4 ms·
Reusing datetime.timezone would not make sense. datetime.timezone represents fixed UTC offsets, while ZoneInfo objects represent IANA timezones (which generally
by progval 4y ago
Reusing datetime.timezone would not make sense. datetime.timezone represents fixed UTC offsets, while ZoneInfo objects represent IANA timezones (which generally don't have a fixed offset).
- lifthrasiir 4y agoI believe GP wants something like `datetime.timezone.from_tzid("Etc/UTC")`, which is by itself a fine backward-compatible upgrade from the original interface.
- Macha 4y agoI would disagree that this is a fine interface. It's not clear with the "Etc/UTC", but what is the offset of datetime.timezone.from_tzid("America/New_York")? You need a datetime to go with the TZ id to answer that question. And experience has shown "Just assume the current time" is a bit of a footgun.
- lifthrasiir 4y agoAs currently defined, datetime.timezone doesn't directly expose the zone offset as a whole and always requires some reference datetime object to compute it, even though the built-in implementation would simply ignore it for now [1]. So it can be surely upgraded. [1] https://docs.python.org/3/library/datetime.html#datetime.timezone.utcoffset https://docs.python.org/3/library/datetime.html#datetime.tim...