Morton Goldberg wrote:
> On Jun 26, 2007, at 8:50 PM, Cool Wong wrote:
> 
>> DateArray = ["Apr", "2", "2007"]
>>
>> How can i read the month and year in the array???
>>
>> The OUTPUT:
>>            day   = 01
>>            month = 04
>>            year  = 07
> 
> Something like this?
> 
> <code>
> require "ParseDate"
> DA = ["Apr", "2", "2007"]
> args = ParseDate.parsedate("#{DA[1]} #{DA[0]} #{DA[2]}")
> date = Time.local(*args).strftime(<<FMT)
> \tday   = %d
> \tmonth = %m
> \tyear  = %y
> FMT
> puts date
> </code>
> 
> <result>
>     day   = 02
>     month = 04
>     year  = 07
> </resutl>
> 
> Regards, Morton
> 

Same idea, but slightly simpler...

da = ["Apr", "2", "2007"]
time = Time.parse(da.join(" "))
puts time.strftime(<<FMT)
\tday   = %d
\tmonth = %m
\tyear  = %y
FMT

__END__

Output:

	day   = 02
	month = 04
	year  = 07

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407