# HG changeset patch # User Paul Boddie # Date 1332714416 -7200 # Node ID 6c939b5c8f19f64bd38cc715fdc5e7e7227e2582 # Parent 6770b3703e614ff369a0eff688b91eff3bf98998 Fixed the Olson zone offset calculation to produce correct offsets for zones west of the prime meridian in a form consistent with those generated using explicit offsets (where the sign of the hours and minutes is always the same). diff -r 6770b3703e61 -r 6c939b5c8f19 EventAggregatorSupport.py --- a/EventAggregatorSupport.py Sun Mar 25 21:35:07 2012 +0200 +++ b/EventAggregatorSupport.py Mon Mar 26 00:26:56 2012 +0200 @@ -76,7 +76,7 @@ month_regexp_str = ur'(?P[0-9]{4})-(?P[0-9]{2})' date_regexp_str = ur'(?P[0-9]{4})-(?P[0-9]{2})-(?P[0-9]{2})' time_regexp_str = ur'(?P[0-2][0-9]):(?P[0-5][0-9])(?::(?P[0-6][0-9]))?' -timezone_offset_str = ur'(?P(UTC)?(?:(?P[-+])(?P[0-9]{2})(?::?(?P[0-9]{2}))?))' +timezone_offset_str = ur'(?P(UTC)?(?:(?P[-+])?(?P[0-9]{2})(?::?(?P[0-9]{2}))?))' timezone_olson_str = ur'(?P[a-zA-Z]+(?:/[-_a-zA-Z]+){1,2})' timezone_utc_str = ur'UTC' timezone_regexp_str = ur'(?P' + timezone_offset_str + '|' + timezone_olson_str + '|' + timezone_utc_str + ')' @@ -2057,12 +2057,12 @@ match = timezone_offset_regexp.match(zone) if match: if match.group("sign") == "-": - sign = -1 + offset_sign = -1 else: - sign = 1 - - hours = int(match.group("hours")) * sign - minutes = int(match.group("minutes") or 0) * sign + offset_sign = 1 + + hours = int(match.group("hours")) * offset_sign + minutes = int(match.group("minutes") or 0) * offset_sign return hours, minutes # Attempt to handle Olson time zone identifiers. @@ -2070,9 +2070,9 @@ dt = self.as_olson_datetime() if dt: seconds = dt.utcoffset().seconds + dt.utcoffset().days * 24 * 3600 - hours = seconds / 3600 - minutes = (seconds % 3600) / 60 - return hours, minutes + hours = abs(seconds) / 3600 + minutes = (abs(seconds) % 3600) / 60 + return sign(seconds) * hours, sign(seconds) * minutes # Otherwise return None.