[Haskell-cafe] Help parsing dates and times

Bjorn Bringert bringert at cs.chalmers.se
Tue Oct 16 16:44:18 EDT 2007

On Oct 16, 2007, at 21:39 , Carl Witty wrote:

> On Tue, 2007-10-16 at 09:25 -0700, Justin Bailey wrote:
>> On 10/16/07, Bjorn Bringert <bringert at cs.chalmers.se> wrote:
>>         Should we just add XX:XX as an alternative time zone offset
>>         format
>>         accepted by %z and %Z? Is this a standard format?
> Yes, this is standard; see below.
>> I'm not sure, but I am getting this date from Google in their XML
>> feeds representing calendar data. The specific element is "gd:when",
>> documented here:
>> http://code.google.com/apis/gdata/elements.html#gdWhen
> That refers to XML Schema; the dateTime type in XML Schema is  
> standardized here:
> http://www.w3.org/TR/xmlschema-2/#dateTime
> (and time zone offsets are required to have a colon in this format).

Thanks, I have added this to the parser now. I can't push right now  
because of performance problems, but it'll be in darcs soon.

Now it works:

Prelude Data.Time System.Locale> parseTime defaultTimeLocale "%FT%T%Q% 
z" "2008-06-26T11:00:00.087-07:00" :: Maybe ZonedTime
Just 2008-06-26 11:00:00.087 -0700

Note that I use %Q for the second decimals instead of .000, this  
makes it accept non-integer seconds.


More information about the Haskell-Cafe mailing list