Fun with time
I had a curious bug rear its ugly head recently. I sort some interface elements by frequency, biasing for recent activity (“top people”). Mysteriously, the most popular one kept disappearing, then reappearing later. A time-based bug, eh?I eventually tracked it down: a score was coming out negative. The reason was simply that the system thought the event occurred in the future, so a difference came out negative, and so did the score. Check this out:
* (get-universal-time)… the times don't round-trip. You'll notice that iso8601-date-string confidently asserts “-08:00”, when California is in DST (and thus GMT-7, PDT). Let's try that:
3353118020
* (iso8601-date-string *)
"2006-04-03T22:40:20-08:00"
* (parse-iso8601-date *)
3353121620
* (parse-iso8601-date "2006-04-03T22:40:20-07:00")Now, let's see how I can work that into the damn code….
3353118020
Posted at 2006-04-03 22:48:33 by Richard • Link to Fun with time
