Skip to content

Commit

Permalink
Python: Fix 'datetime' calculation for local time
Browse files Browse the repository at this point in the history
when the country stopped to adapt the time-zone to daylight-saving
time.

This happened in the past for Honolulu, and will happen in March 2023
for America/Nuuk.

Fixes #708
  • Loading branch information
rcrdnalor committed Feb 11, 2023
1 parent fe865f1 commit 24b552f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mythtv/bindings/python/MythTV/utility/dt.py
Expand Up @@ -44,6 +44,7 @@ def _get_transition_search(self, dt=None):

index = self.__last
direction = 0
oob_range = False
while True:
if dt < self._ranges[index][0]:
if direction == 1:
Expand All @@ -66,13 +67,17 @@ def _get_transition_search(self, dt=None):
if index >= len(self._ranges):
# out of bounds future, use final transition
index = len(self._ranges) - 1
oob_range = True
break
elif index < 0:
# out of bounds past, undefined time frame
raise MythTZError(MythTZError.TZ_CONVERSION_ERROR,
self.tzname(), dt)

self.__last = index
if oob_range:
# out of bounds future, use final transition
return self._transitions[self._ranges[index][2] + 1]
return self._transitions[self._ranges[index][2]]

def _get_transition_empty(self, dt=None):
Expand Down

0 comments on commit 24b552f

Please sign in to comment.