Example #1
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"
     )
Example #2
0
 def test_rfc3339_date_without_time(self):
     """
     Test rfc3339_date() correctly formats date objects.
     """
     self.assertEqual(
         feedgenerator.rfc3339_date(datetime.date(2008, 11, 14)),
         "2008-11-14T00:00:00Z"
     )
Example #3
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"
     )
Example #4
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('/syndication/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 = rfc3339_date(d.replace(tzinfo=ltz))

        self.assertEqual(updated, latest)