The following message is a courtesy copy of an article that has been posted to comp.lang.functional as well. Hi, what is the wisdom behind representing a TimeDiff as a struct of year, month, week and so on, instead of simply the (fractional) number of seconds, or similar? In particular, the derivation of Eq seems to me to imply that sixty minutes is not the same as one hour. I haven't gotten around to play much with the module yet, but at least Prelude> (Time.TimeDiff 0 0 0 1 0 0 0) == (Time.TimeDiff 0 0 0 0 60 0 0) False Could somebody please enlighten me on this issue? -kzm -- If I haven't seen further, it is by standing in the footprints of giants
what is the wisdom behind representing a TimeDiff as a struct of year, month, week and so on, instead of simply the (fractional) number of seconds, or similar?
Firstly, I believe that the Time module is broken, and no one has yet come up with a satisfactory design. But the behaviour you describe is necessary. Consider: 01-Jan-2002 plus 1 month = 01-Feb-2002 01-Feb-2002 plus 1 month = 01-Mar-2002 01-Mar-2002 plus 1 month = 01-Apr-2002 01-Apr-2002 plus 1 month = 01-May-2002 The first and third differences are 2678400 seconds, but the second is 2419200 and the fourth is 2592000. The same is true for many other time differences. If you want the interval between two times, then simply subtract the seconds; but if you want to compute things like "next week", "next month", "next year", you need to have specific units for that. (For "next week", consider the impact of leap seconds...) HTH. --KW 8-)
participants (2)
-
Keith Wansbrough -
Ketil Z Malde