On Fri, 2009-02-20 at 19:45 -0500, Karen Tracey wrote: [...] > Near as I can tell, also, the "U" date-formatting implementation > doesn't work. It is: > > def U(self): > "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)" > off = self.timezone.utcoffset(self.data) > return int(time.mktime(self.data.timetuple())) + off.seconds * > 60
Wow, that code's really old (like 2005 old). Possibly marked as unimplemented because Adrian knew it was broken and wanted to fix it, or something. [...] > So this is what off winds up being: > > >>> off = df.timezone.utcoffset(x) > >>> off > datetime.timedelta(-1, 68400) > >>> off.days > -1 > >>> off.seconds > 68400 > > This is negative one day, plus 68,4000 seconds, equivalent to -18,000 > seconds, but the subsequent code: > > return int(time.mktime(self.data.timetuple())) + off.seconds * 60 > > doesn't consider the negative days value and just uses the 68,4000 > seconds value, so that's a problem. That's a lovely trap in the timedelta API that regularly catches people out (including me, regularly enough, when I forget it happens). When we were implementing timezone support for syndicated feeds at the Washington DC sprint last year, I seem to recall it took a large portion of the time spent on that issue just to get things working for timezones west of UTC due to that "feature". If somebody wants to fix this robustly, I'd strongly suggest swiping the offset computation code from django.utils.feedgenerator. Both the rfc822_date() and rfc3339_date() functions do the computation correctly. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---