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.
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.