[tz] Java & Rearguard

Guy Harris guy at alum.mit.edu
Tue Jun 4 17:36:09 UTC 2019


On Jun 4, 2019, at 9:48 AM, Steve Summit <scs at eskimo.com> wrote:

> What you may be more interested in is a name or abbreviation
> for the local time zone, or the time delta between the local
> time and UTC.  tm_isdst is of no use (at least, not by itself)
> in answering those questions; what you really want is the tm_zone
> and tm_gmtoff fields (which are, sadly, not official, but that's
> another story).

And they're not *present* on all UN*Xes; SunOS 5/Solaris 2 and later, for example, lacks them.  Adding them would take some work to preserve binary compatibility, given that localtime_r() is handed a pointer to such a structure to fill in.  If the system library were to offer multiple versions of localtime_r(), and the development tools were to ensure that code compiled with headers where those fields are missing will call the version of the routine that does not fill them in and code compiled with headers where those fields are present will call the version of the routine that does fill them in, that would work (Apple did something like that when it added support for 64-bit inode numbers in calls such as stat()).

So you may want them, but you can't necessarily have them.

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?

> So the analogous question for me is, "What are Java programs
> using isDaylightSavings for?  What problems would it cause them
> if isDaylightSavings's output changed, or if it disappeared?
> Would some other differently-defined function serve the needs
> of those programs better?"

"And do programs that use it expect it to be true, or false, if they're running in a tzdb region for a country such as Morocco, where they don't do DST but they *do* adjust the clock during Ramadan, and the date/time happens to be during Ramadan?"



More information about the tz mailing list