Parsing date and time specifications

Hi, I have written a parser that turns an RFC2822 date and time specification into a datatype usable in Haskell. While the parser is working just fine so far, I have a problem with the CalendarTime datatype. It appears that in order to construct one of those, I need _all_ the information it contains, including the weekday (Day) and the number of the day in the year. The problem now is that I do not have this information! Of course I could calculate these values by hand, but this is immensely complicated. I thought about using a TimeDiff instead, but apparently the functions provided in the Prelude do not handle TimeDiff for anything except for "maths" -- what doesn't really help me for what I am trying to do. I briefly looked at the Posix module that comes with GHC as well, and which seems to provide CTime. But then, the Posix module appears to be non-standard. *sigh* Any suggestions what I could do? -peter

On 19 Dec 2002, Peter Simons wrote: (snip)
datatype. It appears that in order to construct one of those, I need _all_ the information it contains, including the weekday (Day) and the number of the day in the year.
The problem now is that I do not have this information! Of course I could calculate these values by hand, but this is immensely complicated. (snip) Any suggestions what I could do?
I have some calendar calculation code in Haskell from which I could easily generate code to calculate the weekday (Day) and the number of the day in the year, if it turns out you do end up needing it. -- Mark

Peter Simons
CalendarTime [...] TimeDiff [...] I briefly looked at the Posix module [...] non-standard. *sigh* [...]
Any suggestions what I could do?
Yes. I think it is widely agreed that the time and date structures in the standard libraries are brok^H^H^H^Hslightly less than useful. I suggest you feel free to rewrite it as you see fit, and then lobby for its inclusion in the hierarchical libraries. (My preju^H^Hference would be to store a date-time internally in a posix-like manner (seconds,microsecond since the epoch).) -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (3)
-
ketil@ii.uib.no
-
Mark Carroll
-
Peter Simons