def test_localize(self): dt = datetime.today() utc = timezone("UTC") dt = delorean.localize(dt, "UTC") self.assertEqual(dt.tzinfo, utc)
def test_localize_failure(self): dt1 = delorean.localize(datetime.utcnow(), "UTC") self.assertRaises(ValueError, delorean.localize, dt1, "UTC")
def test_localize(self): dt = datetime.today() dt = delorean.localize(dt, "UTC") self.assertEqual(dt.tzinfo, pytz.utc)
def now(cls): now = delorean.localize(dt.datetime.now(), 'UTC') diff = now - dt.datetime(1970, 1, 1, 0, 0, 0, 0, pytz.utc) millis = (diff.days * 24 * 60 * 60 + diff.seconds) * 1000 + diff.microseconds / 1000 return cls.of_epoch_milli(millis)