% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chronon_common.R
\name{chronon_common}
\alias{chronon_common}
\alias{chronon_common.mixtime}
\title{Find the common chronon of a time object}
\usage{
chronon_common(x, ...)

chronon_common.mixtime(x, .ptype = NULL, ...)
}
\arguments{
\item{x}{A time object (typically a \code{\link{mixtime}}).}

\item{...}{Additional arguments for methods.}

\item{.ptype}{If NULL, the default, the output returns the common chronon
across all chronons of \code{x}. Alternatively, a prototype chronon can be
supplied to \code{.ptype} to demand a specific chronon is used. If the supplied
\code{.ptype} cannot represent all input chronons without loss of information,
an error is raised.}
}
\value{
A time granule object representing the common chronon.
}
\description{
This utility function takes a set of chronons and identifies a common chronon
of the finest granularity that can represent all input chronons without loss
of information. This is useful for operations that require a shared time
granule, such as combining or comparing different time measured at different
precisions.

The result is obtained by finding the greatest lower bound (GLB) of the input
chronons using the ordered relationships defined by \code{chronon_cardinality()}
methods. The GLB represents the finest chronon that can represent all input
chronons without loss of information.
}
\examples{
# The common chronon between a year-month and a day is a day
chronon_common(c(yearmonth(Sys.Date()), date(Sys.Date())))

# The common chronon between a Gregorian month and an ISO week is a day
chronon_common(c(yearmonth(Sys.Date()), yearweek(Sys.Date())))

# The common chronon between a ISO week and an hour is an hour
chronon_common(c(yearweek(Sys.Date()), linear_time(Sys.time(), hour(1L))))

}
