can not access constants from Time module

A

akbarhome

Hi,

I want to know how many days a month has. So I lookup here:
http://www.ruby-doc.org/core/classes/Time.html

CommonYearMonthDays and LeapYearMonthDays constants do what I need. But
I cannot access them.

$ irb
irb(main):001:0> require "time"
=> true
irb(main):002:0> print Time::CommonYearMonthDays
NameError: uninitialized constant Time::CommonYearMonthDays
from (irb):2

But I can access constants from another module, such as BLOCK_SIZE from
openssl/buffering module.

Any idea? Ruby 1.8.4 ( build from source ).

Thank you.
 
R

Robert Klemme

akbarhome said:
Hi,

I want to know how many days a month has. So I lookup here:
http://www.ruby-doc.org/core/classes/Time.html

CommonYearMonthDays and LeapYearMonthDays constants do what I need.
But I cannot access them.

$ irb
irb(main):001:0> require "time"
=> true
irb(main):002:0> print Time::CommonYearMonthDays
NameError: uninitialized constant Time::CommonYearMonthDays
from (irb):2

But I can access constants from another module, such as BLOCK_SIZE
from openssl/buffering module.

Any idea? Ruby 1.8.4 ( build from source ).

Thank you.

Probably a documentation bug

11:22:19 [workspace]: ruby --version
ruby 1.8.4 (2005-12-24) [i386-cygwin]
11:22:26 [workspace]: ruby -r time -e 'puts Time.constants'
RFC2822_MONTH_NAME
RFC2822_DAY_NAME
11:22:34 [workspace]:

Kind regards

robert
 
A

akbarhome

So why does the documentation about Time module list the other
constants like:
ZoneOffset
LeapYearMonthDays
CommonYearMonthDays
MonthValue???

Do you have an idea?
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: can not access constants from Time module"

|> CommonYearMonthDays and LeapYearMonthDays constants do what I need.
|> But I cannot access them.

|Probably a documentation bug

They are constants defined in metaclass of Time.

matz.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top