Skip to content

endOf

Module Export

instant | date |> (granularity: Granularity, zone: Timezone) => instant

The exclusive upper edge of the local period containing the input, in the given timezone.

Remarks

The edge is exclusive, and equals the startOf of the following period. That is deliberate: it means adjacent ranges compose without gaps or off-by-one overlaps, so a value belongs to exactly one period when compared with >= start and < end.

As with startOf, the offset is resolved at the boundary being returned rather than at the input instant.

Examples

import 'calendar'
from 2026-08-15T12:00:00Z endOf ('month', 'Europe/Stockholm')
// Returns:
2026-08-31T22:00:00Z

The edge is shared with the next period, so ranges tile:

import 'calendar'
let august = 2026-08-15T12:00:00Z
let september = 2026-09-15T12:00:00Z
from (august endOf ('month', 'Europe/Stockholm')) == (september startOf ('month', 'Europe/Stockholm'))
// Returns:
true