[Bug time/23859] tzname, daylight are modified by localtime() in unexpected way
eggert at cs dot ucla.edu
sourceware-bugzilla@sourceware.org
Mon Dec 17 19:13:00 GMT 2018
https://sourceware.org/bugzilla/show_bug.cgi?id=23859
eggert at cs dot ucla.edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |eggert at cs dot ucla.edu
Resolution|--- |INVALID
--- Comment #4 from eggert at cs dot ucla.edu ---
(In reply to Andreas Schwab from comment #3)
> POSIX really only specifies the behaviour of POSIX style
> values for TZ, which cannot change over time.
This is correct. Programs that want time zone abbreviations, UT offsets, and
DST indications even in the presence of non-POSIX TZ settings should use the
tm_zone, tm_gmtoff, and tm_isdst members of struct tm. These members are
thread-safe whereas tzname, timezone, and daylight are not.
Unfortunately tm_zone and tm_gmtoff are not standardized by POSIX. But for
strictly portable POSIX code there should be no problem, since such code
shouldn't use non-POSIX TZ settings, and programs like Alexey's work fine when
they stick to POSIX TZ settings.
For semi-portable code that runs on POSIX platforms but does the right thing
even with non-POSIX TZ settings, Alexey can use strftime "%Z" for time zone
abbreviations, subtract gmtime_r from localtime_r for UT offsets, and use
tm_isdst to approximate the 'daylight' flag (the actual meaning of the
'daylight' flag is pretty much useless in this more-general context).
Admittedly this is a hassle; if this is a problem for Alexey then I suggest
lobbying POSIX to get the standard fixed to specify tm_zone and tm_gmtoff.
Closing the bug report as this is not a bug.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list