[M3devel] leap-second issue with Date.i3

Tony Hosking hosking at cs.purdue.edu
Sat Nov 10 17:22:21 CET 2007


I see no problem with changing seconds to [0..60].  That matches the  
POSIX spec nicely enough.

On Nov 10, 2007, at 6:33 AM, 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 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