Skip to content

TimeDelta misleading 'precision' argument & v4 breaking change #2822

@OJFord

Description

@OJFord

The docstring is correct:

:param precision: The time unit used for (de)serialization. Must be one of 'weeks',
   'days', 'hours', 'minutes', 'seconds', 'milliseconds' or 'microseconds'.

it's the units (de)serialised to; it doesn't effect precision.

That is, 123 microseconds with the default "seconds" precision will serialise to 0.000123, not 0.

This seems to be a breaking change in v4.0.0, perhaps somehow related to the date/time/isoformat change, I think in 0c90110 as previously it would return a timedelta(microseconds=123) in the _serialize method, but now returns a float via utils.timedelta_to_microseconds divided by the 'precision''s mapping value, i.e. 1000000 for seconds.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions