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

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02789] Re: Time Conversions

From: matz@... (Yukihiro Matsumoto)
Date: 2000-05-12 16:09:09 UTC
List: ruby-talk #2789
Hi,

In message "[ruby-talk:02787] Time Conversions"
    on 00/05/12, "David Douthitt" <DDouthitt@cuna.com> writes:

|Is there a simple straightforward one-liner of a way to convert a string to a Time instance?
|I'd like something like this: given "Fri May 12 2000 10:48a" it woud return a Time instance.

One-liner?  here it is.

  ruby -r parsedate -e 'p Time.mktime(*ParseDate.parsedate("Fri May 12 2000 10:48a")[0..4])'

Or slightly long form:

  require 'parsedate'

  year, month, day, hour, min = ParseDate.parsedate("Fri May 12 2000 10:48a")
  p Time.mktime(year, month, day, hour, min)

							matz.

In This Thread

Prev Next