[tz] Java & Rearguard

Jonathan Lennox lennox at cs.columbia.edu
Tue Jun 4 20:10:18 UTC 2019


On Tuesday, June 4 2019, "Guy Harris" wrote to "Steve Summit, tz at iana.org" saying:

> BTW, what happens on a system that *does* have them if you:
> 
> 	call localtime()/localtime_r();
> 
> 	set the TZ environment variable in your program to a new value and call tzset();
> 
> 	try to use the tm_zone string from the previous localtime()/localtime_r() call?
> 
> Is the tm_zone string guaranteed to survive the tzset() call?

No, its value becomes undefined.

https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/strftime.html :

   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.

This was specifically written to allow the behavior where strftime's %Z
substitutes tm->tm_zone.

-- 
Jonathan Lennox
lennox at cs.columbia.edu



More information about the tz mailing list