metomi / isodatetime

:date: :watch: Python ISO 8601 date time parser and data model/manipulation utilities
GNU Lesser General Public License v3.0
37 stars 20 forks source link

get_local_time_zone() broken for time zones with minutes west of UT #192

Closed MetRonnie closed 2 years ago

MetRonnie commented 3 years ago

The timezone functions are not working properly for non-standard timezones behind UTC that have either:

Steps to reproduce

(Note: the TZ env var +/- convention is backwards, so that Eastern Standard Time is written TZ=EST+05:00 instead of UTC-05:00)

$ TZ=XXX+02:15 python
>>> from metomi.isodatetime import timezone
>>> timezone.get_local_time_zone()
(-2, 45)  # should be (-2, 15) or (-2, -15)
>>> timezone.get_local_time_zone_format()
'-0245'  # should be '-0215'
$ TZ=XXX+00:30 python
>>> from metomi.isodatetime import timezone
>>> timezone.get_local_time_zone()
(0, 30)  # should be (0, -30)
>>> timezone.get_local_time_zone_format()
'+0030'  # should be '-0030'

Additional context

If the timezone is east of UTC, it works ok

$ TZ=XXX-02:15 python
>>> from metomi.isodatetime import timezone
>>> timezone.get_local_time_zone()
(2, 15)
>>> timezone.get_local_time_zone_format()
'+0215'