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 1.9.2, RoR 3.0.1. When I run 'rspec spec' I get this error. Can't
Ruby's date/time helpers are useful but I found a discrepancy. It seems that 12.months
Ruby, Java, and Python all have several very good libraries which allow you to
Ruby version: 3.0.2 Rails: 1.9.2 OS: windows 7 DB: sql server 2008 (r2) I
ruby-1.8.7-p174 > [0,1][2..3] => [] ruby-1.8.7-p174 > [0,1][3..4] => nil In a 0-index setting
Ruby (and the Rails framework) is the first new programming language that I've learned
Ruby newbie here trying to figure out how to use a Gem and thus
Ruby 1.8.7. I'm using a regex with a ^ to match a pattern at
ruby-1.9.2-p0 > Subscription => Subscription(id: integer, email: string, tuan: boolean, send: boolean, created_at: datetime,
Ruby has two ways of referring to the standard input: The STDIN constant ,

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.