% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cyclical_time.R
\name{cyclical_time}
\alias{cyclical_time}
\title{Cyclical time points}
\usage{
cyclical_time(
  data,
  chronon = time_chronon(data),
  cycle = time_cycle(data),
  discrete = TRUE,
  calendar = time_calendar(data)
)
}
\arguments{
\item{data}{Input data to convert to cyclical time. Can be:
\itemize{
\item Numeric values (interpreted as chronons, 1-indexed)
\item Character strings (parsed as dates/times)
\item Date or POSIXct objects
\item Other time objects
}}

\item{chronon}{A time granule representing the chronon (finest
indivisible time granule), evaluated in the context of \code{calendar}. Use
unquoted expressions like \code{day(1L)} or \code{month(1L)}. Chronons from a
specific calendar can also be used (e.g. \code{cal_isoweek$day(1L)}).}

\item{cycle}{A time granule representing the cycle (coarser time granule
that defines the period), evaluated in the context of \code{calendar}. Use
unquoted expressions like \code{week(1L)} or \code{year(1L)}.}

\item{discrete}{Logical. If \code{TRUE} (default), returns integer positions within
the cycle (discrete time model). If \code{FALSE}, returns fractional positions
allowing representation of fractional time chronons (continuous time model).}

\item{calendar}{Calendar system used to evaluate \code{chronon} and \code{cycle}.
Defaults to \code{time_calendar(data)} for existing time objects. Common options
include \link{cal_gregorian} and \link{cal_isoweek}.}
}
\value{
A \code{mixtime} time vector containing an \code{mt_cyclical} vector.
}
\description{
\code{cyclical_time()} creates a vector of cyclical time points representing
positions within repeating cycles. This function is useful for creating custom
cyclical time representations that aren't covered by the convenience functions
like \code{\link[=day_of_week]{day_of_week()}} or \code{\link[=month_of_year]{month_of_year()}}.
}
\examples{
# Day of week (1-7, Monday = 1)
cyclical_time(
  Sys.Date(),
  chronon = day(1L),
  cycle = week(1L),
  calendar = cal_isoweek
)

# Month of year (1-12)
cyclical_time(
  Sys.Date(),
  chronon = month(1L),
  cycle = year(1L)
)

# Continuous time (discrete = FALSE) for fractional month of year
cyclical_time(
  Sys.Date(),
  chronon = month(1L),
  cycle = year(1L),
  discrete = FALSE
)

# Day of month with Gregorian calendar
cyclical_time(
  Sys.Date(),
  chronon = day(1L),
  cycle = month(1L),
  calendar = cal_gregorian
)

# Hours, minutes, and seconds
cyclical_time(
  Sys.time(),
  chronon = second(1L),
  cycle = day(1L)
)

}
\seealso{
\itemize{
\item \code{\link[=new_cyclical_time_fn]{new_cyclical_time_fn()}} for creating reusable cyclical time functions
\item \code{\link[=day_of_week]{day_of_week()}}, \code{\link[=day_of_month]{day_of_month()}}, \code{\link[=day_of_year]{day_of_year()}} for common cyclical representations
\item \code{\link[=month_of_year]{month_of_year()}}, \code{\link[=week_of_year]{week_of_year()}} for other cyclical time helpers
\item \link{cal_gregorian}, \link{cal_isoweek} for calendar systems
}
}
