Esempio n. 1
0
 def test_datetimes(self):
     commit = self.rorepo.commit('4251bd5')
     assert commit.authored_date == 1255018625
     assert commit.committed_date == 1255026171
     assert commit.authored_datetime == datetime(2009, 10, 8, 18, 17, 5, tzinfo=tzoffset(-7200)), commit.authored_datetime  # noqa
     assert commit.authored_datetime == datetime(2009, 10, 8, 16, 17, 5, tzinfo=utc), commit.authored_datetime
     assert commit.committed_datetime == datetime(2009, 10, 8, 20, 22, 51, tzinfo=tzoffset(-7200))
     assert commit.committed_datetime == datetime(2009, 10, 8, 18, 22, 51, tzinfo=utc), commit.committed_datetime
Esempio n. 2
0
    def test_from_timestamp(self):
        # Correct offset: UTC+2, should return datetime + tzoffset(+2)
        altz = utctz_to_altz('+0200')
        self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(altz)), from_timestamp(1522827734, altz))

        # Wrong offset: UTC+58, should return datetime + tzoffset(UTC)
        altz = utctz_to_altz('+5800')
        self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(0)), from_timestamp(1522827734, altz))

        # Wrong offset: UTC-9000, should return datetime + tzoffset(UTC)
        altz = utctz_to_altz('-9000')
        self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(0)), from_timestamp(1522827734, altz))
    def test_from_timestamp(self):
        # Correct offset: UTC+2, should return datetime + tzoffset(+2)
        altz = utctz_to_altz('+0200')
        self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(altz)), from_timestamp(1522827734, altz))

        # Wrong offset: UTC+58, should return datetime + tzoffset(UTC)
        altz = utctz_to_altz('+5800')
        self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(0)), from_timestamp(1522827734, altz))

        # Wrong offset: UTC-9000, should return datetime + tzoffset(UTC)
        altz = utctz_to_altz('-9000')
        self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(0)), from_timestamp(1522827734, altz))
Esempio n. 4
0
 def test_datetimes(self):
     commit = self.rorepo.commit('4251bd5')
     self.assertEqual(commit.authored_date, 1255018625)
     self.assertEqual(commit.committed_date, 1255026171)
     self.assertEqual(commit.authored_datetime,
                      datetime(2009, 10, 8, 18, 17, 5, tzinfo=tzoffset(-7200)), commit.authored_datetime)  # noqa
     self.assertEqual(commit.authored_datetime,
                      datetime(2009, 10, 8, 16, 17, 5, tzinfo=utc), commit.authored_datetime)
     self.assertEqual(commit.committed_datetime,
                      datetime(2009, 10, 8, 20, 22, 51, tzinfo=tzoffset(-7200)))
     self.assertEqual(commit.committed_datetime,
                      datetime(2009, 10, 8, 18, 22, 51, tzinfo=utc), commit.committed_datetime)
 def test_datetimes(self):
     commit = self.rorepo.commit('4251bd5')
     self.assertEqual(commit.authored_date, 1255018625)
     self.assertEqual(commit.committed_date, 1255026171)
     self.assertEqual(commit.authored_datetime,
                      datetime(2009, 10, 8, 18, 17, 5, tzinfo=tzoffset(-7200)), commit.authored_datetime)  # noqa
     self.assertEqual(commit.authored_datetime,
                      datetime(2009, 10, 8, 16, 17, 5, tzinfo=utc), commit.authored_datetime)
     self.assertEqual(commit.committed_datetime,
                      datetime(2009, 10, 8, 20, 22, 51, tzinfo=tzoffset(-7200)))
     self.assertEqual(commit.committed_datetime,
                      datetime(2009, 10, 8, 18, 22, 51, tzinfo=utc), commit.committed_datetime)
Esempio n. 6
0
 def test_pickle_tzoffset(self):
     t1 = tzoffset(555)
     t2 = pickle.loads(pickle.dumps(t1))
     self.assertEqual(t1._offset, t2._offset)
     self.assertEqual(t1._name, t2._name)