[tz] Buggy %z behaviour in strftime

Andreas Schwab schwab at suse.de
Mon Jul 18 08:44:43 UTC 2022


On Jul 18 2022, Almaz Mingaleev via tz wrote:

> Attached code prints "+0000 America/Los_Angeles" both with glibc and with
> linked ToT strftime implementation.
> On MacOs it prints "-0800 America/Los_Angeles".
> Is it a known issue?
> #include <time.h>
> #include <stdio.h>
> #include <stdlib.h>
>  
> int main() {
>   struct tm tm = {.tm_mday = 12, .tm_mon = 3, .tm_year = 2022 - 1900, .tm_zone = "America/Los_Angeles"};

You are not setting tm_gmtoff, thus it remains at zero.  MacOS probably
doesn't have tm_gmtoff.

-- 
Andreas Schwab, SUSE Labs, schwab at suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


More information about the tz mailing list