Open jeremyjjbrown opened 1 year ago
Is your local timezone set to UTC?
>>> import time
>>> time.tzname
('EET', 'EEST')
>>> from suntime import Sun
>>> sun = Sun(43, -88)
>>> sun.get_local_sunrise_time()
datetime.datetime(2024, 1, 3, 15, 24, tzinfo=tzlocal())
>>> sun.get_local_sunrise_time().tzname()
'EET'
>>> sun.get_sunrise_time()
datetime.datetime(2024, 1, 3, 13, 24, tzinfo=tzutc())
>>> sun.get_sunrise_time().tzname()
'UTC'
You can also just use time_zone=tz.gettz('US/Central')
when you call the functions to get the correct timezone.
My local timezone is set to ('GMT', 'BST')
but get_local_sunrise_time()
gives the time in UTC
(which is equal to GMT
but not BST
).
sun.get_local_sunrise_time().tzname
returns None
Ah, I see this function is being deprecated.
This seems to be a reliable drop-in for me
get_local_sunrise_time = lambda: sun.get_sunrise_time(
time_zone=datetime.datetime.now().astimezone().tzinfo)