Mon 03 Apr 2006

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) 

3353118020
* (iso8601-date-string *)

"2006-04-03T22:40:20-08:00"
* (parse-iso8601-date *)
3353121620
… 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:
* (parse-iso8601-date "2006-04-03T22:40:20-07:00")

3353118020
Now, let's see how I can work that into the damn code….

Posted at 2006-04-03 22:48:33 by RichardLink to Fun with time
Comments, trackbacks.

Google
Web holygoat.co.uk
  • richard is: