chiark / gitweb /
Make the boundary between ADVANCE and STOP variable at compile time.
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 3 Nov 2018 23:06:07 +0000 (23:06 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 3 Nov 2018 23:06:07 +0000 (23:06 +0000)
clunk.c

diff --git a/clunk.c b/clunk.c
index 6e6e19194337da71d04a20c7631d0e4e0fec7ade..669c8b89e5621286feac42c1661630422e536a78 100644 (file)
--- 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;
 }