ds_common_placeholder_py_lib.functions.time

File: functions/time.py Region: ds-common-placeholder-py-lib

Description

Time functions depend only on their arguments, never on the context: the date functions compute from the time they are given, their last argument (@{get_hour, UTC, '2026-05-03T01:30:00Z'}, or any reference the caller’s context holds), or from the current time when none is (contract §5). Outputs match the legacy builtins at the same instant, except get_current_date, which returns an ISO string.

Attributes

NOT_GIVEN

kept apart from any string, so '' is an error,

Functions

check_timezone(name) → zoneinfo.ZoneInfo

Return the zone for an IANA name.

check_language(name) → str

Return name if it is EN or NO.

check_at(value) → datetime.datetime

The time value names, an RFC 3339 timestamp.

get_start_last_month(args) → str

First instant of last month, e.g. 2026-04-01T00:00:00+00:00.

get_end_last_month(args) → str

Last microsecond of last month, e.g. 2026-04-30T23:59:59.999999+00:00.

get_start_date_last_month(args) → str

First day of last month, e.g. 2026-04-01.

get_end_date_last_month(args) → str

Last day of last month, e.g. 2026-04-30.

get_last_month_period(args) → str

Last month as <Month> <year>, e.g. April 2026.

get_current_date(args) → str

The date, e.g. 2026-05-03.

get_day_of_month(args) → int

The day of month.

get_previous_day_of_month(args) → int

The day of month one day before.

get_hour(args) → int

The hour, 0-23.

get_previous_hour(args) → int

The local hour one elapsed hour before, 0-23. Across a DST change

get_iso_timestamp_now(args) → str

The current time to the second, e.g. 2026-05-03T03:30:00+02:00.

get_unix_timestamp_now(args) → int

The current UNIX timestamp in whole seconds.

Module Contents

ds_common_placeholder_py_lib.functions.time.check_timezone(name: str) → zoneinfo.ZoneInfo[source]

Return the zone for an IANA name.

Raises:

PlaceholderError – argument if the name is not an IANA zone.

ds_common_placeholder_py_lib.functions.time.check_language(name: str) → str[source]

Return name if it is EN or NO.

Raises:

PlaceholderError – argument otherwise.

ds_common_placeholder_py_lib.functions.time.NOT_GIVEN: Any

kept apart from any string, so '' is an error, never the current time.

Type:

The default of at

ds_common_placeholder_py_lib.functions.time.check_at(value: str) → datetime.datetime[source]

The time value names, an RFC 3339 timestamp.

Raises:

PlaceholderError – argument if value is not an RFC 3339 timestamp with Z or an offset ('' included).

ds_common_placeholder_py_lib.functions.time.get_start_last_month(args: list[Any]) → str[source]

First instant of last month, e.g. 2026-04-01T00:00:00+00:00.

ds_common_placeholder_py_lib.functions.time.get_end_last_month(args: list[Any]) → str[source]

Last microsecond of last month, e.g. 2026-04-30T23:59:59.999999+00:00.

ds_common_placeholder_py_lib.functions.time.get_start_date_last_month(args: list[Any]) → str[source]

First day of last month, e.g. 2026-04-01.

ds_common_placeholder_py_lib.functions.time.get_end_date_last_month(args: list[Any]) → str[source]

Last day of last month, e.g. 2026-04-30.

ds_common_placeholder_py_lib.functions.time.get_last_month_period(args: list[Any]) → str[source]

Last month as <Month> <year>, e.g. April 2026.

ds_common_placeholder_py_lib.functions.time.get_current_date(args: list[Any]) → str[source]

The date, e.g. 2026-05-03.

ds_common_placeholder_py_lib.functions.time.get_day_of_month(args: list[Any]) → int[source]

The day of month.

ds_common_placeholder_py_lib.functions.time.get_previous_day_of_month(args: list[Any]) → int[source]

The day of month one day before.

ds_common_placeholder_py_lib.functions.time.get_hour(args: list[Any]) → int[source]

The hour, 0-23.

ds_common_placeholder_py_lib.functions.time.get_previous_hour(args: list[Any]) → int[source]

The local hour one elapsed hour before, 0-23. Across a DST change this differs from legacy, which subtracted wall time.

ds_common_placeholder_py_lib.functions.time.get_iso_timestamp_now(args: list[Any]) → str[source]

The current time to the second, e.g. 2026-05-03T03:30:00+02:00.

ds_common_placeholder_py_lib.functions.time.get_unix_timestamp_now(args: list[Any]) → int[source]

The current UNIX timestamp in whole seconds.