% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare.R
\name{mt_cyclical-compare}
\alias{mt_cyclical-compare}
\alias{==,mt_cyclical-method}
\alias{!=,mt_cyclical-method}
\alias{<,mt_cyclical-method}
\alias{<=,mt_cyclical-method}
\alias{>,mt_cyclical-method}
\alias{>=,mt_cyclical-method}
\title{Comparison operators for cyclical time (\code{mt_cyclical})}
\usage{
\S4method{==}{mt_cyclical}(e1, e2)
\S4method{!=}{mt_cyclical}(e1, e2)
\S4method{<}{mt_cyclical}(e1, e2)
\S4method{<=}{mt_cyclical}(e1, e2)
\S4method{>}{mt_cyclical}(e1, e2)
\S4method{>=}{mt_cyclical}(e1, e2)
}
\arguments{
\item{e1, e2}{\code{mt_cyclical} vectors sharing a cycle (or values castable to one,
such as plain numeric vectors sharing the other operand's chronon).}
}
\value{
A logical vector.
}
\description{
A cyclical time value stores an absolute chronon count but \emph{means} a position
within its cycle (e.g. \code{day_of_week()} means a weekday, not a particular
Wednesday). Comparison therefore reduces both operands to their position
within the cycle - the same reduction \code{\link[=format]{format()}} displays - and compares
those:
\itemize{
\item \code{day_of_week(date("2020-01-15")) == day_of_week(date("2020-01-22"))} is
\code{TRUE}, since both are a Wednesday.
\item \code{day_of_year(date("2020-01-15")) == day_of_year(date("2021-01-15"))} is
\code{TRUE}, since both are the 15th day of their year.
}

Both operands must share a \code{cycle}: a cycle is a modulus rather than a unit,
so there is no meaningful common cycle between (say) a weekday and a
day-of-year, and comparing them is an error. Differing \emph{chronons} within a
shared cycle are reconciled as they are for \link[=mt_linear-compare]{mt_linear}:
both positions are expressed in the finest common chronon, and a discrete
value spans the closed interval of its chronon, so
\itemize{
\item \code{a == b} iff \code{start(a) == start(b)} and \code{end(a) == end(b)}
\item \code{a < b} iff \code{end(a) < start(b)}, \code{a > b} iff \code{start(a) > end(b)}
\item \code{a <= b} iff \code{end(a) <= end(b)}, \code{a >= b} iff \code{start(a) >= start(b)}
}

As for \code{mt_linear}, this is not a total order when chronons differ. Ordering
follows the position within the cycle (so \code{Mon < Wed}); the cycle's wrap-around
is not treated as circular.
}
