nanotime(x)
"nanotime"(x)
"nanotime"(x)
"nanotime"(x)
"nanotime"(x)
"nanotime"(x)
"nanotime"(x)
"nanotime"(x)
"print"(x, ...)
"format"(x, justify = "right", digits = NULL, na.encode = FALSE, trim = TRUE, ...)
"index2char"(x, frequency = NULL, ...)
"as.POSIXct"(x, tz, ...)
"as.POSIXlt"(x, tz, ...)
"as.Date"(x, ...)
"as.data.frame"(x, ...)
nanotime
format
method but ignored hereformat
method but ignored hereformat
method but ignored hereformat
method but ignored hereindex2char
method but ignored hereas.POSIXct
and as.POSIXlt
,
can be set via options("nanotimeFormat")
and uses UTC as
a default and fallbackDate
or
POSIXct
objects for the former, and difftime
for the later. Here we (currently) only have time points,
but they are effectively also durations relative to the
epoch of January 1, 1970.bit64
package for integer64
types to represent nanoseconds relative to the epoch. This is
similar to POSIXct
which uses fractional seconds since the
epoch---so here we are essentially having the same values, but
multiplied by 10 to the power 9 and stored as integers. We need
to rely on the external package as we require 64 bit integers
whereas R itself onky has 32 bit integers. The
bit64
package is clever about how it manages to
provide such an integer using only the 64-bit double type and very
clever (and efficient) transformations. The other is the CCTZ library in C++, which we access via the
RcppCCTZ
package. CCTZ extends the C++11 standard
library type chrono
type in very useful ways for time zones and
localtime. We use its formating and parsing features.x <- nanotime("1970-01-01T00:00:00.000000001+00:00")
print(x)
x <- x + 1
print(x)
format(x)
x <- x + 10
print(x)
format(x)
format(nanotime(Sys.time()) + 1:3) # three elements each 1 ns apart
Run the code above in your browser using DataCamp Workspace