schedr._model.timestamps¶
Timestamps in DAG JSON: always UTC, written with Z.
See archive/PROJECT.md, Times and time zones.
- schedr._model.timestamps.format_timestamp(moment)¶
Formats an aware datetime as RFC 3339 in UTC, e.g.
2026-10-15T03:00:00Z.Microseconds are kept when present (
2026-10-15T03:00:00.250000Z).- Parameters:
moment (datetime) – An aware datetime, in any zone.
- Returns:
The moment in UTC with a
Zsuffix.- Raises:
ValueError – If
momentis naive (has no time zone).- Return type:
str
- schedr._model.timestamps.format_optional_timestamp(moment)¶
Formats an optional aware datetime like
format_timestamp().- Parameters:
moment (datetime | None) – An aware datetime, or
None.- Returns:
The moment in UTC with a
Zsuffix, orNone.- Raises:
ValueError – If
momentis naive.- Return type:
str | None
- schedr._model.timestamps.parse_moment(value, tz, name)¶
Reads a moment given in DAG code: naive values (and dates) are in the time zone
tz.- Parameters:
value (datetime | date | str) – An aware or naive datetime, a date (midnight), or an ISO 8601 string.
tz (str) – The IANA time zone of naive values (the trigger’s).
name (str) – The argument’s name, for messages.
- Returns:
An aware datetime.
- Raises:
TypeError – For another type.
ValueError – For a string that isn’t ISO 8601.
- Return type:
datetime