RE: Concerning Time.TimeDiff

| Following a brief off-list exchange, Simon Marlow suggested I post some | notes here concerning Time.diffClockTimes and Time.TimeDiff. These arise | from my thought that the current behaviour of the GHC library in | (sometimes) returning a value with positive seconds and negative | picoseconds values might be viewed as perverse. I'm trying to go beyond a | "what is technically correct" viewpoint to "what is useful"... | | I understand there's some history here, of which I'm not properly aware, so | if this is merely rehashing old ground, please ignore. The H98 Time module is probably broken in many ways. Rather than try to fix it incrementally, I think it'd be most productive if the interested parties simply got together and agreed an interface for a new Time module, even if it's incompatible with the old one. Perhaps Graham is The Man! Simon

"Simon Peyton-Jones"
I understand there's some history here, of which I'm not properly aware, so if this is merely rehashing old ground, please ignore.
As someone who got entangled in this last time it was discussed (and the time before that), I can inform you that it has indeed been discussed a bit, and that you could probably search the archives profitably for ideas and thoughts on the matter. http://www.haskell.org/pipermail/haskell/2002-January/008678.html and (same thread, but broken up, due to broken mail headers): http://www.haskell.org/pipermail/haskell-cafe/2002-December/003742.html http://www.haskell.org/pipermail/haskell-cafe/2002-December/003751.html http://www.haskell.org/pipermail/haskell-cafe/2002-December/003758.html
Rather than try to fix it incrementally, I think it'd be most productive if the interested parties simply got together and agreed an interface for a new Time module, even if it's incompatible with the old one.
Yes, definitely. Useful time/data module is probably best designed by somebody who actually *have* use for it. -kzm -- If I haven't seen further, it is by standing in the footprints of giants

I finally took a look at the earlier discussions, and find that I stand by the broad view I expressed before [1]. I think it is not the role of a "standard library" to be all applications, but rather that it should aim to provide functionality that is useful to a wide range of applications. Specialized applications are, well, special, and their raison d'etre is to embody specialized domain knowledge in executable form, while a general purpose language and libraries aims to provide the means for expressing such embodiment. (This may be a simplification, but I think the principle is fair.) In particular, I think that calendar based scheduling (6:00PM local time on the second Thursday of every month) is a specialized, if widely used, kind of application. I don't think the common library should be trying to support such functionality, if only because whatever semantics you choose, you can be pretty certain it will be wrong for a signifcant number of would-be users. What the standard library *can* do is provide tools that specialized applications can use: for example, functions to convert between Gregorian calendar dates and Julian dates are well-defined, and can make a range of other, more specialized functions much easier to code. In a similar vein, I think it's quite usual for people and applications to deal with a day as a consistent time interval without concern for possible leap seconds, so dealing with days as intervals of 24*60*60 seconds is useful for a majority of applications that deal with such intervals. Thus, allowing intervals to be expressed using days and sub-intervals, or seconds and sub-intervals have roles in a supporting framework that can be used by a variety of applications. In any redesign, I would suggest dropping the redundant day-of-year and day-of-week values, replacing them with functions. I assume there's no burning need for a redesign of this. There should come a time, hopefully not too far away, when I'll be designing Haskell support for aspects of RFC 2445-based calendar information expressed in RDF [2]. That would probably be a good time for me to consider a concrete design and implementation. If there's consensus on a design, I think the only tricky part of its implementation will be a dependable Gregorian/Julian date conversion function, and I expect that already exists. #g -- [1] http://haskell.cs.yale.edu/pipermail/libraries/2003-June/001095.html [2] http://www.w3.org/2002/12/cal/ At 14:08 02/06/03 +0200, Ketil Z. Malde wrote:
"Simon Peyton-Jones"
writes: I understand there's some history here, of which I'm not properly aware, so if this is merely rehashing old ground, please ignore.
As someone who got entangled in this last time it was discussed (and the time before that), I can inform you that it has indeed been discussed a bit, and that you could probably search the archives profitably for ideas and thoughts on the matter.
http://www.haskell.org/pipermail/haskell/2002-January/008678.html
and (same thread, but broken up, due to broken mail headers):
http://www.haskell.org/pipermail/haskell-cafe/2002-December/003742.html http://www.haskell.org/pipermail/haskell-cafe/2002-December/003751.html http://www.haskell.org/pipermail/haskell-cafe/2002-December/003758.html
Rather than try to fix it incrementally, I think it'd be most productive if the interested parties simply got together and agreed an interface for a new Time module, even if it's incompatible with the old one.
Yes, definitely. Useful time/data module is probably best designed by somebody who actually *have* use for it.
-kzm -- If I haven't seen further, it is by standing in the footprints of giants
-------------------
Graham Klyne

