Topic: Time.parse - time out of range

Im lost:


Joels-Macbookpro:~/locomotive/joel/joel joelnylund$ ruby script/console
Loading development environment.
>> s = "1/4/2007"
=> "1/4/2007"
>> t = Time.parse(s)
=> Thu Jan 04 00:00:00 EST 2007
>> s = "1/4/2070"
=> "1/4/2070"
>> s = "07/16/2070"
=> "07/16/2070"
>> Time.parse(s)
ArgumentError: time out of range
        from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/1.8/time.rb:184:in `local'
        from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/1.8/time.rb:184:in `make_time'
        from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/1.8/time.rb:243:in `parse'
        from (irb):5

Is there a limit to the ruby clock?

thanks
Joel

Re: Time.parse - time out of range

ok , after googling a bit, it looks like ruby Time cant hold a date after 2037 on 32 bit operating systems. Wow that sucks real bad, I feel like that young programmer that just realized float didnt store accurate decimals smile

Anwyay, I think rails active record maps mysql datetime to a ruby Time, if this is the case I can never store any datetime greater than 2037 in a rails application, please say it isnt so?

any workaround?

I guess I could make it a string and do date time conversion in ruby?

Re: Time.parse - time out of range

It depends on the field type you're using I believe. YEAR and DATE will be mapped to Date, DATETIME will be mapped to DATETIME, and TIMESTAMP or TIME will be mapped to Time.

Alex

Re: Time.parse - time out of range

Hi, Im using mysql, I have a column which is a datetime column, when I retrieve the active record and call the getter and ask it its class, it is a "Time" object.

This seems contrary to your above note. Is there a config in rails that you can control this stuff?

Re: Time.parse - time out of range

repost hoping for some help