Forum: Ruby can not access constants from Time module

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
05337aed68267daec2996e5ca732d476?d=identicon&s=25 akbarhome (Guest)
on 2006-02-20 10:59
(Received via mailing list)
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.
5befe95e6648daec3dd5728cd36602d0?d=identicon&s=25 Robert Klemme (Guest)
on 2006-02-20 11:24
(Received via mailing list)
akbarhome wrote:
> => 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
05337aed68267daec2996e5ca732d476?d=identicon&s=25 akbarhome (Guest)
on 2006-02-20 11:45
(Received via mailing list)
So why does the documentation about Time module list the other
constants like:
ZoneOffset
LeapYearMonthDays
CommonYearMonthDays
MonthValue???

Do you have an idea?
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 Yukihiro Matsumoto (Guest)
on 2006-02-20 14:28
(Received via mailing list)
Hi,

In message "Re: can not access constants from Time module"
    on Mon, 20 Feb 2006 19:23:30 +0900, "Robert Klemme"
<bob.news@gmx.net> writes:

|> 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.
This topic is locked and can not be replied to.