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

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02792] Re: Time Conversions

From: "David Douthitt" <DDouthitt@...>
Date: 2000-05-12 17:00:57 UTC
List: ruby-talk #2792
Thank you thank you!

But now, a few questions...

Your code:

  require 'parsedate'
  include ParseDate

  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?

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.

It also too me a little bit to realize that 5 elements or 6, mktime (or local) still works - had to go back and read Time::gm from your (WONDERFUL!) reference.

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

http://www.rubycentral.com/ref/ref_c_time.html#to_a

Thank you for all of your hard work on that reference!

In This Thread

Prev Next