日本語 · English

epochOrdinal — the running ordinal from the epoch

Translated from the canonical Japanese page reference/epochOrdinal.md. The source_sha above records the source revision; a consistency check flags this page when the Japanese original changes.

Category: projection (value expression, body-layer core) / Signature: epochOrdinal(u, d) : point -> number / name settled (RC2, spec §5.4)

Meaning

Returns the running ordinal from the epoch (0-based) of the u window containing point d. It is ordinalIn with the frame widened to the epoch — a single coordinate that never resets per window. It is the same coordinate as “the ordinal n of the window under generation” that the premise-layer window-generating word span receives (monthOf(m) = m mod 12 holds with m=0 = the epoch month).

The epoch is the language default 1970-01-01T00:00 (in the in-scope tz). A calendar system on a different basis can override it via the primitive definition’s member epoch: (it cannot be placed in the user-side preamble; ADR-31).

Examples

Every other month — the first day of even-ordinal months (the origin is 1970-01, so January, March, … are even):

# eval: 2026-01-01..2026-04-01
@JP
everyDay |> filter(d => epochOrdinal(month, d) mod 2 == 0) |> within(month) |> first
#=> 2026-01-01 2026-03-01

“Modulo 12” gives the position of the calendar month — selecting January only:

# eval: 2026-01-01..2027-01-01
@JP
everyDay |> filter(d => epochOrdinal(month, d) mod 12 == 0) |> within(month) |> first
#=> 2026-01-01

Pitfalls

ordinalIn · span (the supplier of the same ordinal coordinate) · the epoch epoch: (ADR-31) · ADR-27/30.