[tz] Buggy %z behaviour in strftime

Steffen Nurpmeso steffen at sdaoden.eu
Mon Jul 18 22:19:19 UTC 2022

Paul Eggert wrote in
 <7bfb9e88-eeb0-7cd1-b57b-b648558c1ddc at cs.ucla.edu>:
 |On 7/18/22 09:03, Paul Eggert wrote:
 |> I suppose someone should file a defect report with the C standardization 
 |> committee.
 |I found what I hope is the correct email address for that (it's not 
 |well-advertised) and submitted the following bug report:

 |Subject: strftime %z and %Z depend on more than just tm_isdst
 |Some implementations (e.g., AIX, Solaris) infer %z and %Z output from 
 |tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, and tm_isdst, and 
 |therefore sometimes guess %z or %Z output incorrectly when the clock 
 |moves back from one standard time to another (e.g., Iran at the end of 
 |the year 1978). These implementations typically also depend on the 
 |current setting of the TZ environment variable.
 |Other implementations (e.g., FreeBSD, GNU/Linux) get the UT offset and 
 |abbreviation from struct tm members tm_gmtoff and tm_zone that are not 
 |specified by the C standard. These implementations do not have to guess 
 |%z and %Z output; however, they require that the nonstandard members be 
 |filled in correctly by localtime or equivalent.

The next POSIX standard at least will support these two members:



|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

More information about the tz mailing list