summaryrefslogtreecommitdiffstats
path: root/app/time_fn.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/time_fn.c')
-rw-r--r--app/time_fn.c30
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;
}