-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Currently the timedelta scalar serializer returns a float equivalent to the total amount of seconds.
It could be an idea to return the ISO format for durations (see https://en.wikipedia.org/wiki/ISO_8601#Durations). Since python doesn't implement a way to do timedelta(days=1).isoformat(), we could use django duration_iso_string:
from datetime import timedelta
from django.utils.duration import duration_iso_string
timedelta_scalar = ScalarType("Timedelta")
@timedelta_scalar.serializer
def serialize_timedelta(value: timedelta) -> float:
return duration_iso_string(value)Also instead of Timedelta it could be called Duration
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels