component_helpers: Linear, cyclical and duration component helpers

component_helpersR Documentation

Linear, cyclical and duration component helpers

Description

lin(), cyc() and dur() name the time components addressed by mixtime's component-aware contexts — a single vocabulary shared across format() (and parsing) format strings and time_components() expressions. They are only meaningful inside one of these contexts; calling them directly is an error.

Usage

lin(granule)

cyc(granule, cycle)

dur(granule)

Arguments

granule

The time granule to address, given as a granule generator (e.g. year) or a sized time unit (e.g. year(1L)). Resolved in the calendar of the time vector being formatted, parsed or decomposed.

cycle

The coarser granule defining the cycle a cyc() component repeats within (e.g. year in cyc(month, year)).

Details

A linear and a cyclical component of the same granule store the same value: the count of that chronon since the Unix epoch. The reduction to a within-cycle position happens only when a cyclical vector is formatted. cyc() therefore behaves like lin() on its finest granule but additionally records the cycle.

dur() addresses a duration (an unanchored span of time, see duration()) counted in units of a granule, e.g. "{dur(day)}" formats and parses text like "3 days". A duration has no position in the calendar, so dur() must be the only token in its format string and isn't available in time_components(). Its granule is always a 1-unit granule, so dur(hour(3L)) behaves like dur(hour).

Value

A component specification, consumed internally by the component-aware context (e.g. format(), time_parse() or time_components()).

See Also

format(), time_parse(), time_components() and duration()


mixtime documentation built on Nov. 18, 2026, 5:08 p.m.