INNER CODE UNIT · Python
CustomDateTime
eamigo86/graphene-django-extras · graphene_django_extras/base_types.py:201
class CustomDateTime(DateTime):
"""Custom datetime scalar type with support for custom date formats."""
@staticmethod
def serialize(dt):
"""Serialize datetime value to string."""
if isinstance(dt, CustomDateFormat):
return dt.date_str
assert isinstance(
dt, (datetime.datetime, datetime.date)
), 'Received not compatible datetime "{}"'.format(repr(dt))
return dt.isoformat()