mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-10 19:56:45 +03:00
Use aniso8601 instead of iso8601
This commit is contained in:
parent
3ee94131ae
commit
b4255e55fd
|
@ -3,17 +3,10 @@ from __future__ import absolute_import
|
|||
import datetime
|
||||
|
||||
from graphql.language import ast
|
||||
from aniso8601 import parse_datetime, parse_date, parse_time
|
||||
|
||||
from .scalars import Scalar
|
||||
|
||||
try:
|
||||
import iso8601
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"iso8601 package is required for DateTime Scalar.\n"
|
||||
"You can install it using: pip install iso8601."
|
||||
)
|
||||
|
||||
|
||||
class Date(Scalar):
|
||||
'''
|
||||
|
@ -38,7 +31,7 @@ class Date(Scalar):
|
|||
|
||||
@staticmethod
|
||||
def parse_value(value):
|
||||
return iso8601.parse_date(value).date()
|
||||
return parse_date(value)
|
||||
|
||||
|
||||
class DateTime(Scalar):
|
||||
|
@ -62,7 +55,7 @@ class DateTime(Scalar):
|
|||
|
||||
@staticmethod
|
||||
def parse_value(value):
|
||||
return iso8601.parse_date(value)
|
||||
return parse_datetime(value)
|
||||
|
||||
|
||||
class Time(Scalar):
|
||||
|
@ -71,7 +64,6 @@ class Time(Scalar):
|
|||
specified by
|
||||
[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
|
||||
'''
|
||||
epoch_date = '1970-01-01'
|
||||
|
||||
@staticmethod
|
||||
def serialize(time):
|
||||
|
@ -87,5 +79,4 @@ class Time(Scalar):
|
|||
|
||||
@classmethod
|
||||
def parse_value(cls, value):
|
||||
dt = iso8601.parse_date('{}T{}'.format(cls.epoch_date, value))
|
||||
return datetime.time(dt.hour, dt.minute, dt.second, dt.microsecond, dt.tzinfo)
|
||||
return parse_time(value)
|
||||
|
|
Loading…
Reference in New Issue
Block a user