From: Christopher Thompson Date: 2009-01-21T04:34:17+09:00 Subject: [ruby-core:21475] Re: Time.gm give me ArgumentError out of range (ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]) Claudio Fiorini wrote: > Hi all, > today i was fetching some data from a database through odbc and during > mapping of types i got argument error 'out of range'. > To repeat this error i have created a new file, very simple, with this: > > puts Time.gm(2009,1,1) > puts Time.gm(1800,1,1) > > and this is the result: > > prova.rb:2:in `gm': time out of range (ArgumentError) > from prova.rb:2 > > I found out that the first year that doesn't return error is 1902. > Digging in file time.c i read about the tmcmp function, but i couldn't > understand why, can someone explain me please? > > Thanks a lot > > Claudio See http://www.ruby-doc.org/core/classes/Time.html#M000250 Time is stored internally as the number of seconds from the epoch. On some platforms/implementations, you are permitted to use negative numbers. That limits you to +/- 2^31 seconds from the epoch (Jan 1, 1970). In fact, you can create times in 1901 on most platforms, just not as far back as Jan 1, 1901.