On 10/16/07, Bjorn Bringert <bringert@cs.chalmers.se> wrote:

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'.

Given this date string:

  2008-06-26T11:00:00.000-07:00

The problem is the parseTime function in Data.Time.Format is a little too strict. The following GHCi session shows the different behaviors. Notice how %Z is unable to parse the time zone offset in any case. First we try parseTime:

  > :m + Data.Time System.Time.Parse System.Locale
  > let dateStr = "2008-06-26T11:00:00.000-07:00"
  > parseTime defaultTimeLocale "%FT%X.000%z" dateStr :: Maybe UTCTime
  Nothing
  > parseTime defaultTimeLocale "%FT%X.000-%z" dateStr :: Maybe UTCTime
  Nothing
  > parseTime defaultTimeLocale "%FT%X.000" dateStr :: Maybe UTCTime
  Nothing

Now parseCalendarTime from the parseDate package:

  > parseCalendarTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S" dateStr
  Just (CalendarTime {ctYear = 2008, ctMonth = June, ctDay = 26, ctHour = 11, ctMin = 0, ctSec = 0, ctPicosec = 0, ctWDay
= Thursday, ctYDay = 1, ctTZName = "UTC", ctTZ = 0, ctIsDST = False})
  > parseCalendarTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S.000%Z" dateStr
  Nothing


Justin