Ticket #13299: 0001-Python-Bindings-Fix-parsing-of-zoneinfo-files.patch

File 0001-Python-Bindings-Fix-parsing-of-zoneinfo-files.patch, 2.2 KB (added by rcrdnalor, 10 months ago)

Patch for fixing date-time calculation

  • mythtv/bindings/python/MythTV/utility/dt.py

    From 508505f0770e92a05afff1712ba6356f749a4e1b Mon Sep 17 00:00:00 2001
    From: rcrdnalor <rcrernst@gmail.com>
    Date: Sun, 1 Jul 2018 11:43:11 +0200
    Subject: [PATCH] Python Bindings: Fix parsing of zoneinfo files
    
    ---
     mythtv/bindings/python/MythTV/utility/dt.py | 18 ++++++++++++++++--
     1 file changed, 16 insertions(+), 2 deletions(-)
    
    diff --git a/mythtv/bindings/python/MythTV/utility/dt.py b/mythtv/bindings/python/MythTV/utility/dt.py
    index f688ea24c6..9f2bda4700 100644
    a b class posixtzinfo( basetzinfo ): 
    159159            return
    160160
    161161        transitions = []
     162        faulty_transitions = []
    162163        for i in range(counts.transitions): # read in epoch time data
    163164            t = unpack(ttmfmt, fd.read(calcsize(ttmfmt)))[0]
    164             tt = time.gmtime(t)
     165            try:
     166                tt = time.gmtime(t)
     167            except ValueError:
     168                tt = time.gmtime(0)
     169                faulty_transitions.append(i)
    165170            transitions.append([t, tt, None, None, None, None])
    166171
    167172        # read in transition type indexes
    class posixtzinfo( basetzinfo ): 
    179184            typedefs.append([offset, isdst])
    180185        for i in range(counts.transitions):
    181186            offset,isdst = typedefs[types[i]]
    182             transitions[i][2] = time.gmtime(transitions[i][0] + offset)
     187            try:
     188                transitions[i][2] = time.gmtime(transitions[i][0] + offset)
     189            except ValueError:
     190                transitions[i][2] = time.gmtime(0)
     191                if i not in faulty_transitions:
     192                    faulty_transitions.append(i)
    183193            transitions[i][3] = offset
    184194            transitions[i][5] = isdst
    185195
    class posixtzinfo( basetzinfo ): 
    198208
    199209        for i in range(counts.transitions):
    200210            transitions[i] = self._Transition(*transitions[i])
     211        # delete the faulty items, caused by LMT - Local Mean Time - entries:
     212        for index, t in reversed(list(enumerate(transitions))):
     213            if index in faulty_transitions:
     214                del transitions[index]
    201215        self._transitions = tuple(transitions)
    202216
    203217