1. Michael Twomey
  2. pyiso8601
Issue #8 resolved

0.1.5 parses negative timezones incorrectly

Jonathan Lange
created an issue

Hello,

There's a difference in behaviour between 0.1.4 and 0.1.5 when parsing negative timezones.

import iso8601

string = "1985-04-12T23:20:50.52-05:30"
parsed = iso8601.parse_date(string)
print "%r ==> %s (%r)" % (string, parsed, parsed.tzinfo)

What I see:

  '1985-04-12T23:20:50.52-05:30' ==> 1985-04-12 23:20:50.520000-04:30 (<FixedOffset '-05:30' datetime.timedelta(-1, 70200)>)

What I expect to see:

  '1985-04-12T23:20:50.52-05:30' ==> 1985-04-12 23:20:50.520000-05:30 (<FixedOffset '-05:30' datetime.timedelta(-1, 66600)>)

What I see in 0.1.4:

  '1985-04-12T23:20:50.52-05:30' ==> 1985-04-12 23:20:50.520000-05:30 (<FixedOffset '-05:30'>)

Note that the timezone in 0.1.5 returns a -04:30 rather than -05:30. This behaviour does not occur with positive offsets.

Comments (6)

  1. Michael Twomey repo owner

    Thanks for the bug report + patch, I actually just fixed it in a similar manner myself a second ago.

    The problem was I removed the negative minutes line by mistake (braino) and had incorrect tests which just matched the incorrect behaviour (which you've also fixed).

    I'll release 0.1.6 now.

  2. Michael Twomey repo owner

    Handle negative timezone offsets correctly

    I had dropped the negative minutes in a braino and had incorrectly updated tests to match.

    I've added a isoformat field to the tests, so I can correctly assert they formatted date looks right.

    Thanks to Jonathan Lange for reporting this and a patch.

    Fixes #8

    → <<cset 462f8303fc39>>

  3. Log in to comment