calendar_gregorian: Gregorian time unit classes

calendar_gregorianR Documentation

Gregorian time unit classes

Description

Time unit constructors for the Gregorian calendar system. These units can be used with linear_time() to create custom time representations.

Usage

cal_gregorian

Format

A civil-based calendar containing Gregorian time units.

Details

The following time units are available in the Gregorian calendar (⁠cal_gregorian$⁠).

  • year(): Year unit

  • quarter(): Quarter (3-month period) unit

  • month(): Month unit

  • day(): Day unit

  • hour(): Hour unit

  • minute(): Minute unit

  • second(): Second unit

  • millisecond(): Millisecond unit

These units form a hierarchy where conversions between adjacent units follow the Gregorian calendar rules. For units that don't have a fixed relationship (e.g., months to days), the conversion requires a time context.

Value

A calendar (an S7 mt_calendar object of class cal_gregorian) containing the named time unit classes of the Gregorian calendar. Each unit is accessible via $ notation and calling it with a step size produces a time granule (e.g., 1 month granule as cal_gregorian$month(1L)).

See Also

linear_time() for creating linear time points.

Examples

# Create a custom time representation using Gregorian units
linear_time(
  Sys.time(),
  chronon = hour(1L)
)


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