The importance of working late

Now while I’m not particularly happy about my normal coding hours – say, 10pm till 4am – in this particular case they just did me wonders. I have some code, you see, which converts between NSCalendarDate and CSSM_DATEs – don’t worry if this is going over your head, it’s part of the boring, disgusting internal details of the CDSA. There’s at least five time formats I have to deal with. Hooray. I have to deal with it as part of the Keychain framework, one of my major projects – and probably the one I’ve worked on longest; at least three years now.

Anyway, what I apparently didn’t think of when I first wrote this code was that CSSM_DATEs have no explicit time zone information, ergo they assume GMT. NSCalendarDate of course defaults to the local timezone. So I was actually corrupting the date when converting it. And I never would have known had I not been testing some code that depends on this just as the clock struck midnight. All of a sudden, everything broke. One of those typical horrible moments – “but I swear I hardly touched it!” :).

Luckily I figured it out pretty quickly. A bit of testing (trying my tests again at 9:58am and 10:02am) proved my hypothesis. And now it’s fixed, and working all swell again, back in real time (12:40am).

It’s quite disturbing how many bugs I’m killing tonight in this framework. It’s a wonder it’s ever worked at all. :/

Leave a Comment