[tz] strftime %s

Paul Gilmartin PaulGBoulder at AIM.com
Thu Jan 11 19:09:48 UTC 2024


On 1/10/24 15:05:23, Steve Summit via tz wrote:
> Paul Gilmartin wrote:
>> Seconds since the epoch should not depend on TZ.
>> The epoch is 0 UTC, not 0 local.
>  .
> Right.  So it seems to me that strftime should *not* support %s,
> or at least, not unless struct tm is expanded to include a field
> holding the original time_t value.
>  .
POSIX strftime(), which does nor include the proposed %s,:
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html#tag_16_576_02> says:

"[CX] [Option Start] If a struct tm broken-down time structure is created by localtime() or localtime_r(), or modified by mktime(), and the value of TZ is subsequently modified, the results of the %Z and %z strftime() conversion specifiers are undefined, when strftime() is called with such a broken-down time structure."

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.

> (But, yes, I saw Paul's earlier message mentioning the next POSIX
> draft talking about it.)

-- 
gil



More information about the tz mailing list