Replies: 8 comments 1 reply
|
My first instinct is to agree with your points. I'm hesitant to add another class though...
There will be plenty of these type of decisions. My gut feeling is that it's best (most Pythonic, perhaps) to aim for the common use cases and leave users with complex needs to use lower-level libraries ( |
|
Coming back to this issue, my conclusion so far is that most metadata that can be retrieved from |
|
@exoriente has expressed interest in picking up this issue. |
|
Note: with the implementation of timezone logic in Rust (#202), this issue becomes a lot more involved: TZ names and DST flags would need to be added to TZif file parsing. On the plus side, whenever's custom TZif implementation allows introduction of methods like |
|
I just noticed the status change. Has this been implemented? |
|
@ofek @bxparks the upcoming release (0.10) adds:
See the docs here There is now also a Likely to be implemented:
Not (yet) implemented:
|
|
Pre-release 0.10.0b3 now includes |
|
Release 0.10 is now out with a lot of improvements to timezone metadata. Feel free to reopen this discussion if there are any issues. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I took a quick scan through the API doc (https://whenever.readthedocs.io/en/latest/api.html), and I noticed that the IANA TZDB timezones are always referenced symbolically, through a string (e.g. "America/Los_Angeles"). As far as I can tell, there is no explicit
TimeZoneclass. (I assume internally,wheneveris usingzoneinfoor something similar.) This means that timezone metadata is not available. For example:tz.name()- full unique name of the IANA timezone (e.g. "America/Los_Angeles")tz.abbrev(timestamp)- the IANA abbreviation (e.g. "EST") at a giventimestamptz.stdoffset(timestamp)- the Standard UTC offset at a giventimestamptz.dstoffset(timestamp)- the DST offset at a giventimestamptz.utcoffset(timestamp)- the full UTC offset at a giventimestamp(i.e. stdoffset + dstoffset)tz.isambiguous(timestamp)- return True iftimestampgenerates aZonedDateTimewhose innerDateTimerepresentation is ambiguoustz.transitions(from, until)- list of DST transitions between[from, until)tz.version()- return the IANA TZDB version identifier (e.g. "2024a"), this is important for deterministic and reproducible integration testsI also noticed that your
AwareDateTimeclasses do not have methods corresponding to some of these. In other words, the following do not exist:ZonedDateTime.tzname()ZonedDateTime.tzabbrev()ZonedDateTime.stdoffset()ZonedDateTime.dstoffset()ZonedDateTime.utcoffset()Admittedly, applications which need this information are rare, but they do exist. If the
wheneverlibrary aims to be a general purpose replacement of the standarddatetimelibrary, then access to the TimeZone metadata may need to be added.All reactions