You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from datetime import datetime
from astral import LocationInfo
from astral.location import Location
from astral.sun import sun
loc_info = LocationInfo('', '', 'Asia/Kolkata', 10.7655888888889, 78.7150444444444)
loc = Location(loc_info )
time_local = datetime.strptime('2024-05-17 22:34:37', '%Y-%m-%d %H:%M:%S')
s = sun(loc_info .observer, date=time_local .date(), tzinfo=loc .timezone)
Above snippet would result in Unable to find a dawn time on the date specified
The reason is because the initial calculation would give the tot (time of transit) as 2024-05-18 05:29:42.178336+05:30, and then its date (2024-05-18) is used to compare against (2024-05-17), which would adjust the input date to 2024-05-16, thus the ValueError.
Proposed solution: the initial date comparison between tot and input date should account for timezone.
The text was updated successfully, but these errors were encountered:
The question is - is it possible that the caller actually wants to find the dawn by rolling to further past? I understand the steps is to to calculate the time of transit by rolling forward, but is there a set of steps to follow to roll back further to find the time of transit instead which can be offered as option to function caller? That can potentially help with such detection in the aforementioned corner case.
current steps to adjust offset - if the offset exceeds half a day in the past, then it would roll forward a day:
Above snippet would result in
Unable to find a dawn time on the date specified
The reason is because the initial calculation would give the tot (time of transit) as
2024-05-18 05:29:42.178336+05:30
, and then its date (2024-05-18) is used to compare against (2024-05-17), which would adjust the input date to 2024-05-16, thus the ValueError.Proposed solution: the initial date comparison between tot and input date should account for timezone.
The text was updated successfully, but these errors were encountered: