Hi all, I found a issue with the DateTime module. For what I could see the functions _tzoffset2rfc822zone and _tzoffset2iso8601zone, that are used to return a zone specification, have problems with negative offset. This not happens with all the negative offset, just when the hour is not rounded and have minutes. Functions '_tzoffset2rfc822zone' and '_tzoffset2iso8601zonethat' are used in the mtehods 'DateTime.ISO8601' and 'DateTime.rfc822'. I think it may be clearer with some examples:
dt = DateTime('2004/06/14 14:30:15 GMT+0430') dt.rfc822() 'Mon, 14 Jun 2004 14:30:15 +0430' dt.ISO8601() '2004-06-14T14:30:15+04:30'
This is Ok.
dt = DateTime('2004/06/14 14:30:15 GMT-0400') dt.rfc822() 'Mon, 14 Jun 2004 14:30:15 -0400' dt.ISO8601() '2004-06-14T14:30:15-04:00'
This is Ok.
dt = DateTime('2004/06/14 14:30:15 GMT-0430') dt.rfc822() 'Mon, 14 Jun 2004 14:30:15 -0530' dt.ISO8601() '2004-06-14T14:30:15-05:30'
This is not. As you could see, the offset printed is -0530. This is the code for both functions def _tzoffset2rfc822zone(seconds): """Takes an offset, such as from _tzoffset(), and returns an rfc822 compliant zone specification. Please note that the result of _tzoffset() is the negative of what time.localzone and time.altzone is. """ return "%+03d%02d" % divmod((seconds / 60), 60) def _tzoffset2iso8601zone(seconds): """Takes an offset, such as from _tzoffset(), and returns an ISO 8601 compliant zone specification. Please note that the result of _tzoffset() is the negative of what time.localzone and time.altzone is. """ return "%+03d:%02d" % divmod((seconds / 60), 60) I think that the error come from the way in where the integer division works.
secconds = (4 * 60 + 30) * 60 secconds 16200 divmod((secconds/60), 60) (4, 30) divmod((-secconds/60), 60) (-5, 30)
secconds / 60 270 270 / 60 4 - 270 / 60 -5
I hope be clear and not to much verbose, but this is my first mail to the list. Cheers and sorry for my English :) nueces....