A classic calendar change bug
Jan. 8th, 2010 05:53 pmI happened across an interesting new year bug this week. I was investigating why a particular command failed to work correctly when run on the 31st December 2009.
After some digging, I discovered that the command was being passed the date of the next day in month and day format, e.g. "01/01", which appears to have been incorrectly evaluated as "01/01/2009" instead of "01/01/2010". Which indicates that, if the year isn't specified, the command simple tacks on the current year — something that works in every case except where the date crosses a calendar year change.
The solution to the problem seems to me to be relatively simple. Given that, by its nature, the command cannot act on any date that has already passed, it should assume the current year unless the date has already passed, in which case it should assume next year. While not perfect, this should at least avoid triggering problems on New Year's Eve, a time when most good sysadmins are out partying. Or asleep.
But it just goes to show how easy it is, a decade after all that time and money and effort was spent on Y2K, to fail to correctly account for calendar changes.
After some digging, I discovered that the command was being passed the date of the next day in month and day format, e.g. "01/01", which appears to have been incorrectly evaluated as "01/01/2009" instead of "01/01/2010". Which indicates that, if the year isn't specified, the command simple tacks on the current year — something that works in every case except where the date crosses a calendar year change.
The solution to the problem seems to me to be relatively simple. Given that, by its nature, the command cannot act on any date that has already passed, it should assume the current year unless the date has already passed, in which case it should assume next year. While not perfect, this should at least avoid triggering problems on New Year's Eve, a time when most good sysadmins are out partying. Or asleep.
But it just goes to show how easy it is, a decade after all that time and money and effort was spent on Y2K, to fail to correctly account for calendar changes.