round.POSIXt.Rd 1.38 KB
Newer Older
Radford Neal's avatar
Radford Neal committed
1 2
% File src/library/base/man/round.POSIXt.Rd
% Part of the R package, http://www.R-project.org
3
% Copyright 1995-2007 R Core Team
Radford Neal's avatar
Radford Neal committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
% Distributed under GPL 2 or later

\name{round.POSIXt}
\alias{round.POSIXt}
\alias{trunc.POSIXt}
\alias{round.Date}
\alias{trunc.Date}
\title{Round / Truncate Data-Time Objects}
\description{
  Round or truncate date-time objects.
}
\usage{
\method{round}{POSIXt}(x, units = c("secs", "mins", "hours", "days"))
\method{trunc}{POSIXt}(x, units = c("secs", "mins", "hours", "days"), \dots)

\method{round}{Date}(x, \dots)
\method{trunc}{Date}(x, \dots)
}
\arguments{
  \item{x}{an object inheriting from \code{"POSIXt"} or \code{"Date"}.}
  \item{units}{one of the units listed.  Can be abbreviated.}
  \item{\dots}{arguments to be passed to or from other methods, notably
    \code{digits} for \code{round}.}
}
\details{
  The time is rounded or truncated to the second, minute, hour or day.
  Timezones are only relevant to days, when midnight in the current
  \link{timezone} is used.

  The methods for class \code{"Date"} are of little use except to remove
  fractional days.
}
\value{
  An object of class \code{"POSIXlt"} or \code{"Date"}.
}
\seealso{
  \code{\link{round}} for the generic function and default methods.
  
  \code{\link{DateTimeClasses}}, \code{\link{Date}}
}

\examples{
round(.leap.seconds + 1000, "hour")
Radford Neal's avatar
Radford Neal committed
47
\donttest{trunc(Sys.time(), "day")}
Radford Neal's avatar
Radford Neal committed
48 49
}
\keyword{chron}