curldl.util.time module#

Time and timestamp utilities for internal use

class curldl.util.time.Time[source]#

Bases: object

Time and timestamp utilities

static timestamp_to_dt(timestamp: int | float) datetime[source]#

Convert POSIX timestamp to datetime in UTC timezone.

Parameters:

timestamp (int | float) – UTC-based POSIX timestamp

Returns:

datetime.datetime in UTC timezone

Return type:

datetime

static timestamp_to_http_date(timestamp: int | float) str[source]#

Convert POSIX timestamp to HTTP date in GMT timezone.

Parameters:

timestamp (int | float) – POSIX timestamp

Returns:

RFC-822 date suitable for HTTP headers

Return type:

str

static timestamp_delta(timestamp_delta: int | float) timedelta[source]#

Convert POSIX timestamp difference to a printable datetime duration.

Parameters:

timestamp_delta (int | float) – time period in seconds

Returns:

datetime.datetime duration, rounded to non-fractional seconds

Return type:

timedelta