File: trunc.POSIXt.Rd

package info (click to toggle)
hmisc 4.2-0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,332 kB
  • sloc: asm: 27,116; fortran: 606; ansic: 411; xml: 160; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,784 bytes parent folder | download
1
2
3
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
47
48
49
50
51
52
\name{trunc.POSIXt}
\alias{truncPOSIXt}
\alias{ceil.POSIXt}
\alias{ceil}
\alias{ceil.default}
\alias{roundPOSIXt}
\title{Return the floor, ceiling, or rounded value of date or time to
  specified unit.}
\description{
  \code{truncPOSIXt} returns the date truncated to the specified unit.
  \code{ceil.POSIXt} returns next ceiling of the date at the unit selected in
  \code{units}.
  \code{roundPOSIXt} returns the date or time value rounded to nearest
  specified unit selected in \code{digits}.

  \code{truncPOSIXt} and \code{roundPOSIXt} have been extended from
  the \code{base} package functions \code{trunc.POSIXt} and
  \code{round.POSIXt} which in the future will add the other time units
  we need.
}
\usage{
ceil(x, units,\dots)
\method{ceil}{default}(x, units, \dots)
truncPOSIXt(x, units = c("secs", "mins", "hours", "days",
"months", "years"), \dots)
\method{ceil}{POSIXt}(x, units = c("secs", "mins", "hours", "days",
"months", "years"), \dots)
roundPOSIXt(x, digits = c("secs", "mins", "hours", "days", "months", "years"))
}
\arguments{
  \item{x}{ date to be ceilinged, truncated, or rounded }
  \item{units}{ unit to that is is rounded up or down to. }
  \item{digits}{
    same as \code{units} but different name to be compatible
    with \code{\link{round}} generic.
  }
  \item{\dots}{further arguments to be passed to or from other methods.}
}
\value{
  An object of class \code{POSIXlt}.
}
\author{ Charles Dupont }
\seealso{ \code{\link{Date}} \code{\link{POSIXt}} \code{\link{POSIXlt}} \code{\link{DateTimeClasses}}}
\examples{
date <- ISOdate(1832, 7, 12)
ceil(date, units='months')  # '1832-8-1'
truncPOSIXt(date, units='years')     # '1832-1-1'
roundPOSIXt(date, digits='months')    # '1832-7-1'
}
\keyword{ manip }
\keyword{ utilities }
\keyword{ chron }