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
orNone
if the input wasNone
.- Return type:
datetime.timedelta or None