| new_calendar | R Documentation |
Define a new calendar as a collection of time units. Calendars are the foundation for representing dates and times in terms of human-readable components like years, months, days, hours, minutes, and seconds. Each calendar is defined by specifying the time units it contains, which determine how time values can be interpreted and manipulated.
new_calendar(..., name, inherit = NULL, class = lifecycle::deprecated())
... |
Named time unit class definitions. Each argument should be a
time unit class (typically created with |
name |
A string naming the calendar (e.g. |
inherit |
Optional calendar to inherit time units from. Units
defined in |
class |
Time units are typically S7 class definitions that inherit from mt_unit
for standard units, mt_tz_unit for timezone-aware units (civil time), or
mt_loc_unit for location-aware units (astronomical time). The calendar
object provides a namespace for accessing these unit constructors and
defines the relationships between them for calendar arithmetic.
A calendar object, the single instance of a new S7 class name
which inherits from mt_calendar. A calendar is a named list containing
the specified time unit classes.
linear_time(), cyclical_time()
# Create a simple calendar with year and month units
# (inheriting from civil time units for day, hour, minute, second, ...)
cal_simple <- new_calendar(
year = new_time_unit("tu_year", parent = mt_tz_unit),
month = new_time_unit("tu_month", parent = mt_tz_unit),
inherit = cal_time_civil,
name = "cal_simple"
)
# Create time granules from the calendar
cal_simple$year(1L)
cal_simple$month(1L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.