diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2011-11-18 13:01:06 +0000 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2011-11-18 13:01:06 +0000 |
| commit | 9b1cb755a28f020e27d4268c214b25315d4de42e (patch) | |
| tree | 2ff0827176f0eb49defa4ce7ce10164f2fc26e86 /django/utils/feedgenerator.py | |
| parent | 01f70349c9ef23d6751437dcd57d2efc193b2661 (diff) | |
Added support for time zones. Thanks Luke Plant for the review. Fixed #2626.
For more information on this project, see this thread:
http://groups.google.com/group/django-developers/browse_thread/thread/cf0423bbb85b1bbf
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17106 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/feedgenerator.py')
| -rw-r--r-- | django/utils/feedgenerator.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index 7d7c7af65c..df3cf41652 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -28,6 +28,7 @@ import urlparse from django.utils.xmlutils import SimplerXMLGenerator from django.utils.encoding import force_unicode, iri_to_uri from django.utils import datetime_safe +from django.utils.timezone import is_aware def rfc2822_date(date): # We can't use strftime() because it produces locale-dependant results, so @@ -40,7 +41,7 @@ def rfc2822_date(date): dow = days[date.weekday()] month = months[date.month - 1] time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month)) - if date.tzinfo: + if is_aware(date): offset = date.tzinfo.utcoffset(date) timezone = (offset.days * 24 * 60) + (offset.seconds // 60) hour, minute = divmod(timezone, 60) @@ -51,7 +52,7 @@ def rfc2822_date(date): def rfc3339_date(date): # Support datetime objects older than 1900 date = datetime_safe.new_datetime(date) - if date.tzinfo: + if is_aware(date): time_str = date.strftime('%Y-%m-%dT%H:%M:%S') offset = date.tzinfo.utcoffset(date) timezone = (offset.days * 24 * 60) + (offset.seconds // 60) |