On Mon, Jun 16, 2003 at 04:42:53PM +0100, Graham Klyne wrote:
... I think it's quite usual for people and applications to deal with a day as a consistent time interval without concern for possible leap seconds, so dealing with days as intervals of 24*60*60 seconds is useful for a majority of applications that deal with such intervals.
What about the fact that days are not actually intervals of 24*60*60 seconds (as I'm sure you know)? Most applications don't care, but it's crucial to give correct and unsurprising results. I'm worried that the complexity to deal with leap seconds will end up being just as complicated as the complexity to deal with more general TimeDiff's as in the current library, in which case it may be necessary to bite the bullet and specify the behaviour of TimeDiffs completely and accurately. Peace, Dylan

Dylan Thurston writes: : | What about the fact that days are not actually intervals of 24*60*60 | seconds (as I'm sure you know)? Most applications don't care, but | it's crucial to give correct and unsurprising results. : Some applications surreptitiously use sixtieths of minutes instead of seconds. :-)

At 18:56 16/06/03 +0200, Dylan Thurston wrote:
On Mon, Jun 16, 2003 at 04:42:53PM +0100, Graham Klyne wrote:
... I think it's quite usual for people and applications to deal with a day as a consistent time interval without concern for possible leap seconds, so dealing with days as intervals of 24*60*60 seconds is useful for a majority of applications that deal with such intervals.
What about the fact that days are not actually intervals of 24*60*60 seconds (as I'm sure you know)? Most applications don't care, but it's crucial to give correct and unsurprising results.
This area is something of a judgement call. I agree with your comment (below) about the complexity of leap second support. (Worse, impossibility for far future dates, because I understand the occurrence of leap seconds is not even known very far in advance.) The view I was expressing was based on an opinion that for the majority of "ordinary" applications, treating a day as anything other than 24*60*60 would be surprising. If I want to say that an event takes place exactly N days after some previous event, say 2003-06-17T10:39:00+01:00, in the overwhelming majority of cases (and this is a judgement rather than an assertion) I expect it would be surprising if the clock time of the later event were not exactly T10:39:00+01:00, or equivalent. (Using RFC3339 [1] notation :-) Therefore, in an implementation of time intervals that includes a measure of days would be very clear that for that purpose, a day is defined as 24*60*60 seconds. Of course, another perfectly good approach would be to stick to seconds and picoseconds, and let the application figure out larger interval units. My judgement is based on my own past experience or writing and using such code, which is more than none at all, but not especially extensive. If there's any significant concern about ignoring leap seconds in time intervals, then rather than debate it at length, I'd rather just stick to seconds.
I'm worried that the complexity to deal with leap seconds will end up being just as complicated as the complexity to deal with more general TimeDiff's as in the current library, in which case it may be necessary to bite the bullet and specify the behaviour of TimeDiffs completely and accurately.
Yes, I do agree that behaviour of TimeDiffs should be should be specified
"completely and accurately", including any simplifying assumptions such as
possibly ignoring leap seconds.
#g
--
[1] http://www.ietf.org/rfc/rfc3339.txt
-------------------
Graham Klyne
participants (6)
-
Dylan Thurston
-
Graham Klyne
-
Graham Klyne
-
ketil@ii.uib.no
-
Simon Peyton-Jones
-
Tom Pledger