diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index 7fc63f5adbf..61d43b81368 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -53,17 +53,9 @@ def rfc2822_date(date): def rfc3339_date(date): - # Support datetime objects older than 1900 - date = datetime_safe.new_datetime(date) - time_str = date.strftime('%Y-%m-%dT%H:%M:%S') - offset = date.utcoffset() - # Historically, this function assumes that naive datetimes are in UTC. - if offset is None: - return time_str + 'Z' - else: - timezone = (offset.days * 24 * 60) + (offset.seconds // 60) - hour, minute = divmod(timezone, 60) - return time_str + '%+03d:%02d' % (hour, minute) + if not isinstance(date, datetime.datetime): + date = datetime.datetime.combine(date, datetime.time()) + return date.isoformat() + ('Z' if date.utcoffset() is None else '') def get_tag_uri(url, date):