[phobos] std.datetime fails on OSX

Jonathan M Davis jmdavisProg at gmx.com
Sun Jan 16 04:19:40 PST 2011


On Sunday 16 January 2011 03:50:08 Jacob Carlborg wrote:
> Don't know if it helps but I found this:
> 
> /etc/localtime                  			local time zone file
> /usr/share/zoneinfo             			time zone directory
> /usr/share/zoneinfo/posixrules  	rules for POSIX-style TZ's
> /usr/share/zoneinfo/GMT         		for UTC leap seconds
> 
> If the file /usr/share/zoneinfo/GMT does not exist, UTC leap seconds are
> loaded from /usr/share/zoneinfo/posixrules.
> 
> http://developer.apple.com/library/mac/#documentation/darwin/reference/manp
> ages/man3/tzsetwall.3.html

Welll, the leap seconds are universal. Those won't vary from time zone to time 
zone. The time zone files themselves may or may not have them, so if a program 
reading them in wants to actually use leap seconds, and all it's going by is the 
time zone files, then whether or not leap seconds are used would depend on 
whether they're in the time zone file or not. However, it's quite possible that 
posixrules and GMT contain leap seconds and a program (or the OS) could take the 
leap seconds from there and apply them to any time zone which doesn't have leap 
seconds in its time zone file.

Regardless, the posix standard says to ignore leap seconds, so that's what glibc 
and Linux does. However, that's not to say that the Mac isn't doing something 
different.

From what I recall, all of the time zones in right/ had leap seconds in them and 
none of the others did, but it's quite possible that posixrules and GMT do, and 
I forgot. So, the OSX may just load them from there. It certainly sounds like it 
does in that documentation.

Regardless, I'm not terribly interested in leap seconds (I think that they 
should be abolished along with DST) - particularly since the Posix standard 
disallows them - but since they _are_ in certain time zone files, and some crazy 
programmer may want to use them, or some poor programmer may be forced to use 
them, it seemed like I might as well make it so that std.datetime.PosixTimeZone 
applied leap seconds to time zones whose time zone file contained leap seconds. 
So, I did.

However, with the current design of PosixTimeZone, if a programmer wants to use 
leap seconds, they need to pick a time zone whose file includes leap seconds. 
There's no way to grab the time zone rules from one file and the leap seconds 
from another. So, you couldn't use leap seconds on a Mac unless you brought 
along your own time zone files. But since you can't do it on _Windows_ without 
bringing along your own time zone files (since, as far as I can tell, Windows has 
not support for leap seconds, and WindowsTimeZone certainly doesn't), I don't 
see that as being a big deal.

Regardless, thanks for the info. If nothing else, it does show that Mac OS X is 
doing its own thing with regards to leap seconds. It does make me wonder though 
if they try and use them normally (by the system clock), or if it's just 
something that _can_ be used if you use the right functions. As I understand it, 
the Posix standard requires that leap seconds be ignored, so if the OSX system 
clock uses it, then that would be breaking the standard.

- Jonathan M Davis


More information about the phobos mailing list