[tz] Buggy %z behaviour in strftime
Almaz Mingaleev
mingaleev at google.com
Mon Jul 18 10:56:14 UTC 2022
Tried to set tm_isdst to 0 and 1. With glibc and tzcode strftime
the result is the same, they print +0000. MacOs works as
expected - it prints standard and DST offsets.
Though when I set it to -1 both glibc and MacOs just skip
%z. tzcode's implementation replaces %z with +0000 in that
case.
On Mon, 18 Jul 2022 at 11:04, Michael H Deckers <
michael.h.deckers at googlemail.com> wrote:
>
> 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20220718/51ea3e26/attachment.htm>
More information about the tz
mailing list