I Hate Date Processing
Fri Feb 29th 2008, 3:19pm
Today a software project I'm involved in got bit by a bug regarding FTP date processing in the Apache Common Net library (Apache Commons Net implements the client side of many basic Internet protocols. The purpose of the library is to provide fundamental protocol access). I'll quote Johan Vos' blog which summarizes the problem nicely:
I discovered that the FTPFiles that are created get a Date that is obtained by parsing the date provided by the ftp server. The Unix ftp server returns the date in the format "MMM d HH:mm". No year info is supplied. This caused problems, of course, since Feb 29 is not a valid day in the default year 1970.
Sigh, date processing just sucks. So I don't blame (much) whoever made that assumption that using 1970 as the default year was okay. And you can bet this will make the prime time news--here come all the y2k jokes all over again.

So since today is a leap day, it's always good to remember the specific formula to use to determine if a year is a leap year:
Every year divisible by 4 is a leap year, unless it's divisible by 100 in which case it's not, unless it's divisible by 400 in which case it is.
This funky formula is expected to keep the Gregorian calendar in sync with the Sun for at least another 4000 years. And if we remember to use it, we can spare future generations from any y2100 bugs. For more details, Wikipedia has (as usual) a good article on the topic.