[Haskell-cafe] Help parsing dates and times
Bjorn Bringert
bringert at cs.chalmers.se
Tue Oct 16 10:52:24 EDT 2007
On Oct 16, 2007, at 16:16 , Bjorn Bringert wrote:
> On Oct 16, 2007, at 2:25 , Don Stewart wrote:
>
>> jgbailey:
>>> I am trying to parse various date and time formats using the
>>> parseTime
>>> function found in (GHC 6.6.1) Data.Time.Format. The one that
>>> is giving me
>>> trouble looks like this:
>>>
>>> 2008-06-26T11:00:00.000-07:00
>>>
>>> Specifically, the time zone offset isn't covered by the format
>>> parameters
>>> given. I can almost parse it with this:
>>>
>>> %FT%X.000
>>>
>>> But that doesn't take into account the "-07:00" bit. I'm sure
>>> this has
>>> been solved - can someone point me to the solution? Thanks in
>>> advance.
>
> Try %z
>
> (see http://www.haskell.org/ghc/docs/latest/html/libraries/time/
> Data-Time-Format.html#v%3AformatTime for all the format specifiers).
>
>> Is there anything in the parsedate library?
>>
>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/
>> parsedate-2006.11.10
>> http://hackage.haskell.org/packages/archive/parsedate/
>> 2006.11.10/doc/html/System-Time-Parse.html
>>
>> -- Don
>
> parsedate is obsolete, unless you have ghc < 6.6.1. It was
> rewritten to become what is now the date parsing code in the time
> package.
Hmm, perhaps I should clarify this: parsedate and time-1.1.1 (which
comes with GHC 6.6.1) have different APIs. parsedate produces
CalendarTimes, and the code in time-1.1.1 produces the new time and
date data types. So I guess parsedate isn't actually obsolete,
rather, it's for use with the package currently known as 'old-time'.
/Björn
More information about the Haskell-Cafe
mailing list