% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/round.R
\name{time_round}
\alias{time_round}
\alias{time_floor}
\alias{time_ceiling}
\alias{trunc_time}
\title{Round, floor and ceiling transformations for time objects}
\usage{
time_round(x, granule, ...)

time_ceiling(x, granule, ...)

time_floor(x, granule, ...)
}
\arguments{
\item{x}{A date/time object to be rounded. Accepted types include Date,
POSIXct, POSIXlt and other objects that inherit from POSIXt. The returned
object will be of the same class as the input.}

\item{granule}{A time granule (or object coercible to a time granule, e.g. "day").}

\item{...}{Additional arguments passed to specific implementations.}
}
\value{
An object of the same class as x with its time components adjusted
to the requested granule.
}
\description{
A family of helpers to round date/time objects to a specified time granule
such as second, minute, hour, or day. These functions preserve the input
time class, as rounded by the attributes of the \code{granule}.
}
\examples{
# Round POSIXct to the nearest minute (preserving tz)
t <- as.POSIXct("2020-01-01 12:34:56", tz = "UTC")
time_round(t, granule = cal_gregorian$minute(1L))

# Floor to the nearest hour
time_floor(t, granule = cal_gregorian$hour(1L))

# Ceiling a Date (treated as midnight-of-day rounding)
d <- as.Date("2020-01-01")
time_ceiling(d, granule = cal_gregorian$month(1L))

}
\seealso{
\link[base:round]{base::round}, \link[lubridate:round_date]{lubridate::round_date}
}
