Magnus Therning | 9 Nov 2006 16:38
Gravatar

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.
Malcolm Wallace | 9 Nov 2006 17:57
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
Dougal Stanton | 9 Nov 2006 16:58
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 2006 20:43
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 2006 00:29
Gravatar

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 2006 01:27
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)


Gmane