コード例 #1
0
    def test_timezone_with_no_transitions(self):
        tz = Timezone('Test', (), ((0, False, None, ''),), 0, [])

        dt = datetime(2016, 11, 26)
        dt = tz.convert(dt)

        self.assertEqual(dt.year, 2016)
        self.assertEqual(dt.month, 11)
        self.assertEqual(dt.day, 26)
        self.assertEqual(dt.hour, 0)
        self.assertEqual(dt.minute, 0)
        self.assertEqual(dt.second, 0)
コード例 #2
0
    def test_tzname(self):
        tz = Timezone.load('Europe/Paris')
        dt1 = tz.convert(datetime(2016, 7, 1))
        dt2 = tz.convert(datetime(2016, 3, 1))
        tzinfo = TimezoneInfo(tz, 7200, True, timedelta(0, 3600), 'CEST')

        self.assertEqual('CEST', tzinfo.tzname(dt1))
        self.assertEqual('CET', tzinfo.tzname(dt2))
        self.assertEqual('CEST', tzinfo.tzname(None))
コード例 #3
0
    def test_construct(self):
        tz = Timezone.load('Europe/Paris')
        tzinfo = TimezoneInfo(tz, 7200, True, timedelta(0, 3600), 'CEST')

        self.assertEqual(7200, tzinfo.offset)
        self.assertEqual(timedelta(0, 7200), tzinfo.adjusted_offset)
        self.assertEqual(True, tzinfo.is_dst)
        self.assertEqual(timedelta(0, 3600), tzinfo.dst_)
        self.assertEqual(tz, tzinfo.tz)
        self.assertEqual('Europe/Paris', tzinfo.name)
        self.assertEqual('CEST', tzinfo.abbrev)
        self.assertEqual('CEST', tzinfo.tzname(None))
コード例 #4
0
    def test_repr(self):
        tz = Timezone.load('Europe/Paris')
        tzinfo = TimezoneInfo(tz, 7200, True, timedelta(0, 3600), 'CEST')

        self.assertEqual('<TimezoneInfo [Europe/Paris, CEST, +02:00:00, DST]>',
                         repr(tzinfo))