A trivial bug in cl-audioscrobbler
So as I’m learning Common Lisp, as I usually do in a new language, I decide to write an IRC bot. It has been quite an interesting experience. Having had the general framework figured out I started to make it actually do some things, google searches, quotes, etc…
I also recently set up a last.fm account and had nothing better to do on New Year’s Eve, so I thought it would be nifty if I had my bot interact with last.fm in some way, and I found a handy library to do just that, cl-audioscrobbler.
But it always set the time the song played to 6 hours before I actually played it. It was easy to figure out what was going wrong, given I’m in CST, or UTC-6. Last.fm’s API specifies: “UTC date/time in YYYY-MM-DD hh:mm:ss format”. cl-audioscrobbler was sending my *local* time.
So I found the bit of code that figures out what time it is in src/tools.lisp, and naively tried to simply add 6 hours to whatever it produced. Naturally, that didn’t work out so well, and I wound up with something that kinda sorta worked but was hugely complicated and ugly. Then I found the un-braindead way to do it.
Change (get-decoded-time) to (decode-universal-time (get-universal-time) 0)
It’s not much, and chances are cl-audioscrobbler’s author has already found and fixed this (it was obvious looking at the sources that 1.2 support was already well underway), but I sent him a quick note about it anyway.
But it was the first bug in Lisp I’ve ever fixed that wasn’t in my own code, so I’m still pretty happy about it.
Update: As of 2008/01/08 this is fixed with the 0.3.1 release. Thanks to Nicolas Lamirault for accepting my first ever Lisp patch =)
No comments yet.