The Y3001 bug.

schwern on 2008-10-02T05:24:42

In my attempts to make Perl's date handling as portable and future-proof as possible, I've tested a lot of implementations of gmtime() and localtime() on a lot of compilers and operating systems. This one takes the cake.

Microsoft Visual C++ 2008 Express Edition.
gmtime max    32535291599 (Thu Jan 01 20:59:59 3001)
localtime max 32535244799 (Thu Jan 01 07:59:59 3001)
gmtime min    -43200      (Thu Dec 31 12:00:00 1969)
localtime min 0           (Thu Jan 01 00:00:00 1970)


What?! 3001? What in the screaming hell is so special about Jan 1st, 3001? And what's up with failing at noon? And 3 hours, 1 second before midnight? Windows keeps its system clock in local time, but I'm in EDT (-4) so that doesn't jive.

Weird.

UPDATE: Turns out their difftime() can't handle negative times. WHAT?! It's a fucking SUBTRACTION FUNCTION!