def test_timestamp_todate(self): timestamp = 1000401040.0 local_time = utils.timestamp_todate(timestamp) utc_time = local_time.astimezone(self.utc) self.assertEquals(utc_time, local_time, "Different times") date_to_timestamp = utils.date_totimestamp(utc_time) self.assertLessEqual( timestamp - date_to_timestamp, self.error, "Error in conversion from date to timestamp")
def test_date_totimestamp(self): local_date = parser.parse( "12/31/2011 23:50").replace(tzinfo=self.local_tz) utc_date = local_date.astimezone(tz=self.utc) self.assertEquals(local_date, utc_date, "Different dates") timestamp = utils.date_totimestamp(utc_date) local_from_timestamp = utils.timestamp_todate(timestamp) self.assertLessEqual( local_date - local_from_timestamp, self.date_error, "Error in conversion from timestamp to date")