% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare.R
\name{all.equal.mixtime::mt_time}
\alias{all.equal.mixtime::mt_time}
\title{Tolerant comparison of mixtime time values}
\usage{
\method{all.equal}{`mixtime::mt_time`}(target, current, tolerance = sqrt(.Machine$double.eps), ...)
}
\arguments{
\item{target, current}{\code{mt_time} vectors of the same length to compare (as
passed down by \link[vecvec:class_vecvec]{vecvec::class_vecvec}'s \code{all.equal()}).}

\item{tolerance}{Numeric tolerance, as an absolute number of \code{target}'s
chronon units. Defaults to \code{sqrt(.Machine$double.eps)}, as for
\code{\link[base:all.equal]{base::all.equal()}}.}

\item{...}{Ignored.}
}
\value{
\code{TRUE} if \code{target} and \code{current} are equal within \code{tolerance},
otherwise a string describing the discrepancy.
}
\description{
\link[vecvec:class_vecvec]{vecvec::class_vecvec}'s \code{all.equal()} method (which \code{mixtime} inherits,
since a mixtime vector is a \code{vecvec}) handles length/\code{NA} mismatches and
groups elements by their underlying storage slot, then compares each
group's \emph{raw} values with \code{all.equal()}. That raw comparison has no notion
of chronon: two elements that are \code{==} (e.g. \code{days(1)} and \code{hours(24)}, or
a \code{yearmonth} and an equivalent-instant \code{yearweek}) can end up stored with
different chronons or magnitudes, and so are wrongly reported as unequal.

This method fixes that at the per-slot level: elements already \code{==} (which
is chronon-aware, see \link{mt_linear-compare}/\link{mt_duration-compare}) count as
equal outright; for the rest, the discrepancy is measured as the duration
between them in their common chronon. A time point has no "typical
magnitude" to scale a \emph{relative} tolerance against the way a plain number
does, so - unlike \code{\link[base:all.equal.numeric]{base::all.equal.numeric()}} - \code{tolerance} is always
absolute, in (possibly fractional) chronon units.
}
\examples{
all.equal(yearmonth(0), yearmonth(0))
all.equal(yearmonth(0), yearmonth(1))
all.equal(days(1), hours(24))

}
\keyword{internal}
