Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1109445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:14:11+00:00 2026-05-17T02:14:11+00:00

Ruby’s Time.parse() works for dates from Dec 14 1901 up Jan 18 2038 (this

  • 0

Ruby’s Time.parse() works for dates from Dec 14 1901 up Jan 18 2038 (this appears to be system dependent):

# works
irb(main):038:0> Time.parse('14-12-1901')
=> Sat Dec 14 00:00:00 -0600 1901

# doesn't work
irb(main):039:0> Time.parse('13-12-1901')
ArgumentError: time out of range
    from /usr/lib/ruby/1.8/time.rb:184:in `local'
    from /usr/lib/ruby/1.8/time.rb:184:in `make_time'
    from /usr/lib/ruby/1.8/time.rb:243:in `parse'
    from (irb):39
    from /usr/lib/ruby/1.8/date/format.rb:214

I can’t think of the reason why it stops working there. Why the odd cut-off? How can I programatically get the valid range?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:14:12+00:00Added an answer on May 17, 2026 at 2:14 am

    Ruby’s Time class is a wrapper around time_t, which uses a signed int to represent seconds since the beginning of the Unix epoch. With a 32-bit int, this causes the 1901-2038 boundaries you’re experiencing. This is often referred to as the Y2038 bug.

    PHP actually suffers from this same bug, so while this is a weird source for answering a Ruby question, here’s an except from the PHP manual:

    The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch.

    According to this article, Ruby 1.9.2 should fix this issue (and Rails accounts for it as well).

    Alternately, you can use the DateTime class, which is able to parse the dates you’re having issues with:

    DateTime.parse('13-12-1901').strftime("%Y-%m-%d")
    => "1901-12-13"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ruby-mode from svn, looks equal to 1.1 version here is emacs indentation of hash
Ruby Enterprise Edition fails to compile from sources with GCC 4.5, but sucessfully compiles
Ruby works well with Unicode character in File Path and Filenames on Mac OS
Ruby has this very interesting functionality in which when you create a class with
ruby somescript.rb somehugelonglistoftextforprocessing is this a bad idea? rather should i create a separate
Ruby Motion comes with a lot of pre-built functions that are formatted like this:
Ruby docs don't mention this. Does Dir.glob(*) guarantee the order of the files it
Ruby has this great abstraction layer on top of Selenium called Capybara, which you
Ruby Settings From terminal % ruby -v ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux] =>
[ruby 1.8] Assume I have: dummy string do puts thing end Now, this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.