srawlins / timezone

Time zone database and time zone aware DateTime object for Dart.
BSD 2-Clause "Simplified" License
102 stars 54 forks source link

How do I get TimeZone name from numeric offset? #159

Closed tsquillario closed 1 year ago

tsquillario commented 1 year ago

I'm returning a DateTimeOffset from a my backend like 2023-06-17 18:30:00.0000000 -06:00. I'm trying to figure out how to get the timezone name from the offset -06:00. Is there any way to do this?

I have a DropDown which is a list from tz.timeZoneDatabase.locations and I'd like to set the correct value without storing the timezone name string in my database. Thoughts?

tsquillario commented 1 year ago

I see why this is not possible, one offset could return multiple timezones. You could lookup the offset in milliseconds but would have no way of knowing which timezone was the correct one. Closing.