Awesome Adium Time Zone plugin: good (or, well, awesome).
PBGContactTimeZonePlugin.m, line 95 (time = [[NSAttributedString alloc] initWithString:[localTime descriptionWithCalendarFormat:@"%1I:%M %p, %A"]];): bad.
time = [[NSAttributedString alloc] initWithString:[localTime descriptionWithCalendarFormat:@"%X" locale:nil]]; returns the time following the current locale and matching any format changes you may have done in the System Preferences. For a plugin with no configurability, my recommendation is to use the default locale representation.
Update: Clarification: On 10.0 through 10.3 (Panther), use NSCalendarDate methods like above. (localTime is an NSCalendarDate instance.) On 10.4 and forward, use NSDateFormatter. For NSCalendarDate, you can use %c for a date and time composite, and %x (lowercase x) for the date component, in addition to the %X for the time component.
Out of courtesy, I will refrain from pointing out that the Edit Time Zone menu item is not run through AILocalizedString.
(Yes, I am aware of the abysmal state of localization in some of my products, notably Monocle. I am working hard on getting it right - including things like correctly detecting and storing string encodings for discovering search engines - which is why I couldn’t make it into 1.0 due to the self-imposed deadline. I intend to write an entry where I beat myself up over Monocle’s code too. Do not worry. )
Cool, I’m going to change that for the actual release. Also, please don’t refrain from pointing out my other errors. I’m still a cocoa newbie and need to learn this stuff sooner rather than later. :)
Thanks!
By Patrick G · 2007.02.25 06:43
That’s fair, I suppose. I feel bad ragging on other people’s code when I know my own is worse in a lot of places even though I know better. Telling myself it’s worse because that code was written that way in the interest of time doesn’t help a lot. :)
By Jesper · 2007.02.26 01:25