% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sequence.R
\name{seq.mixtime::mixtime}
\alias{seq.mixtime::mixtime}
\alias{seq.mt_time}
\title{Generate sequences of mixtime values}
\usage{
\method{seq}{`mixtime::mixtime`}(...)

\method{seq}{mt_time}(
  from,
  to,
  by,
  length.out = NULL,
  along.with = NULL,
  on_invalid = c("nearest", "overflow"),
  ...
)
}
\arguments{
\item{...}{Additional arguments passed to the underlying sequence method.}

\item{from}{Starting value of the sequence.}

\item{to}{End value of the sequence (if provided).}

\item{by}{Increment of the sequence. Can be:
\itemize{
\item A numeric for the number of time chronons
\item A character string specifying the interval (e.g., "1 day", "2 weeks",
"1 month", "1 year")
\item A time granule object created with time unit functions (e.g., \code{cal_gregorian$year(1L)},
\code{cal_gregorian$month(1L)}, \code{cal_gregorian$day(1L)})
\item A time \code{\link[=duration]{duration()}} object (e.g., \code{years(1L)}, \code{months(1L)}, \code{days(1L)})
}}

\item{length.out}{Desired length of the sequence (alternative to \code{to}).}

\item{along.with}{Take the length from this argument (alternative to \code{length.out}).}

\item{on_invalid}{How to handle time points that overflow the cycle when
using a \code{by} argument with different time granule than the sequence chronon.
Options are:
\itemize{
\item \code{"nearest"} (default): Adjust overflowing time points to the nearest
valid time point within the cycle
\item \code{"overflow"}: Allow time points to overflow into the next cycle
}

This is relevant when the starting time point has an offset that doesn't
exist in all cycles. For example, starting on day 31 with \code{by = "1 month"}
will overflow in months with fewer than 31 days (e.g., February). With
\code{"nearest"}, these will be adjusted to the last day of the month (e.g.,
Feb 28/29). With \code{"overflow"}, the extra days carry into the next month.

If not explicitly specified and overflow occurs, a warning is issued with
the default \code{"nearest"} behavior applied.}
}
\value{
A mixtime vector containing the sequence.
}
\description{
Create regular sequences of time values. This method handles both linear
time sequences (dates, date-times) and cyclical time sequences (day of week,
month of year).
}
\details{
For linear time types (Date, POSIXct, yearmonth, etc.), sequences progress
forward or backward in time. For cyclical time types (month_of_year,
day_of_week, etc.), sequences wrap around cyclically.
}
\examples{
# Linear time sequences with integer by
seq(yearmonth("2020-01-01"), yearmonth("2020-12-01"))
seq(yearquarter("2020-01-01"), length.out = 5, by = 3)

# Linear time sequences with string intervals
seq(date("2020-01-01"), date("2020-12-31"), by = "1 month")
seq(yearmonth("2020-01-01"), yearmonth("2025-01-01"), by = "1 year")
seq(date("2020-01-01"), length.out = 10, by = "2 weeks")

# Linear time sequences incrementing by time granules
seq(yearmonth("2020-01-01"), yearmonth("2020-12-01"), by = cal_gregorian$month(2L))
seq(date("2020-01-01"), length.out = 5, by = cal_gregorian$year(1L))
seq(date("2020-01-01"), date("2020-01-31"), by = cal_gregorian$day(7L))

# Handling invalid dates with on_invalid
seq(date("2020-01-31"), length.out = 3, by = "1 month")  # warns, uses nearest
seq(date("2020-01-31"), length.out = 3, by = "1 month", on_invalid = "nearest")
seq(date("2020-01-31"), length.out = 3, by = "1 month", on_invalid = "overflow")

# Cyclical time sequences
seq(month_of_year(0L), month_of_year(11L))
seq(day_of_week(0L), day_of_week(6L), by = 1)

}
