[Haskell-cafe] Fwd: Data.Time

Ashley Yakeley ashley at semantic.org
Sat Jul 2 23:14:55 CEST 2011


On 2011-07-02 13:22, Yitzchak Gale wrote:
> Ashley, heads up! I am CCing you on this message because
> I think a problem has been found with Data.Time.Format.

Thanks Yitzchak.

>> when you think that this is not a parseable date:
>> 2011/1/30 (because the month must be padded by zeros).
>
> Hmm, that does seem wrong. The C API allows that to be
> parsed using the format "%Y/%m/%d", since the leading zero
> for %m and %d are optional when parsing.
> See, for example,
> http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html

This was fixed in time-1.2.0.5. From the haddock for parseTime:

"Supports the same %-codes as formatTime, including %-, %_ and %0 
modifiers."

With ghci:

Prelude System.Locale Data.Time> parseTime defaultTimeLocale 
"%Y/%-m/%-d" "2011/1/30" :: Maybe Day
Loading package old-locale-1.0.0.2 ... linking ... done.
Loading package time-1.2.0.5 ... linking ... done.
Just 2011-01-30

-- 
Ashley Yakeley



More information about the Haskell-Cafe mailing list