MCPcopy Create free account
hub / github.com/apify/crawlee-python / _timedelta_from_ms

Function _timedelta_from_ms

src/crawlee/_utils/models.py:34–46  ·  view source on GitHub ↗
(value: float | timedelta | Any | None, handler: Callable[[Any], timedelta])

Source from the content-addressed store, hash-verified

32
33
34def _timedelta_from_ms(value: float | timedelta | Any | None, handler: Callable[[Any], timedelta]) -> timedelta | None:
35 if value == float('inf'):
36 return timedelta.max
37
38 # If the value is a string-encoded number, decode it
39 if isinstance(value, str):
40 with suppress(ValidationError):
41 value = _number_parser.validate_python(value)
42
43 if not isinstance(value, (int, float)):
44 return handler(value)
45
46 return timedelta(milliseconds=value)
47
48
49def _timedelta_from_secs(

Callers

nothing calls this directly

Calls 1

handlerFunction · 0.50

Tested by

no test coverage detected