Magnus Therning | 9 Nov 16:38 2006

string to date?

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?

/M

--

-- 
Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
magnus <at> therning.org             Jabber: magnus.therning <at> gmail.com
http://therning.org/magnus

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.

Finagle's Sixth Law:
Don't believe in miracles -- rely on them.
Dougal Stanton | 9 Nov 16:58 2006
Picon

Re: string to date?

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.

Cheers,

D.

[1]:
<http://quux.org:70/devel/missingh/html/MissingH-Time-ParseDate.html>
[2]:  <http://www.cs.chalmers.se/~bringert/darcs/parsedate/>
Björn Bringert | 9 Nov 20:43 2006
Picon
Picon

Re: string to date?

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.
> 
> Cheers,
> 
> D.
> 
> [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:

http://www.cs.chalmers.se/~bringert/darcs/parsedate-2/

/Björn
Magnus Therning | 10 Nov 00:29 2006

Re: string to date?

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.
>>Cheers,
>>D.
>>[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:
>
>http://www.cs.chalmers.se/~bringert/darcs/parsedate-2/

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"
 Nothing
 > parseCalendarTime System.Locale.defaultTimeLocale "%C%y%m%d" "20061109"
(Continue reading)

Bjorn Bringert | 10 Nov 01:27 2006
Picon
Picon

Re: string to date?


On 10 nov 2006, at 00.29, Magnus Therning wrote:

> 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.
>>> Cheers,
>>> D.
>>> [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:
>>
>> http://www.cs.chalmers.se/~bringert/darcs/parsedate-2/
(Continue reading)

Malcolm Wallace | 9 Nov 17:57 2006
Picon

Re: string to date?

Magnus Therning <magnus <at> therning.org> wrote:

> 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?

Not quite what you want, but: "read"?  (opposite of "show")

Regards,
    Malcolm

Gmane