[Haskell-cafe] Telling the time

Andrew Coppin andrewcoppin at btinternet.com
Thu Jun 21 16:15:12 EDT 2007


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?



More information about the Haskell-Cafe mailing list