Description of the classes "POSIXlt" and "POSIXct" representing calendar dates and times.
# S3 method for POSIXct
print(x, tz = "", usetz = TRUE, max = NULL, …)<p></p><p># S3 method for POSIXct
summary(object, digits = 15, …)</p><p><code>time + z</code>
<code>z + time</code>
<code>time - z</code>
<code>time1 lop time2</code></p>
| Parameter | Description |
|---|---|
x, object |
an object to be printed or summarized from one of the date-time classes. |
tz, usetz |
for timezone formatting, passed to format.POSIXct. |
max |
numeric or NULL, specifying the maximal number of entries to be printed. By default, when NULL, getOption("max.print") used. |
digits |
number of significant digits for the computations: should be high enough to represent the least important time unit exactly. |
… |
further arguments to be passed from or to other methods. |
time |
date-time objects |
time1, time2 |
date-time objects or character vectors. (Character vectors are converted by as.POSIXct.) |
z |
a numeric vector (in seconds) |
lop |
one of ==, !=, <, <=, > or >=. |
# NOT RUN {
<!-- % <--> may fail / be platform dependent -->
(z <- Sys.time()) # the current date, as class "POSIXct"
Sys.time() - 3600 # an hour ago
as.POSIXlt(Sys.time(), "GMT") # the current time in GMT
format(.leap.seconds) # the leap seconds in your time zone
print(.leap.seconds, tz = "PST8PDT") # and in Seattle's
# }
# NOT RUN {
<!-- % ..test should be diffable from here on: -->
# }
# NOT RUN {
## look at *internal* representation of "POSIXlt" :
leapS <- as.POSIXlt(.leap.seconds)
names(leapS) ; is.list(leapS)
## str() "too smart" --> need unclass(.):
utils::str(unclass(leapS), vec.len = 7)
## Extracting *single* components of POSIXlt objects:
leapS[1 : 5, "year"]
## length(.) <- n now works for "POSIXct" and "POSIXlt" :
for(lpS in list(.leap.seconds, leapS)) {
ls <- lpS; length(ls) <- 12
l2 <- lpS; length(l2) <- 5 + length(lpS)
stopifnot(exprs = {
## length(.) <- * is compatible to subsetting/indexing:
identical(ls, lpS[seq_along(ls)])
identical(l2, lpS[seq_along(l2)])
## has filled with NA's
is.na(l2[(length(lpS)+1):length(l2)])
})
}
# }
# NOT RUN {
<!-- % for -->
# }