YmerNode.Messages.Clock (Ymer Node v0.7.0)

Copy Markdown View Source

The times YmerNode.Messages reads and writes: the since a read takes, and every time an answer carries. The zone is handed in, never read here, so each rule below runs in a test against a zone with summer time.

A since is one ISO-8601 field. A span starts with P — PT1H, P1D — and reaches that far back from the moment of the call; one that nets forward — P-1D — is refused. Anything else is an instant: with an offset or Z it means exactly that; without one it is read in the zone given, which the process passes as the node time zone. An offset-less instant the clock passes twice — in the hour a fall-back repeats — is its first pass, as it is for a schedule's lifetime (YmerNode.Schedules.Lifetime); one the clock never shows — in the hour a spring-forward skips — is refused. A bare date is refused too, as neither shape.

Every time an answer carries is ISO-8601 in the zone with its offset, the way YmerNode.Schedules renders.

Summary

Functions

at as ISO-8601 in zone, with the offset it has there — nil for no time.

The instant a since given at now names, in UTC — nil for no since.

Functions

format(at, zone)

at as ISO-8601 in zone, with the offset it has there — nil for no time.

Examples

iex> YmerNode.Messages.Clock.format(~U[2026-07-01 09:00:00Z], "Europe/Helsinki")
"2026-07-01T12:00:00+03:00"

iex> YmerNode.Messages.Clock.format(~U[2026-12-01 09:00:00Z], "Europe/Helsinki")
"2026-12-01T11:00:00+02:00"

since(span, now, zone)

The instant a since given at now names, in UTC — nil for no since.

Examples

iex> YmerNode.Messages.Clock.since("PT1H", ~U[2026-10-11 09:00:00Z], "Europe/Helsinki")
{:ok, ~U[2026-10-11 08:00:00Z]}

iex> YmerNode.Messages.Clock.since("2026-10-11T09:00:00", ~U[2026-10-11 12:00:00Z], "Europe/Helsinki")
{:ok, ~U[2026-10-11 06:00:00Z]}

iex> YmerNode.Messages.Clock.since("2026-10-11T09:00:00Z", ~U[2026-10-11 12:00:00Z], "Europe/Helsinki")
{:ok, ~U[2026-10-11 09:00:00Z]}

iex> YmerNode.Messages.Clock.since(nil, ~U[2026-10-11 12:00:00Z], "Europe/Helsinki")
{:ok, nil}