diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index af167697c2..0fd5dfef34 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -27,8 +27,11 @@ import datetime import urlparse from django.utils.xmlutils import SimplerXMLGenerator from django.utils.encoding import force_unicode, iri_to_uri +from django.utils import datetime_safe def rfc2822_date(date): + # Support datetime objects older than 1900 + date = datetime_safe.new_datetime(date) # We do this ourselves to be timezone aware, email.Utils is not tz aware. if date.tzinfo: time_str = date.strftime('%a, %d %b %Y %H:%M:%S ') @@ -40,6 +43,8 @@ def rfc2822_date(date): return date.strftime('%a, %d %b %Y %H:%M:%S -0000') def rfc3339_date(date): + # Support datetime objects older than 1900 + date = datetime_safe.new_datetime(date) if date.tzinfo: time_str = date.strftime('%Y-%m-%dT%H:%M:%S') offset = date.tzinfo.utcoffset(date) @@ -64,7 +69,7 @@ def get_tag_uri(url, date): d = '' if date is not None: - d = ',%s' % date.strftime('%Y-%m-%d') + d = ',%s' % datetime_safe.new_datetime(date).strftime('%Y-%m-%d') return u'tag:%s%s:%s/%s' % (hostname, d, path, fragment) class SyndicationFeed(object): diff --git a/tests/regressiontests/syndication/fixtures/feeddata.json b/tests/regressiontests/syndication/fixtures/feeddata.json index 4a5c02297a..167115c925 100644 --- a/tests/regressiontests/syndication/fixtures/feeddata.json +++ b/tests/regressiontests/syndication/fixtures/feeddata.json @@ -4,7 +4,7 @@ "pk": 1, "fields": { "title": "My first entry", - "date": "2008-01-01 12:30:00" + "date": "1850-01-01 12:30:00" } }, {