[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02797] Re: Time Conversions

From: Dave Thomas <Dave@...>
Date: 2000-05-12 17:35:10 UTC
List: ruby-talk #2797
"David Douthitt" <DDouthitt@cuna.com> writes:

>   t = Time.local(*parsedate("Fri May 12 2000 10:48a")[0,6])
>   p t  # => Fri May 12 10:48:00 CDT 2000
> 
> What does the * in *parsedate do?

Converts the array into a list of parameters.

> 
> Secondly, matzes code:
> 
>   require 'parsedate'
> 
>   year, month, day, hour, min = ParseDate.parsedate("Fri May 12 2000 10:48a")
>   p Time.mktime(year, month, day, hour, min)
> 
> You use the array subscript [0,6] (which I read as the zeroth
> element and the sixth element....)  Matz uses [0..4] (which I read
> as the zeroth element THROUGH the fourth element.)  I'm sure I
> misread it, but that's what it looks like.

[0,6] means 6 elements starting at 0.

[0..4] means element 0 through element 4 (5 in all).


Matz left off the seconds because your original time didn't include
seconds.

> You might also want to know that the nice header formatting (et al)
> in ref_c_time.html is lost right after "to_a"

Sigh... Thanks.



Regards

Dave

In This Thread

Prev Next