Python dateutil.zoneinfo.get_zonefile_instance() Examples

The following are 9 code examples of dateutil.zoneinfo.get_zonefile_instance(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module dateutil.zoneinfo , or try the search function .
Example #1
Source File: test_tz.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
def __get_kiritimati_resolve_imaginary_test():
    # In the 2018d release of the IANA database, the Kiritimati "imaginary day"
    # data was corrected, so if the system zoneinfo is older than 2018d, the
    # Kiritimati test will fail.

    tzi = tz.gettz('Pacific/Kiritimati')
    new_version = False
    if not tz.datetime_exists(datetime(1995, 1, 1, 12, 30), tzi):
        zif = zoneinfo.get_zonefile_instance()
        if zif.metadata is not None:
            new_version = zif.metadata['tzversion'] >= '2018d'

        if new_version:
            tzi = zif.get('Pacific/Kiritimati')
    else:
        new_version = True

    if new_version:
        dates = (datetime(1994, 12, 31, 12, 30), datetime(1995, 1, 1, 12, 30))
    else:
        dates = (datetime(1995, 1, 1, 12, 30), datetime(1995, 1, 2, 12, 30))

    return (tzi, ) + dates 
Example #2
Source File: test_tz.py    From plugin.video.emby with GNU General Public License v3.0 5 votes vote down vote up
def gettz(self, name):
        zoneinfo_file = zoneinfo.get_zonefile_instance()
        return zoneinfo_file.get(name) 
Example #3
Source File: test_tz.py    From plugin.video.emby with GNU General Public License v3.0 5 votes vote down vote up
def testZoneInfoInstanceCaching(self):
        zif_0 = zoneinfo.get_zonefile_instance()
        zif_1 = zoneinfo.get_zonefile_instance()

        self.assertIs(zif_0, zif_1) 
Example #4
Source File: test_tz.py    From plugin.video.emby with GNU General Public License v3.0 5 votes vote down vote up
def testZoneInfoNewInstance(self):
        zif_0 = zoneinfo.get_zonefile_instance()
        zif_1 = zoneinfo.get_zonefile_instance(new_instance=True)
        zif_2 = zoneinfo.get_zonefile_instance()

        self.assertIsNot(zif_0, zif_1)
        self.assertIs(zif_1, zif_2) 
Example #5
Source File: test_tz.py    From plugin.video.emby with GNU General Public License v3.0 5 votes vote down vote up
def testPickleZoneFileGettz(self):
        zoneinfo_file = zoneinfo.get_zonefile_instance()
        tzi = zoneinfo_file.get('America/New_York')
        self.assertIsNot(tzi, None)
        self.assertPicklable(tzi) 
Example #6
Source File: test_tz.py    From bazarr with GNU General Public License v3.0 5 votes vote down vote up
def gettz(self, name):
        zoneinfo_file = zoneinfo.get_zonefile_instance()
        return zoneinfo_file.get(name) 
Example #7
Source File: test_tz.py    From bazarr with GNU General Public License v3.0 5 votes vote down vote up
def testZoneInfoInstanceCaching(self):
        zif_0 = zoneinfo.get_zonefile_instance()
        zif_1 = zoneinfo.get_zonefile_instance()

        self.assertIs(zif_0, zif_1) 
Example #8
Source File: test_tz.py    From bazarr with GNU General Public License v3.0 5 votes vote down vote up
def testZoneInfoNewInstance(self):
        zif_0 = zoneinfo.get_zonefile_instance()
        zif_1 = zoneinfo.get_zonefile_instance(new_instance=True)
        zif_2 = zoneinfo.get_zonefile_instance()

        self.assertIsNot(zif_0, zif_1)
        self.assertIs(zif_1, zif_2) 
Example #9
Source File: test_tz.py    From bazarr with GNU General Public License v3.0 5 votes vote down vote up
def testPickleZoneFileGettz(self):
        zoneinfo_file = zoneinfo.get_zonefile_instance()
        tzi = zoneinfo_file.get('America/New_York')
        self.assertIsNot(tzi, None)
        self.assertPicklable(tzi)