[tz] Buggy %z behaviour in strftime

Michael H Deckers michael.h.deckers at googlemail.com
Mon Jul 18 10:04:26 UTC 2022


On 2022-07-18 09:34, Almaz Mingaleev via tz wrote:
> Setting tm_gmtoff "fixes" it.



     According to page 366 in the newest C draft standard at
[https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2912.pdf],
     strftime() looks at the member .tm_isdst for the format patterns
     %z and %Z; but this member was not initialized and is therefore
     "indeterminate", so that the result produced by strftime() may
     be "unspecified".

     By the way, the draft standard seems to be defective in that
     it does not state that strftime() also looks at the members
     .tm_year, .tm_mon, tm_mday, .tm_hour, .tm_min, .tm_sec
     for printing %z or %Z -- one cannot determine the offset
     or the time zone abbreviation without knowing the timestamp.

     Michael Deckers.



More information about the tz mailing list