format.mt_time: Format mixtime vectors

format.mt_timeR Documentation

Format mixtime vectors

Description

Formats a mixtime vector as a character vector, using a glue-style format string of {lin(...)}/{cyc(...)} (or, for durations, {dur(...)}) tokens tailored to the vector's chronon and cycle. If format is omitted, a sensible default is derived automatically. See vignette("time-format-strings") for the format string syntax.

Usage

## S4 method for signature 'mt_time'
format(x, ..., attr = TRUE)
## S4 method for signature 'mt_cyclical_free'
format(x, format = NULL, ..., attr = TRUE)

## S7 method for class <mixtime::mt_cyclical_free>
format(x, format = NULL, ..., attr = TRUE)

Arguments

x

A mixtime vector.

...

Additional arguments for methods, including format for time points.

attr

If TRUE (default), append attribute information (e.g. timezone) to the default format.

format

A glue-style format string, defaulting to one derived automatically for x. For time points it is passed via ....

Value

A character vector the same length as x.

Underspecified cyclical time

Underspecified cyclical time (e.g. month_of_year(3)) has no position on the time line, so only {cyc(...)} tokens can be used. Attribute tokens such as {tz(.time)} render as empty text.

Examples

format(yearmonth("2024-03"))
format(date("2024-03-15"), format = "{cyc(day(1L), month(1L))} {lin(year(1L))}")
format(month_of_year(3))


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