DateTime

Hi,

I've just checked out this: http://ruby.cenophobie.com/RubyCheat.pdf
Ruby cheat sheet. On the second page, DateTime is mentioned but when I
try the following:

DateTime::now

or

DateTime.now

it says that the constant DateTime is uninitalized.

Can anyone help?

···

--
Posted via http://www.ruby-forum.com/.

it says that the constant DateTime is uninitalized.

Can anyone help?

Sure. You should add this line:

require ‘date’

you can find some more examples on date/time and other simple exercises on my blog:

http://www.rubyrailways.com/implementing-15-exercises-for-learning-a-new-programming-language/

HTH,
Peter

···

__
http://www.rubyrailways.com

Hi,

···

In message "Re: DateTime" on Mon, 18 Dec 2006 03:39:50 +0900, Lucas Holland <hollandlucas@gmail.com> writes:

DateTime::now

or

DateTime.now

it says that the constant DateTime is uninitalized.

Can anyone help?

Put

   require 'date'

before using DateTime.

              matz.

"Lucas Holland" typed:

DateTime::now
or
DateTime.now

it says that the constant DateTime is uninitalized.

There is also "Time.now" which, as I see it, does not require any
module(s) to be loaded explicitly by the user. I haven't checked yet, but
do the two differ in any other way than the format in which they report
time?

···

--
Ayaz Ahmed Khan

It is impossible to defend perfectly against the attack of those who
want to die.

Peter Szinek wrote:

Sure. You should add this line:

require ‘date’

Thanks a lot, Peter. It works fine now.

···

--
Posted via http://www.ruby-forum.com/\.

This older thread might clear up the confusion between DateTime and Time:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/96071

- rob

···

On 12/18/06, Ayaz Ahmed Khan <ayaz@dev.slash.null> wrote:

"Lucas Holland" typed:
> DateTime::now
> or
> DateTime.now
>
> it says that the constant DateTime is uninitalized.

There is also "Time.now" which, as I see it, does not require any
module(s) to be loaded explicitly by the user. I haven't checked yet, but
do the two differ in any other way than the format in which they report
time?

--

"Rob Sanheim" typed:

···

On 12/18/06, Ayaz Ahmed Khan <ayaz@dev.slash.null> wrote:

There is also "Time.now" which, as I see it, does not require any
module(s) to be loaded explicitly by the user. I haven't checked yet, but
do the two differ in any other way than the format in which they report
time?

This older thread might clear up the confusion between DateTime and Time:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/96071

An insightful explanation. Thanks, Rob.

--
Ayaz Ahmed Khan

It is impossible to defend perfectly against the attack of those who
want to die.