mt_calendar: Base S7 class for calendars

mt_calendarR Documentation

Base S7 class for calendars

Description

mt_calendar is the parent class of every calendar. A calendar is a named list of time unit classes, and each calendar created with new_calendar() is the single instance of its own subclass of mt_calendar (e.g. cal_isoweek is an instance of class cal_isoweek). This allows methods to dispatch on the calendar, such as formatting a shared unit differently in each calendar that contains it.

Usage

mt_calendar(.data = list())

Arguments

.data

A named list of time unit classes.

Details

Time units record their calendar by its identifier ("<package>::<name>"), which is resolved back to the calendar object when the unit's ⁠@calendar⁠ is accessed. This keeps time objects small when serialised, and their calendar is restored from the current definition when read back in.

Value

An S7 class object, or a calendar when called as a constructor. End users should use new_calendar() to create calendars.

See Also

new_calendar() for creating calendars, time_calendar() for obtaining the calendar of a time object.


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