Date and DateTime on the Mac

R

Ronny

I have installed ruby for Mac OS/X. Strangely, the classes Date and
DateTime
are not known:

NameError: uninitialized constant DateTime
from (irb):1

At least some other classes (I tried File and Time) exist, so it is
not that the
installation were completely broken.

What could be the problem here?

Ronald
 
G

Gary Wright

I have installed ruby for Mac OS/X. Strangely, the classes Date and
DateTime
are not known:

NameError: uninitialized constant DateTime
from (irb):1

At least some other classes (I tried File and Time) exist, so it is
not that the
installation were completely broken.

What could be the problem here?

did you do a

require 'date'

before trying to access Date or DateTime. They are not part of
the Core classes that are automatically defined when Ruby starts up.
 
R

Ronald Fischer

did you do a
=20
require 'date'
=20
before trying to access Date or DateTime. They are not part of
the Core classes that are automatically defined when Ruby starts up.

OK, that solves it - but interestingly, a require 'date' is=20
not necessary when running under Windows (both in the native and
cygwin build of Ruby).=20

Ronald
--=20
Ronald Fischer <[email protected]>
Phone: +49-89-452133-162
 
J

John Joyce

OK, that solves it - but interestingly, a require 'date' is
not necessary when running under Windows (both in the native and
cygwin build of Ruby).

Ronald
That may mean it's loading all those libraries on windows even if you
don't need them...
You might run a test to see if methods from various libraries are
available.
 
R

Ronald Fischer

OK, that solves it - but interestingly, a require 'date' is
That may mean it's loading all those libraries on windows=20
even if you =20
don't need them...
You might run a test to see if methods from various libraries are =20
available.

I wonder whether this is really the "official" definition of Ruby that
date.rb must be required explicitly. On Linux, it isn't necessary
either,
and at least the Ruby books I have access to ("The Ruby Way" by Hal
Fulton
and "The Ruby Cookbook" by Richardson and Carlson) don't mention a
require 'date' when discussing the Date and DateTime classes...

Ronald
--=20
Ronald Fischer <[email protected]>
Phone: +49-89-452133-162
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top