Exemple #1
0
 def test_to_datetime_without_tz_info(self):
     date = Date(timezone=TZ_UTC)
     date.from_string(datestring="2015-12-28T05:00:00+02:00",
                      fmt=FMT_ISO8601)
     result_datetime = date.to_datetime_without_tz_info()
     expected_datetime = datetime(2015, 12, 28, 3, 0, 0)
     self.assertEquals(expected_datetime, result_datetime)
Exemple #2
0
 def test_from_string_when_format_is_iso8601_not_overrites_datestring_timezone(self):
     date = Date(timezone=TZ_UTC)
     date.from_string(datestring="2015-12-28T01:02:03+02:00",
                      fmt=FMT_ISO8601)
     utc_datetime = datetime(2015, 12, 28, 1, 2, 3, 0, timezone(TZ_UTC))
     self.assertNotEquals(utc_datetime, date.to_datetime())
     self.assertEquals(timedelta(hours=2),
                       utc_datetime - date.to_datetime())
Exemple #3
0
 def test_to_datetime(self):
     date = Date(timezone=TZ_UTC)
     date.from_timestamp(timestamp="1451260800")
     expected_datetime = datetime(2015, 12, 28, 0, 0, 0, 0,
                                  timezone(TZ_UTC))
     self.assertEquals(date.to_datetime(), expected_datetime)
Exemple #4
0
 def test_to_string_from_not_utc_timezone(self):
     date = Date(timezone=TZ_UTC)
     date.from_string(datestring="2015-12-28T05:00:00+02:00",
                      fmt=FMT_ISO8601)
     self.assertEquals("2015-12-28 03:00:00", date.to_string())
Exemple #5
0
 def test_to_string(self):
     date = Date(timezone=TZ_UTC)
     date.from_timestamp(timestamp="1451260800")
     self.assertEquals("2015-12-28T00:00:00Z", date.to_string(FMT_ISO8601))
Exemple #6
0
 def test_from_string_when_format_is_iso8601(self):
     date = Date(timezone=TZ_UTC)
     date.from_string(datestring="2015-12-28T01:02:03Z", fmt=FMT_ISO8601)
     expected_datetime = datetime(2015, 12, 28, 1, 2, 3, 0,
                                  timezone(TZ_UTC))
     self.assertEquals(expected_datetime, date.to_datetime())