From 15f6b14a9f22615734e05bd044292594ba3b6bb5 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 3 Nov 2018 23:06:07 +0000 Subject: [PATCH] Make the boundary between ADVANCE and STOP variable at compile time. --- clunk.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/clunk.c b/clunk.c index 6e6e191..669c8b8 100644 --- a/clunk.c +++ b/clunk.c @@ -6,6 +6,16 @@ static long const pulsewidth = 250000000; /* nanoseconds */ +/* + * Maximum error to correct by advancing the clock rather than + * stopping it, in seconds. The point where it's faster to stop the + * clock than to advance it is around 11:15 forwards (0:45 backwards), + * but this is set a little lower so that setting the clock back for + * the end of summer time is done by stopping, in accordance with + * Synchronome's documentation. + */ +static int const maxadvance = (10 * 3600) + (50 * 60); + static struct tm displayed; static void @@ -68,7 +78,7 @@ need_adjust(struct tm const *now) if (diff < 0) diff += 3600 * 12; diff %= 3600 * 12; printf("diff = %ld\n", diff); - if (diff < 30 || diff >= (10 * 3600)) return STOP; + if (diff < 30 || diff >= maxadvance) return STOP; if (diff < 60) return TICK; if (diff < (10 * 3600)) return ADVANCE; } -- 2.30.2