[tz] strftime %s

Paul Eggert eggert at cs.ucla.edu
Thu Jan 11 20:28:54 UTC 2024


On 2024-01-11 11:09, Paul Gilmartin via tz wrote:
> That is, it is the responsibility of the programmer to call strftime()
> with a TZ matching that corresponding to struct tm.  I take this to
> mean that gmtime corresponds to GMT0.  There is no need to ad a
> time_t value.

Yes, after looking at this a bit more I'm becoming more inclined to not 
add a strftime_z (and strftime_lz). It's easy to generate the equivalent 
of %s with sprintf on the corresponding time_t value, and none of the 
other strftime formats should care which timezone was used to generate them.

%z and %Z should be calculated from tm_gmtoff and tm_zone (when 
available) rather than by invoking mktime (which is the best you can do 
when they're not available). The next POSIX draft says something along 
these lines, although it botches the details (which admittedly are messy).

If I understand things correctly, it's impossible for an implementation 
to conform to both POSIX-2017 and draft next POSIX in this area. Oh well.



More information about the tz mailing list