% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cyclical_time.R
\name{cyclical_time_helpers}
\alias{cyclical_time_helpers}
\alias{month_of_year}
\alias{day_of_year}
\alias{day_of_month}
\alias{time_of_day}
\alias{day_of_week}
\alias{week_of_year}
\title{Cyclical time helpers}
\usage{
month_of_year(data, discrete = TRUE, calendar = time_calendar(data), ...)

day_of_year(data, discrete = TRUE, calendar = time_calendar(data), ...)

day_of_month(data, discrete = TRUE, calendar = time_calendar(data), ...)

time_of_day(data, discrete = TRUE, calendar = time_calendar(data), ...)

day_of_week(data, discrete = TRUE, calendar = time_calendar(data), ...)

week_of_year(data, discrete = TRUE, calendar = time_calendar(data), ...)
}
\arguments{
\item{data}{Another object to be coerced into the specified cyclical time.}

\item{discrete}{If \code{TRUE}, the position within the cycle that \code{data}
falls into is returned as an integer. If \code{FALSE}, a fractional
position is returned (analagous to time using a continuous time model).}

\item{calendar}{A calendar object specifying the calendar system to use.}

\item{...}{Additional arguments for \code{\link[=cyclical_time]{cyclical_time()}}, such as \code{tz} for timezones.}
}
\value{
A \code{mixtime} time vector containing an \code{mt_cyclical} vector with chronon and cycle matching the function used.
}
\description{
Helper functions for creating cyclical time representations. These functions
create time objects that repeat within a larger time cycle, useful for identifying
seasonal patterns or positions within a calendar period.
}
\section{Cyclical time representations}{

\itemize{
\item \code{day_of_week()}: Represents the day position within a week (1-7) using
the ISO 8601 standard where weeks start on Monday.
\item \code{day_of_month()}: Represents the day position within a month (1-28, 1-29,
1-30, or 1-31 depending on the month). The chronon is one day, cycling
within a month.
\item \code{day_of_year()}: Represents the day position within a year (1-365 or 1-366
for leap years). The chronon is one day, cycling within a year.
\item \code{week_of_year()}: Represents the week position within a year (1-52 or 1-53)
using the ISO 8601 week numbering system.
\item \code{month_of_year()}: Represents the month position within a year (1-12).
The chronon is one month, cycling within a year.
}
}

\section{Custom cyclical time representations}{

You can create custom cyclical time representations using \code{\link[=cyclical_time]{cyclical_time()}}
with any of the supported time units (see \link{calendar_gregorian} and \link{calendar_isoweek}).

For example, to create a representation for day of the month:

\preformatted{
day_of_month <- new_cyclical_time_fn(
  chronon = day(1L), cycle = month(1L),
  default_calendar = cal_gregorian
)
}
}

\examples{

month_of_year(Sys.Date())
day_of_year(Sys.Date())
day_of_week(Sys.Date())
day_of_week(as.Date("2025-12-15") + 0:6)

}
\seealso{
\code{\link[=cyclical_time]{cyclical_time()}} for creating cyclical time vectors,
\code{\link[=new_cyclical_time_fn]{new_cyclical_time_fn()}} for creating cyclical time helper functions
}
