Monday, February 20, 2006

Ruby Till the End of Time...

or, more precisely, Mon Jan 18 22:14:07 Eastern Standard Time 2038.

But give the very next second a try...

puts Time.local(2038,1,18,22,14,8)


That's the limit when you start at the Epoch and count the seconds using 31 bits. It suprised me, as this was something I bumped my head against on UNIX so long ago (I've seen a frightfully large percentage of those 31 bits!) Not too big a suprise though, since it is all C under the covers, as Eero Saynatkari reminded me.

I had wondered if I was working with an out-of-date (no irony intended) version of the Time class, but it's clear it's a real issue. Maybe there's a well-used ruby mechanism to get around this, or maybe it'd be a useful exercise to write one. Or perhaps I should just start printing T-shirts with "The next world starts at 1/18/38 22:14:08 EST" on the front?

Mike Schneider put it well, "Y2K was amateur's day's. The epoch rollover day is coming."

No comments: