astral icon indicating copy to clipboard operation
astral copied to clipboard

Help understanding the `timezone` field of a `LocationInfo`, does it do anything when used in tandem with sun?

Open HarrisonWilde opened this issue 2 years ago • 0 comments

Hi, I have a use case where I know my longitude and latitude but not the timezone (using IP to get my current approx lat and long). I want to then use this package to calculate the sunrise and sunset times for my location. However, I am unsure what I should set the timezone to in the argument when instantiating LocationInfo. I can use the dateutil module to ensure when I instantiate sun on the LocationInfo I pass it tz.tzlocal() to its tzinfo argument, but I don't understand what the timezone set prior to this will do? E.g. say I instantiate a lat and long roughly on the west coast of the US:

city = LocationInfo(latitude = 34, longitude = -118)

The timezone will default to Europe/London. If I then do:

s = sun(city.observer, date=datetime.today(), tzinfo=tz.tzlocal())

Assuming I am actually at that lat/long, the times returned seem correct, even though the timezone on the city is incorrect? Hope my question makes sense.

HarrisonWilde avatar Jan 19 '23 21:01 HarrisonWilde