summaryrefslogtreecommitdiff
path: root/django/utils/feedgenerator.py
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-02-12 19:11:57 +0000
committerJannis Leidel <jannis@leidel.info>2011-02-12 19:11:57 +0000
commitbc5c2537ae3d09d3b9145beb027ff9f60eac6ba3 (patch)
treefaa8b8c770ec5d313d6b2d6707c584c0ecaf0671 /django/utils/feedgenerator.py
parent47b1a8e704b375f0b4f79db8432e4373d33e746d (diff)
Fixed #14132 -- Fixed feedgenerator to support years < 1900. Thanks, mk.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15503 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/feedgenerator.py')
-rw-r--r--django/utils/feedgenerator.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index 5ec20f6664..15476f8b0f 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -27,13 +27,15 @@ 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):
# We can't use strftime() because it produces locale-dependant results, so
# we have to map english month and day names manually
months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',)
days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
-
+ # 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.
dow = days[date.weekday()]
month = months[date.month - 1]
@@ -47,6 +49,8 @@ def rfc2822_date(date):
return time_str + '-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)
@@ -71,7 +75,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):