Sorry if the threading is broken on this.
It doesn't seem to have been sent to me from the mailing list?
Anyway...

On 09/08/2026 11:47, Collin Funk wrote:
GNU date falls back to UTC0 when the timezone is invalid. I guess that
isn't too intuitive, see a twitter user who ran into this gotcha (and an
unhinged reply...) [1].

This has been an annoyance for me for ages:
https://www.pixelbeat.org/docs/linux_timezones/

stating a file does seem like a useful check indeed,
though it would be best to restrict to builds that
support that concept.

Note mentioned in the URL is the UTC+5 format etc.
So you'd only want to do the TZ file lookup in restricted cases.
Like when the actual UTC offset returned is 0,
and TZ != UTC0 etc.

Also the /usr/share/zoneinfo dir is parameterized
both at build and runtime through TZDIR define and $TZDIR respectively.
So we'd have to use the TZDIR define and getenv("TZDIR") to get
the appropriate directory.
Also one could use #ifdef TZDIR, to restrict the code above to
supported platforms.

Also the TZ=:/absolute/path/to/tzfile format would have to be handled.

I'm thinking all of the above might be encapsulated
in a tzfile() function, returning NULL if not found?

So in summary pseudo code for this might be:

#ifdef TZDIR
  if (returned_UTC_offset == 0
      && TZ != UTC[-+]?0*
      && ! tzfile())
    dbg_printf (_("warning: TZ=\"%s\" falling back to UTC\n"), tzstring);
#endif

thanks!
Padraig



Reply via email to