
Greetings. Is there a standard library function anywhere which will parse a string into some kind of date/time representation? And, further, is there some function that will tell me how many seconds elapsed between two such times? (I see there's a giant pile of modules to do with dates and times, but I can't make much sense out of them - and in at least one place, the documentation on the Haskell website doesn't actually match what's installed on my computer!) I want to write a program which reads a file of the form 2007-05-26 11:23:16 PM|Begin processing... 2007-05-26 11:23:16 PM|Done stage #1 2007-05-26 11:23:21 PM|Done stage #2 2007-05-26 11:24:05 PM|Done stage #3 and produce a new file of the form 2007-05-26 11:23:16 PM|Begin processing... +0|Done stage #1 +5|Done stage #2 +44|Done stage #3 Ideally I'd like to have it able to parse several slightly differing date/time formats. (It turns out my programs all log using a very subtly different format!) Before I go on an 8-month expedition to reimplement this myself, is there something I can use in the library?

On 6/21/07, Andrew Coppin
Is there a standard library function anywhere which will parse a string into some kind of date/time representation?
In Data.Time.Format, there's parseTime. parseTime takes a format string that describes the layout. Since you have varying layouts in your files (hopefully consistent in the same file!), you simply change the format string for each file. -- Rich JID: rich@neswold.homeunix.net AIM: rnezzy

On Thu, Jun 21, 2007 at 09:15:12PM +0100, Andrew Coppin wrote:
Greetings.
Is there a standard library function anywhere which will parse a string into some kind of date/time representation? And, further, is there some function that will tell me how many seconds elapsed between two such times? I know about Data.Time.* and System.Time ( tdSec . diffClockTimes )
For parsing there is the library written by bringert: http://www.cs.chalmers.se/~bringert/darcs/parsedate/ I don't know wether it is in the library index on the haskell.org. If not we should add it. I was'nt able to find it there.
(I see there's a giant pile of modules to do with dates and times, but I can't make much sense out of them - and in at least one place, the
The trouble is that time processing can be complicated if you want to pay attention to leap seconds/ years etc. leap seconds can't be known in advance etc.
documentation on the Haskell website doesn't actually match what's installed on my computer!) That's why I'm reading the source all the time ;) 2007-05-26 11:23:16 PM|Begin processing...
HTH Marc Weber

Marc Weber wrote:
On Thu, Jun 21, 2007 at 09:15:12PM +0100, Andrew Coppin wrote:
Greetings.
Is there a standard library function anywhere which will parse a string into some kind of date/time representation? And, further, is there some function that will tell me how many seconds elapsed between two such times?
I know about Data.Time.* and System.Time ( tdSec . diffClockTimes )
For parsing there is the library written by bringert: http://www.cs.chalmers.se/~bringert/darcs/parsedate/
I don't know wether it is in the library index on the haskell.org. If not we should add it. I was'nt able to find it there.
OK, I'll try a deeper look...
(I see there's a giant pile of modules to do with dates and times, but I can't make much sense out of them - and in at least one place, the
The trouble is that time processing can be complicated if you want to pay attention to leap seconds/ years etc. leap seconds can't be known in advance etc.
I don't care about leap seconds - and neither does the hardware clock on the server that generates these logs. ;-) I just want to find out how long each step took...
documentation on the Haskell website doesn't actually match what's installed on my computer!)
That's why I'm reading the source all the time ;)
Oh... goodie...
participants (3)
-
Andrew Coppin
-
Marc Weber
-
Rich Neswold