datetime#

Date, time, duration, and timestamp helpers.

Functions#

parse_duration(→ datetime.timedelta | None)

Parse plain, compact, or ISO 8601 duration strings.

parse_datetime_to_timestamp(→ float | None)

Parse an ISO/RFC 3339 datetime into a POSIX timestamp.

normalize_timestamp_seconds(→ float)

Normalize a seconds-or-milliseconds POSIX timestamp to seconds.

Attributes#

COMPACT_DURATION_UNITS#
MAX_SECONDS_TIMESTAMP = 253402300799#
_COMPACT_DURATION_RE#
_ISO8601_DURATION_RE#
_DATE_ONLY_RE#
_COMPACT_DATE_ONLY_RE#
parse_duration(value: str) datetime.timedelta | None#

Parse plain, compact, or ISO 8601 duration strings.

parse_datetime_to_timestamp(value: str) float | None#

Parse an ISO/RFC 3339 datetime into a POSIX timestamp.

Naive datetimes are interpreted as UTC. Date-only values are interpreted as the start of the following UTC day.

normalize_timestamp_seconds(value: str | int | float) float#

Normalize a seconds-or-milliseconds POSIX timestamp to seconds.