INNER CODE UNIT · Python

CustomTime

eamigo86/graphene-django-extras · graphene_django_extras/base_types.py:166

class CustomTime(Time):
    """Custom time scalar type with support for custom date formats."""

    @staticmethod
    def serialize(time):
        """Serialize time value to string."""
        if isinstance(time, CustomDateFormat):
            return time.date_str

        if isinstance(time, datetime.datetime):
            time = time.time()

        assert isinstance(
            time, datetime.time
        ), 'Received not compatible time "{}"'.format(repr(time))
        return time.isoformat()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…