mirror of
https://github.com/gabime/spdlog.git
synced 2026-04-19 22:48:53 +00:00
POSIX 2024 defines three formats for the TZ environment variable,
1. Implementation defined format which always starts with a colon:
":characters".
2. A specifier which fully describes the timezone rule in format
"stdoffset[dst[offset][,start[/time],end[/time]]]". Note the
offset and start/end part could be omitted, in which case one hour
is implied, or it's considered implementation-defined when changing
to and from Daylight Saving Time occurs.
3. Geographical or special timezone from an implementation-defined
timezone database.
POSIX 2024 requires the format 1 and 2 to take precedence over format 3.
In tests/test_timezone.cpp, we set TZ to "EST5EDT" or "IST-2IDT".
According to POSIX, "EST5EDT" should be interpreted as
- timezone "EST", which is five hours behind UTC
- corresponding DST timezone is "EDT", which is one hour ahead of
standard time
- it's implementation-defined when changing to and from DST occurs
The interpretion is similar for TZ="IST-2IDT". Obviously we're hitting
implementation-defined behavior here, which is inconsistent across
platforms, e.g., musl considers DST is always active if both DST start
and end rules are omitted, thus test_timezone.cpp would fail.
Let's also provide DST rules when setting TZ variables to avoid
depending on implementation-defined behavior.
Fixes: b656d1ceec ("Windows utc_minutes_offset(): Fix historical DST accuracy and improve offset calculation speed (~2.5x) (#3508)")
Signed-off-by: Yao Zi <me@ziyao.cc>