On Sunday, I slept an extra hour because of daylight saving time. On Monday and Tuesday, I spent 15 hours debugging and rewriting my time tracking iOS app, 168 Hours, because of daylight saving time.

The fun began on Monday morning when I opened the app to log my meditation session and noticed that the dates and times were wrong. It didn’t take long for me to realize that it was probably tied to going back an hour for DST. I opened up Xcode and quickly confirmed that DST was breaking all my logic before heading in to work.

I spent most of Monday evening familiarizing myself with the two main iOS date classes that I was using (NSDate and NSCalendar) and attempting to fix the bugs in my code. After 9 or so hours, I had made some progress, but I was still a long ways off from having it all sorted out. I decided to pull the app from the app store given the problem, and I toyed with just giving up on the app completely because of how frustrated I was at that point. Who knew that something as simple as a time tracker could be so complicated?

The next day, something inexplicably “clicked,” and I felt motivated to tackle the problem again (in part because I love programming…). I upgraded my laptop to Lion, downloaded the newest version of Xcode, and started to systematically correct all of the issues, testing it on my laptop and phone (where I could easily change the date).

Although it took much longer than expected, I was able to submit a DST-friendly app update to the app store and update the code on GitHub before going to sleep. And I now understand why iOS separates out date functionality into NSDate and NSCalendar.