Time library underspecified

John Meacham john@repetae.net
Thu, 14 Nov 2002 13:39:47 -0800


yes! I was just wrestling with this yesterday. I finally gave up and
looked inside ghc's (TOD Integer Integer) directly because the Time
library as it currently stands is somewhat less than useful. This is
probably a pretty serious bug in Haskell 98 as there is no good way to
work with times other than roll your own.

how about:
toRawTime :: ClockTime -> (Integer,Integer)
where they are # of seconds and picoseconds since epoch.
(and an 'epoch' constant ClockTime)

another useful thing would be  
endOfTime and beginningOfTime constants, representing the minimum and
maximum values representable by ClockTime.
	John

On Thu, Nov 14, 2002 at 10:22:46AM -0800, Christopher Milton wrote:
> Hmm, this has come up before:
> 
> http://www.haskell.org/pipermail/glasgow-haskell-bugs/2001-September/001810.html
> http://www.haskell.org/pipermail/haskell/2002-January/008678.html
> 
> --- Peter Thiemann <thiemann@informatik.uni-freiburg.de> wrote:
> > Did anyone try to use the standard Time library that comes with Haskell 
> > for a serious purpose?
> > 
> > I wanted to, but came across the problem that the TimeDiff data type is 
> > underspecified. For example, what is the official way to convert a 
> > TimeDiff value into seconds? The problematic parts are:
> > * how many days for one tdYear (365, 366)
> > * how many days for one tdMonth (28,29,30,31)
> > * how many seconds for one tdMin (given the presence of leap seconds)^(1)
> > Actually, once the absolute reference of the TimeDiff is lost, then it
> > is impossible to recover leap years and leap seconds, so TimeDiff
> > better had to account for them somehow. I suppose, the best would be
> > to just have diffClockTimes return the number of seconds as an Integer.
> > 
> > Since Simon PJ has finished editing the library report, who's now in 
> > charge of keeping track of problems with it and perhaps writing a 
> > commentary in cases such as this?
> > 
> > Cheers
> > -Peter
> > 
> > (1) for this one, there is reasonable consensus. for example the ISO 
> > 8601 standard (representation of dates and times) defines minute=60 
> > seconds, hour=60 minutes, day=24 hours. However, this leads to the 
> > strange(?) situation that the difference between
> > 1998-12-31T12:00:00 and 1999-01-01T12:00:00
> > is 1 day and one second. (There was a leap second on that night
> > 
> >                1998 December 31   23h   59m   59s
> >                1998 December 31   23h   59m   60s
> >                1999 January  01    0h    0m    0s
> > 
> > see http://tycho.usno.navy.mil/leap.html)
> > 
> > 
> > 
> > _______________________________________________
> > Haskell mailing list
> > Haskell@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell
> 
> 
> =====
> Christopher Milton
> cmiltonperl@yahoo.com
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
> 

-- 
---------------------------------------------------------------------------
John Meacham - California Institute of Technology, Alum. - john@foo.net
---------------------------------------------------------------------------