replace dateutil by isodate (#10196)

isodate has better support for the full ISO8601 specification.
This commit is contained in:
Benjamin Dauvergne 2016-04-11 17:44:16 +02:00
parent aa66457d12
commit 74b61de641
2 changed files with 8 additions and 5 deletions

View File

@ -2,7 +2,7 @@ import logging
import datetime
import importlib
from functools import wraps
import dateutil.parser
import isodate
from django.core.urlresolvers import reverse
from django.template.loader import render_to_string
@ -115,12 +115,15 @@ def flatten_datetime(d):
return d
def iso8601_to_datetime(date_string):
'''Convert a string formatted as an ISO8601 date into a time_t
def iso8601_to_datetime(date_string, default=None):
'''Convert a string formatted as an ISO8601 date into a datetime
value.
This function ignores the sub-second resolution'''
dt = dateutil.parser.parse(date_string)
try:
dt = isodate.parse_datetime(date_string)
except:
return default
if is_aware(dt):
if not settings.USE_TZ:
dt = make_naive(dt, get_default_timezone())

View File

@ -93,7 +93,7 @@ setup(name="django-mellon",
install_requires=[
'django>=1.5',
'requests',
'python-dateutil',
'isodate',
],
setup_requires=[
'django',