## S3 method for class 'Date': round(x, ...) ## S3 method for class 'Date': trunc(x, ...)## 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"), ...)
## round, trunc, abs, ceiling, floor, sign, signif ## S3 method for class 'difftime': Math(x, ...)
x | a Date, POSIXt, or difftime object. |
units | the unit to truncate or round to. |
... | additional arguments. |
## Date dput(d <- as.Date("2038-01-19") + 0.9) dput(trunc(d)) dput(round(d))## POSIXt pct <- as.POSIXct("2038-01-19 13:34:37.5") trunc(pct, "days"); trunc(pct, "hours"); trunc(pct, "mins"); trunc(pct, "secs") round(pct, "days"); round(pct, "hours"); round(pct, "mins"); round(pct, "secs")
## difftime dt <- as.difftime("13:34:37.5") trunc(dt); floor(dt) round(dt); ceiling(dt) abs(dt); sign(dt); signif(dt)