@@ -140,7 +140,7 @@ def __init__(self, datetime_local_struct, days_ahead, utc_offset_string):
140140 lunar data), documented at:
141141 https://docs.api.met.no/doc/sunrise/celestial.html
142142 """
143- if days_ahead :
143+ if days_ahead > 0 :
144144 # Can't change attributes in struct_time, need to create a new
145145 # one which will roll the date ahead as needed. Convert to local
146146 # epoch seconds and back for the offset to work. :/
@@ -310,8 +310,8 @@ def __init__(self, datetime_local_struct, days_ahead, utc_offset_string):
310310 gc .collect ()
311311 NOW_LOCAL_SECONDS = time .time () # Current local epoch time in seconds
312312
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 :
315315 try :
316316 DATETIME_LOCAL_STRUCT , UTC_OFFSET_STRING = update_system_time ()
317317 LAST_SYNC_LOCAL_SECONDS = time .mktime (DATETIME_LOCAL_STRUCT )
@@ -331,7 +331,7 @@ def __init__(self, datetime_local_struct, days_ahead, utc_offset_string):
331331 NOW_UTC_SECONDS = NOW_LOCAL_SECONDS - utc_offset_seconds
332332
333333 # 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 :
335335 PERIOD [0 ] = PERIOD [1 ]
336336 PERIOD [1 ] = MoonData (time .localtime (), 1 , UTC_OFFSET_STRING )
337337
@@ -372,7 +372,7 @@ def __init__(self, datetime_local_struct, days_ahead, utc_offset_string):
372372 # the future, and C) are closer than the last guess. What's left at the
373373 # end is the next rise or set time, and a flag whether the moon's
374374 # 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
376376 for DAY in PERIOD :
377377 if (DAY .rise_utc_seconds and
378378 NOW_UTC_SECONDS < DAY .rise_utc_seconds < NEXT_EVENT_UTC_SECONDS ):
0 commit comments