% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/duration.R
\name{new_duration_fn}
\alias{new_duration_fn}
\title{Duration function factory}
\usage{
new_duration_fn(chronon, default_calendar = cal_gregorian)
}
\arguments{
\item{chronon}{A bare call for a time unit object representing the chronon
(e.g., \code{month(1L)}, \code{day(1L)}).}

\item{default_calendar}{A default calendar used to resolve the time units
if they don't exist in the calendar of the input data (e.g.,
\code{cal_gregorian}).}
}
\value{
A function used to create duration vectors with a specific chronon.
The returned function accepts:
\describe{
\item{\code{data}}{A numeric vector of duration magnitudes.}
\item{\code{calendar}}{A calendar system used to evaluate \code{chronon}. Defaults
to \code{time_calendar(data)}.}
\item{\code{...}}{Additional arguments passed to the chronon (e.g., \code{tz} for
timezones).}
}
}
\description{
\code{new_duration_fn()} creates a duration function for a specified chronon. A
chronon is the smallest indivisible time unit (e.g., days, months) that
defines what the numeric magnitudes in the resulting duration vector
represent.
}
\examples{
# Create a months duration function
months <- new_duration_fn(month(1L), default_calendar = cal_gregorian)
months(1:6)

# Create a days duration function
days <- new_duration_fn(day(1L), default_calendar = cal_gregorian)
days(1:7)

}
\seealso{
\itemize{
\item \code{\link[=duration]{duration()}} for creating duration vectors directly
\item \link{cal_gregorian}, \link{cal_isoweek} for calendar systems
}
}
