metomi/isodatetime

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

MetRonnie opened this issue · 0 comments

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

  • zero hours but non-zero minutes (e.g. -00:30)
  • minutes that aren't 0 or 30 (e.g. -02:15)

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'