Misc and Advanced - FObersteiner/zdt GitHub Wiki
similar projects in Zig
- zeit, datetime and time zone library
- datetime, generic Date, Time, and DateTime library, time zone handling not implemented
- tempus, time library with focus on performance & low level stuff
- zig-datetime, Python-arrow like semantics, time zones only represented by fixed offsets (! notes: this is very error-prone...)
- zig-time, date/time parsing/formatting, no time zone features
- chrono-zig, a port of Rust's
chrono
crate - Karl Seguin's zig utility library also offers some date/time functionality (no time zone features)
Related:
- zig-tzif, TZif and POSIX TZ string parsing library
Datetime.now(null)
give a UTC-like datetime ?
why does If you supply null
(no time zone), the fields of the returned datetime will resemble UTC. This is a compromise. You can convert that to Unix time and it will be "correct". If the returned datetime would resemble your local time, the conversion to Unix time would not be possible without knowing the according offset from UTC. So the choice boils down to: you cannot convert naive datetime to Unix time or naive datetime is treated like it was UTC.
Ambiguous and Non-Existent Datetime: folds and gaps
A datetime is ambiguous if it appears multiple times on a wall clock:
- DST transition fold: wall clock moved backwards when daylight saving time goes from active to inactive
A datetime is non-existent if it does not appear on a wall clock:
- DST transition gap: wall clock moved forwards when daylight saving time goes from inactive to active
The DST tag wiki on StackOverflow has a nice illustration for this.
IANA time zone identifiers vs. Windows time zone names
This library works with the IANA database exclusively. Therefore, a mapping is required if a Windows time zone should be acquired. For example, this is needed in Timezone.tzLocal
. Since IANA db and Windows db do not strive to achieve an unambiguous mapping between the databases, this method is error-prone. zdt
uses the mapping provided by the Unicode CLDR Project. The mapping is updated by /util/gen_wintz_mapping.py
.
Some resources related to this:
- Jon Skeet on StackOverflow
- timezone tag wiki on StackOverflow