summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorKetan Bhatt <ketanbhatt1006@gmail.com>2016-05-24 22:20:20 +0530
committerTim Graham <timograham@gmail.com>2016-05-30 18:36:15 -0400
commitf31fbbae1ab1572e1637fc5ca9ae4bae66679294 (patch)
tree7cdf28b1a88c40d57fc59ccf7f517184e41e7a7a /django
parent92107522ed3568740ec7c3597db50b5c3a6e84d3 (diff)
Fixed #26653 -- Made SyndicationFeed.latest_post_date() return time in UTC.
Diffstat (limited to 'django')
-rw-r--r--django/utils/feedgenerator.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index 3a91af3815..aeb054f4e9 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -31,6 +31,7 @@ from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, iri_to_uri
from django.utils.six import StringIO
from django.utils.six.moves.urllib.parse import urlparse
+from django.utils.timezone import utc
from django.utils.xmlutils import SimplerXMLGenerator
@@ -211,7 +212,7 @@ class SyndicationFeed(object):
def latest_post_date(self):
"""
Returns the latest item's pubdate or updateddate. If no items
- have either of these attributes this returns the current date/time.
+ have either of these attributes this returns the current UTC date/time.
"""
latest_date = None
date_keys = ('updateddate', 'pubdate')
@@ -223,7 +224,8 @@ class SyndicationFeed(object):
if latest_date is None or item_date > latest_date:
latest_date = item_date
- return latest_date or datetime.datetime.now()
+ # datetime.now(tz=utc) is slower, as documented in django.utils.timezone.now
+ return latest_date or datetime.datetime.utcnow().replace(tzinfo=utc)
class Enclosure(object):