Pádraig Brady <[email protected]> writes: > Sorry if the threading is broken on this. > It doesn't seem to have been sent to me from the mailing list? > Anyway...
No worries. Going to re-order your message slightly, to respond to each point. > 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/ Thanks, I thought I remembered you documenting something about it. But I forgot where. That is where I remembered it from. > 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. Agreed, I had realized that after sending the patch. But figured it didn't warrant a v2 since it was mostly just an example patch. > stating a file does seem like a useful check indeed, > though it would be best to restrict to builds that > support that concept. Do any operating systems exist that don't use tzdb? Perhaps you have heard of it, Paul? > 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. Is there anywhere where /usr/share/zoneinfo isn't the correct location? That works on macOS, which typically has a stranger layout, e.g., /Users/collinfunk instead of /home/collinfunk or /usrc/home/collinfunk. I guess Windows will likely be something strange. Perhaps it can be determined from the generated lib/configmake.h. I'll try that. It would be easy to parameterize if it were not for cross-compilation. > Also the TZ=:/absolute/path/to/tzfile format would have to be handled. Right. To be honest, I did not know about that form of TZ= or TZDIR=. I've never felt the need to create custom time zone files. It will be useful for testing, though. > 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 Yes, that sounds reasonable. Thanks, Collin
