round.POSIXt: Round / Truncate Data-Time Objects

Description Usage Arguments Details Value See Also Examples

View source: R/datetime.R

Description

Round or truncate date-time objects.

Usage

1
2
3
4
5
6
7
8
9
## S3 method for class 'POSIXt'
round(x, units = c("secs", "mins", "hours", "days"))
## S3 method for class 'POSIXt'
trunc(x, units = c("secs", "mins", "hours", "days"), ...)

## S3 method for class 'Date'
round(x, ...)
## S3 method for class 'Date'
trunc(x, ...)

Arguments

x

an object inheriting from "POSIXt" or "Date".

units

one of the units listed. Can be abbreviated.

...

arguments to be passed to or from other methods, notably digits for round.

Details

The time is rounded or truncated to the second, minute, hour or day. Time zones are only relevant to days, when midnight in the current time zone is used.

The methods for class "Date" are of little use except to remove fractional days.

Value

An object of class "POSIXlt" or "Date".

See Also

round for the generic function and default methods.

DateTimeClasses, Date

Examples

1
2
round(.leap.seconds + 1000, "hour")
trunc(Sys.time(), "day")

robertzk/monadicbase documentation built on May 27, 2019, 10:35 a.m.