mirror of https://github.com/django/django.git
Simplified django.utils.feedgenerator.rfc3339_date().
This commit is contained in:
parent
cd41f7d6b8
commit
c794b56811
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue