linux - 32 bit ruby 1.9.2p290 Time can't handle 2038? -
32-bit ruby 1.9.2p290 (which must use), seems having hard time adding 25 (but not 24!) years current time.
now = time.now more_time = (24*365*24*60*60) puts "more_time.class = #{more_time.class}" later = + more_time = time.now more_time = (25*365*24*60*60) puts "more_time.class = #{more_time.class}" later = + more_time
produces:
more_time.class = fixnum
more_time.class = fixnum
ruby_time.rb:11:in `+': time + 788400000.000000 out of time range (rangeerror) ruby_time.rb:11
am running year 2038 problem? don't have issue 64-bit ruby 1.9.2-p290.
32 bit ruby uses 32 bits represent time, therefore has valid range 13 dec 1901 20:45:54 utc
19 jan 2038 03:14:07 utc
, these minimum/maximum signed integer values representable 32 bits, time 0 being unix epoch time (1 jan 1970 00:00:00 utc
).
64 bit ruby uses 64 bits represent time, therefore has valid range of anything.
to fix this, using datetime
class, not limited 32 bits.
Comments
Post a Comment