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?

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

Peter S. wrote:

Sure. You should add this line:

require ‘date’

Thanks a lot, Peter. It works fine now.

Hi,

In message “Re: DateTime”
on Mon, 18 Dec 2006 03:39:50 +0900, Lucas H.
[email protected] writes:

|DateTime::now
|
|or
|
|DateTime.now
|
|it says that the constant DateTime is uninitalized.
|
|Can anyone help?

Put

require ‘date’

before using DateTime.

						matz.

On 12/18/06, Ayaz Ahmed K. [email protected] wrote:

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

  • rob

“Rob S.” typed:

On 12/18/06, Ayaz Ahmed K. [email protected] 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 K.

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

“Lucas H.” 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 K.

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