On Friday, 2 May 2003 22:05:43 +0900, Robert wrote:

> Hm, how about a static method in class Time, maybe
> Time.parse(pattern ="<iso default>") with <iso default>
> replaced by the ISO default pattern (something like
> "YYYY.MM...")?

Yes, I will like to consider the ISO patterns even though
currently my "need of the day" does not require it to be.

> Alternatively you could introduce a class TimeParser
> that is constructed with a pattern and can create Time
> instances from given strings.

I am looking at the ParseDate module that comes with the
standard distribution which can handle a subset of ISO-8601
formats among others. But it returns an array which I can
easily convert to a Time object.

On my WinXP Pro (ruby 1.6.8 (2002-12-24) [i586-mswin32]
something like:

#-----------------------------------------------------

require 'parsedate'

date = `date /t`
time = `time /t`
puts date, time if $DEBUG

a = ParseDate::parsedate(date + ' ' + time)
p a if $DEBUG

a.pop
t = Time::local(*a)
p t #=> Sat May 03 17:57:00 Central Daylight Time 2003

#-----------------------------------------------------


What do you think ?
-- shanko