Beispiel #1
0
 def test_rfc3339_date(self):
     """
     Test rfc3339_date() correctly formats datetime objects.
     """
     self.assertEqual(
         feedgenerator.rfc3339_date(datetime.datetime(2008, 11, 14, 13, 37, 0)),
         "2008-11-14T13:37:00Z"
     )
Beispiel #2
0
 def test_rfc3339_date_with_timezone(self):
     """
     Test rfc3339_date() correctly formats datetime objects with tzinfo.
     """
     self.assertEqual(
         feedgenerator.rfc3339_date(datetime.datetime(2008, 11, 14, 13, 37, 0, tzinfo=tzinfo.FixedOffset(datetime.timedelta(minutes=120)))),
         "2008-11-14T13:37:00+02:00"
     )
Beispiel #3
0
 def test_naive_datetime_conversion(self):
     """
     Test that datetimes are correctly converted to the local time zone.
     """
     # Naive date times passed in get converted to the local time zone, so
     # check the recived zone offset against the local offset.
     response = self.client.get('/naive-dates/')
     doc = minidom.parseString(response.content)
     updated = doc.getElementsByTagName('updated')[0].firstChild.wholeText        
     d = Entry.objects.latest('date').date
     ltz = tzinfo.LocalTimezone(d)
     latest = feedgenerator.rfc3339_date(d.replace(tzinfo=ltz))
     
     self.assertEqual(updated, latest)