@@ -140,7 +140,7 @@ def __init__(self, datetime_local_struct, days_ahead, utc_offset_string):
140
140
lunar data), documented at:
141
141
https://docs.api.met.no/doc/sunrise/celestial.html
142
142
"""
143
- if days_ahead :
143
+ if days_ahead > 0 :
144
144
# Can't change attributes in struct_time, need to create a new
145
145
# one which will roll the date ahead as needed. Convert to local
146
146
# epoch seconds and back for the offset to work. :/
@@ -310,8 +310,8 @@ def __init__(self, datetime_local_struct, days_ahead, utc_offset_string):
310
310
gc .collect ()
311
311
NOW_LOCAL_SECONDS = time .time () # Current local epoch time in seconds
312
312
313
- # Sync with time server every ~12 hours
314
- if NOW_LOCAL_SECONDS - LAST_SYNC_LOCAL_SECONDS > 12 * 60 * 60 :
313
+ # Sync with time server every ~3 hours
314
+ if NOW_LOCAL_SECONDS - LAST_SYNC_LOCAL_SECONDS > 3 * 60 * 60 :
315
315
try :
316
316
DATETIME_LOCAL_STRUCT , UTC_OFFSET_STRING = update_system_time ()
317
317
LAST_SYNC_LOCAL_SECONDS = time .mktime (DATETIME_LOCAL_STRUCT )
@@ -331,7 +331,7 @@ def __init__(self, datetime_local_struct, days_ahead, utc_offset_string):
331
331
NOW_UTC_SECONDS = NOW_LOCAL_SECONDS - utc_offset_seconds
332
332
333
333
# If PERIOD has expired, move data down and fetch new +24-hour data
334
- if NOW_UTC_SECONDS >= PERIOD [1 ].end_utc_seconds :
334
+ if NOW_UTC_SECONDS >= PERIOD [0 ].end_utc_seconds :
335
335
PERIOD [0 ] = PERIOD [1 ]
336
336
PERIOD [1 ] = MoonData (time .localtime (), 1 , UTC_OFFSET_STRING )
337
337
@@ -372,7 +372,7 @@ def __init__(self, datetime_local_struct, days_ahead, utc_offset_string):
372
372
# the future, and C) are closer than the last guess. What's left at the
373
373
# end is the next rise or set time, and a flag whether the moon's
374
374
# currently risen or not.
375
- NEXT_EVENT_UTC_SECONDS = PERIOD [ 1 ]. end_utc_seconds + 100000 # Way future
375
+ NEXT_EVENT_UTC_SECONDS = NOW_UTC_SECONDS + 300000 # Way future
376
376
for DAY in PERIOD :
377
377
if (DAY .rise_utc_seconds and
378
378
NOW_UTC_SECONDS < DAY .rise_utc_seconds < NEXT_EVENT_UTC_SECONDS ):
0 commit comments