[Haskell-cafe] string to date?

Magnus Therning magnus at therning.org
Thu Nov 9 18:29:47 EST 2006

On Thu, Nov 09, 2006 at 20:43:36 +0100, Björn Bringert wrote:
>Dougal Stanton wrote:
>>Quoth Magnus Therning, nevermore,
>>>I've been staring my eyes out trying to find a function that converts a
>>>string into a ClockTime or CalendarTime.  Basically something like C's
>>>strptime(3).  I can't seem to find anything like it in System.Time,
>>>there are function that convert _to_ a string, but nothing that converts
>>>_from_ a string it seems.  Where should I look?
>>The MissingH.Time.ParseDate [1] module might be what you want. There's
>>also one from Bjorn Bringert [2]. I haven't used either though, so I
>>can't recommend anything between them.
>>[1]: <http://quux.org:70/devel/missingh/html/MissingH-Time-ParseDate.html>
>>[2]: <http://www.cs.chalmers.se/~bringert/darcs/parsedate/>
>Those two are the same code. I have a preliminary new version which can also 
>parse most of the types from the time package (Data.Time.*) available at:

I noticed one thing when playing around with ParseDate.parseCalendarTime
in ghci:

 > parseCalendarTime System.Locale.defaultTimeLocale "%Y" "2006"
 Just (CalendarTime {ctYear = 2006, ctMonth = January, ctDay = 1, ctHour = 0, ctMin = 0, ctSec = 0, ctPicosec = 0, ctWDay = Thursday, ctYDay = 1, ctTZName = "UTC", ctTZ = 0, ctIsDST = False})
 > parseCalendarTime System.Locale.defaultTimeLocale "%Y%m%d" "20061109"
 > parseCalendarTime System.Locale.defaultTimeLocale "%C%y%m%d" "20061109"
 Just (CalendarTime {ctYear = 2006, ctMonth = November, ctDay = 9, ctHour = 0, ctMin = 0, ctSec = 0, ctPicosec = 0, ctWDay = Thursday, ctYDay = 1, ctTZName = "UTC", ctTZ = 0, ctIsDST = False})

I'm on a Debian Sid system:

 % dpkg -l \*missingh\*
 | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
 |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
 ||/ Name                      Version        Description
 ii  libghc6-hdbc-missingh-dev        Integration of HDBC with MissingH, GHC version
 ii  libghc6-missingh-dev      0.16.2         Library of utility functions for Haskell, GHC6
 un  missingh-doc              <none>         (no description available)

Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
magnus at therning.org             Jabber: magnus.therning at gmail.com

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

It's important for a corporate leader to know the difference between
what is actually illegal, and what people assume should be illegal.
     -- Bill Gates, in interview for The Register, 19th June 2006
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20061109/e90e105d/attachment.bin

More information about the Haskell-Cafe mailing list