diff options
author | root <root@ka-ata-killa.ourano.james.local> | 2021-03-20 18:48:43 +0000 |
---|---|---|
committer | root <root@ka-ata-killa.ourano.james.local> | 2021-03-20 19:01:35 +0000 |
commit | f211fe6461aae73f5ffdbe58961dbe3dd1309854 (patch) | |
tree | a4b698a5146f1ec2584f09db5b7f73f263d6bc4a /app/time_fn.c | |
parent | 5b8f47a70a57765ba04a4d75dfa31a2f55f75029 (diff) | |
download | clock-f211fe6461aae73f5ffdbe58961dbe3dd1309854.tar.gz clock-f211fe6461aae73f5ffdbe58961dbe3dd1309854.tar.bz2 clock-f211fe6461aae73f5ffdbe58961dbe3dd1309854.zip |
make the interval bisection work properly for events in the next hour, add an alarm output
Diffstat (limited to 'app/time_fn.c')
-rw-r--r-- | app/time_fn.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/app/time_fn.c b/app/time_fn.c index 64a92ff..75b69d3 100644 --- a/app/time_fn.c +++ b/app/time_fn.c @@ -417,12 +417,25 @@ int time_ra_cmp (double a, double b) /*Find the next occuring time for RA tra */ +static int test_side (EPOCH m, double tra) +{ + + double ra; + UTC u; + + u = time_epoch_to_utc (m); + ra = time_utc_to_ra (u); + + return time_ra_cmp (ra, tra); +} + + EPOCH time_ra_to_next_epoch (EPOCH l, double tra) { EPOCH r, m; unsigned n; - UTC u; - double ra; + + int dog = 48; printf ("time_ra_to_next_epoch %.9f\n", tra); @@ -432,8 +445,13 @@ EPOCH time_ra_to_next_epoch (EPOCH l, double tra) /* So IB works better */ + while ((test_side (l, tra) != 1) && dog--) + l.s += 3600; + r = l; - r.s += 86400.; + + while ((test_side (r, tra) != -1) && dog--) + r.s += 3600; for (n = 0; n < 64; ++n) { @@ -453,12 +471,8 @@ EPOCH time_ra_to_next_epoch (EPOCH l, double tra) m = time_epoch_add (l, m); - u = time_epoch_to_utc (m); - ra = time_utc_to_ra (u); - - if (time_ra_cmp (ra, tra) < 0) + if (test_side (m, tra) < 0) r = m; - else l = m; } |