jiff/testprograms/invalid-tz-environment-variable
Andrew Gallant 08abeadd09 tz: fallback to Etc/Unknown when TZ is set to an invalid value
Previously, when `TZ` was set to an invalid value, Jiff would still
attempt to detect the system configured time zone. But this is arguably
not great, because it silently (aside from logs) rejects an invalid
`TZ` value. In reality, if `TZ` is set, it is likely that the user
intends for it to have an impact. So if it doesn't, we should bleat
about it.

This manifests as an error when using `TimeZone::try_system()` and
manifests as a error sentinel in the form of `Etc/Unknown` when using
`TimeZone::system()`.

We also tweak some of the logging levels. Namely, in #370, I increased
the number of TRACE-level log messages, which makes it much noisier. So
I've promoted a few things that were TRACE to DEBUG without making the
output much noisier. I guess TRACE should be reserved for variable
length things.

Fixes #364
2025-05-17 11:02:57 -04:00
..
Cargo.toml tz: fallback to Etc/Unknown when TZ is set to an invalid value 2025-05-17 11:02:57 -04:00
main.rs tz: fallback to Etc/Unknown when TZ is set to an invalid value 2025-05-17 11:02:57 -04:00
README.md tz: fallback to Etc/Unknown when TZ is set to an invalid value 2025-05-17 11:02:57 -04:00

This tests that Jiff falls back to the special Etc/Unknown time zone when the TZ environment variable is set to a non-empty and invalid value. This also checks that a set but empty TZ environment variable is indistinguishable from TZ=UTC (which follows existing convention for GNU and BSD implementations of POSIX date).

See #364 for discussion about this behavior.