% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/01_calendar.R
\name{new_calendar}
\alias{new_calendar}
\title{Create a new calendar}
\usage{
new_calendar(..., inherit = NULL, class = character())
}
\arguments{
\item{...}{Named time unit class definitions. Each argument should be a
time unit class (typically created with \code{S7::new_class()}) that inherits
from \code{mt_unit} or \code{mt_tz_unit}. The names define the calendar's fields
and are used to access unit constructors (e.g., \code{calendar$year()}).}

\item{inherit}{Optional calendar to inherit time units from. Units
defined in \code{...} will override inherited units with the same name.}

\item{class}{Character vector of additional classes for the calendar object.}
}
\value{
A calendar object of class \code{c(class, "mt_calendar")}, consisting of a
named list containing the specified time unit classes.
}
\description{
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.
}
\details{
Time units are typically S7 class definitions that inherit from \code{\link{mt_unit}}
for standard units, \code{\link{mt_tz_unit}} for timezone-aware units (civil time), or
\code{\link{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.
}
\examples{
# 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,
  class = "cal_simple"
)

# Create time granules from the calendar
cal_simple$year(1L)
cal_simple$month(1L)

}
\seealso{
\code{\link[=linear_time]{linear_time()}}, \code{\link[=cyclical_time]{cyclical_time()}}
}
