[M3devel] leap-second issue with Date.i3

hendrik at topoi.pooq.com hendrik at topoi.pooq.com
Sat Nov 10 21:11:01 CET 2007


On Sat, Nov 10, 2007 at 03:33:03AM -0800, Mika Nystrom wrote:
> Hello everyone,
> 
> I just ... added a workaround for a nasty bug I had in some code
> of my own.  My code used Unix's localtime to convert a Time.T to a
> Date.T using the zoneinfo files.  I'm not sure if there's a "normal"
> way to do this in M3, so I have some messy stuff involving mutexes,
> static storage, etc.  (Note one has to be careful when linking this
> stuff into a program with the normal M3 conversion codes---Date.FromTime
> and Date.ToTime---which also use (other) hidden mutexes to protect
> some of the same data structures!)
> 
> The issue is this.  I just realized that localtime sometimes returns
> "60" for the seconds---namely, during a leap second!  Just copying
> this into a Date.T will lead to a range error and a program crash.
> Do we really want Modula-3 users to have to restart their servers
> the moment after popping the champagne corks?  (Ok, well during
> New Year's Eve in my time zone, but still...)

Does that mean that each time zone, as midnight creeps around the world, 
will insert the leap second at its own midnight, resulting in time-zone 
differences of 59 minutes and 59 seconds?

-- hendrik

> 
> Does anyone know how Date.T handles/should handle this?  As correct
> as it is, I find it somewhat unsatisfying to change the seconds
> field to [0..60], because off-by-one errors are so common in
> programming... it's probably The Right Thing to do, though.
> 
>      Mika




More information about the M3devel mailing list