Hi, a while ago time calculation was subject on this list. Now, I have a time library based on the TAI (international atomic time) time scale.
Peter Thiemann (Thu, Feb 06, 2003 at 12:40:14PM -0800):
John's code illustrates TimeDiff's deficiencies perfectly:
There is also a more fundamental problem with the TimeDiff data type. While seconds, minutes, hours, and days are clearly specified amounts of time, the duration of a month or a year may vary depending on the reference point where the time difference is applied.
newtype TimeDiff = TimeDiff Rational deriving (Eq, Ord)
Hmm, this is underspecified! As another poster said, (pointing out http://cr.yp.to/libtai, but it is better to look at http://cr.yp.to/time.html, which has a discussion on UTC vs TAI vs UNIX time) the official source of time is TAI, so it is best to base a time library *on the number of TAI seconds since a reference date* (which is btw what the libtai is all about). For compatibility with UNIX time, "Arthur David Olson's popular time library uses an epoch of 1970-01-01 00:00:10 TAI" [http://cr.yp.to/proto/utctai.html]. So this mostly means that you need to set your system clock correctly:-)
Sincerly, -- Stefan Karrmann
Stefan Karrmann <sk@mathematik.uni-ulm.de> writes:
a while ago time calculation was subject on this list. Now, I have a time library based on the TAI (international atomic time) time scale.
This is cool! But what actually happens when people post interesting library code to the list? Does somebody snarf it, and put it in a more convenient place? Why not upload it into the Haskell library site at Sourceforge, and just post a description and a pointer? http://sourceforge.net/projects/haskell-libs/ -kzm -- If I haven't seen further, it is by standing in the footprints of giants
On Sat, 1 Nov 2003 17:36:11 +0100 Stefan Karrmann <sk@mathematik.uni-ulm.de> wrote:
a while ago time calculation was subject on this list. Now, I have a time library based on the TAI (international atomic time) time scale.
I get the following error with GHCi: ------------------------------------------------------------ Compiling Main ( Tai.lhs, interpreted ) Tai.lhs:450: Couldn't match `LeapSeconds' against `TAI' Expected type: LeapSeconds Inferred type: TAI In the first argument of `cFromTai', namely `taileap1' In the first argument of `cSecond', namely `(cFromTai taileap1 lst)' Tai.lhs:453: Couldn't match `LeapSeconds' against `TAI' Expected type: LeapSeconds Inferred type: TAI In the first argument of `cFromTai', namely `taileap2' In the first argument of `cSecond', namely `(cFromTai taileap2 lst)' Tai.lhs:472: Couldn't match `LeapSeconds' against `TAI' Expected type: LeapSeconds Inferred type: TAI In the first argument of `cFromTai', namely `taileap1' In the first argument of `cSecond', namely `(cFromTai taileap1 lst)' Tai.lhs:475: Couldn't match `LeapSeconds' against `TAI' Expected type: LeapSeconds Inferred type: TAI In the first argument of `cFromTai', namely `taileap2' In the first argument of `cSecond', namely `(cFromTai taileap2 lst)' Failed, modules loaded: none. ------------------------------------------------------------ Also, wouldn't make sense to add: cConvert :: (Calendar a, Calendar b) => a -> b cConvert = cFromTai . cToTai Or it is already there and I've missed it? Juanma
Dear Juanma, some last moment changes broke the library, I am sorry. Juanma Barranquero (Thu, Nov 06, 2003 at 05:03:03PM +0100):
On Sat, 1 Nov 2003 17:36:11 +0100 Stefan Karrmann <sk@mathematik.uni-ulm.de> wrote:
a while ago time calculation was subject on this list. Now, I have a time library based on the TAI (international atomic time) time scale.
I get the following error with GHCi:
------------------------------------------------------------
Compiling Main ( Tai.lhs, interpreted )
Tai.lhs:450: Couldn't match `LeapSeconds' against `TAI'
Also, wouldn't make sense to add:
cConvert :: (Calendar a, Calendar b) => a -> b cConvert = cFromTai . cToTai
I've inserted 'convert = (uncurry cFromTai) . cToTai'. A fixed and checked version is appended and carbon copied to <haskell-libs-developers@lists.sourceforge.net>. Regards, -- Stefan Karrmann
On Fri, 7 Nov 2003 19:55:47 +0100 Stefan Karrmann <sk@mathematik.uni-ulm.de> wrote:
I've inserted 'convert = (uncurry cFromTai) . cToTai'.
Great, thanks.
A fixed and checked version is appended and carbon copied to <haskell-libs-developers@lists.sourceforge.net>.
What's haskell-libs-developers? I thought libraries' development was carried over on libraries@haskell.org... (And shouldn't we be discussing Tai.lhs there, BTW :) I'm attaching a patch (diff -u2) with a few small changes: - 1%seconds_per_day -> 1 % seconds_per_day (otherwise GHC complains in -fglasgow-exts mode because it misinterprets it as an implicit parameter). - I've put a few _ here and there to silence warnings for unused arguments. - I've renamed a few variables because of "shadows an existing binding" warnings. - I've deleted a few internal definitions apparently not used (according to -Wall), like cumulated_month_length_after_february. - I've corrected a few typos. More coments: - I'm sending you the patch throw the Haskell list because previous attempts of sending to your e-mail address failed. - Are you very fond of the literate style? I ask because unlit'ing it would allow adding Haddock coments, which would be nice. - I'm not sure I like depending on a leapseconds table hardcoded in the source, even if it changes slowly. Wouldn't it be better to have the data in a file and load it through unsafePerformIO? (And isn't loading configuration data one of the few "good" examples of use of unsafePerformIO, after all? :) - I get a warning with -Wall: Warning: Defined but not used: TimeDiff, days_from_MJD2unixEpoch, days_from_unixEpoch2MJD', hours_per_day, isodelta, isomoveDHM, isomoveS, isomoveYM, libtaiEpoch, month_per_year, test, test2 Several of these are neither used nor exported. ??? Thanks, Juanma
Dear Juanma, thanks for your remarks. Juanma Barranquero (Mon, Nov 10, 2003 at 10:54:22AM +0100):
On Fri, 7 Nov 2003 19:55:47 +0100 Stefan Karrmann <sk@mathematik.uni-ulm.de> wrote:
I've inserted 'convert = (uncurry cFromTai) . cToTai'.
Great, thanks.
A fixed and checked version is appended and carbon copied to <haskell-libs-developers@lists.sourceforge.net>.
What's haskell-libs-developers? I thought libraries' development was carried over on libraries@haskell.org... (And shouldn't we be discussing Tai.lhs there, BTW :)
Well, the original thread was on this list. I'm moving it to libraries@haskell.org now.
I'm attaching a patch (diff -u2) with a few small changes:
I've included it.
More coments:
- I'm sending you the patch throw the Haskell list because previous attempts of sending to your e-mail address failed.
I'm using ASK as a spam killer. Do you have problems with it?
- Are you very fond of the literate style? I ask because unlit'ing it would allow adding Haddock coments, which would be nice.
I've given it a try, but my comment marking could be improved.
- I'm not sure I like depending on a leapseconds table hardcoded in the source, even if it changes slowly. Wouldn't it be better to have the data in a file and load it through unsafePerformIO? (And isn't loading configuration data one of the few "good" examples of use of unsafePerformIO, after all? :)
Well, I included the two as examples. The empty one is correct for all times before 1970-01-01. That's more than ten billion years.
- I get a warning with -Wall:
Warning: Defined but not used: TimeDiff, days_from_MJD2unixEpoch, days_from_unixEpoch2MJD', hours_per_day, isodelta, isomoveDHM, isomoveS, isomoveYM, libtaiEpoch, month_per_year, test, test2
Some values are only for testing and debugging while others are experimental, e.g. TimeDiff and friends.
Several of these are neither used nor exported. ???
Regards, -- Stefan Karrmann
participants (3)
-
Juanma Barranquero -
ketil+haskell@ii.uib.no -
Stefan Karrmann