Simplified django.utils.feedgenerator.rfc3339_date().
@@ -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):
