Thursday, February 7, 2008

March 9th 2008 @ 2am does not compute

I find problems like this terribly fascinating... first some background...

At work, we integrate with a PHP based application called NATS in order to provide us with affiliate tracking as well as manage the connection between the credit card billers and our users. So, when a user comes to one of our sites, clicks the join button, they are redirected to NATS. They fill out a bit more information and are then redirected to the biller to enter their credit card information. After they are done, the user is redirected back to us. On the back end, the biller tells NATS that the user has paid and NATS also passes that information back to our code so that we can track their subscription as well. The majority of our subscriptions are for a month at a time. This is a convoluted process which mostly works great except that recently we figured out that NATS has been creating subscriptions for about a month from now... which is March 9th... which happens to be a daylight savings time switch at 2 a.m.

So, the summary of that long paragraph is that we have a system that is creating an expires date for a time that does not exist! So, March 9th @ 2am does not exist. To quote another site: "In spring, clocks spring forward from 1:59 a.m. to 3:00 a.m."

After a bit of digging in google, I found this issue. It seems that after so many years of PHP existence, they have still not been able to get date time handling correct. It is possible to create an invalid date/time in PHP! Because we use Java for our systems, when we get the expires time from NATS we use the most excellent Joda Time library to create a new DateTime object. This library correctly recognizes it is an invalid date and throws an IllegalArgumentException.

Fun times indeed.

No comments: