normalize_timedelta

gafaelfawr.util.normalize_timedelta(v)

Pydantic validator for timedelta fields.

The only reason to use this validator over Pydantic’s built-in behavior is to ensure that ISO time durations are rejected and only an integer number of seconds is supported.

Parameters:

v (int | timedelta | None) – The field representing a duration, in seconds.

Returns:

The corresponding datetime.timedelta or None if the input was None.

Return type:

datetime.timedelta or None