R Under development (unstable) (2024-06-16 r86763 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > library(nanotime) > > z <- RcppCCTZ:::parseDouble("1970-01-01T00:00:00.000000001+00:00") > cat("z is: ") z is: > print(z) [,1] [,2] [1,] 0 1 > > x <- nanotime("1970-01-01T00:00:00.000000001+00:00") > cat("x is: ") x is: > print(x) [1] 1970-01-01T00:00:00.000000001+00:00 > format(x) [1] "1970-01-01T00:00:00.000000001+00:00" > > cat("x+1 is: ") x+1 is: > x <- x + 1 > print(x) [1] 1970-01-01T00:00:00.000000002+00:00 > format(x) [1] "1970-01-01T00:00:00.000000002+00:00" > > cat("y is: ") y is: > y <- nanotime(z) > print(y) [1] 1970-01-01T00:00:00.000000000+00:00 1970-01-01T00:00:00.000000001+00:00 > #print(class(y)) > format(y) [1] "1970-01-01T00:00:00.000000000+00:00" "1970-01-01T00:00:00.000000001+00:00" > > cat("y+1 is: ") y+1 is: > y <- y + 1 > print(y) [1] 1970-01-01T00:00:00.000000001+00:00 1970-01-01T00:00:00.000000002+00:00 > format(y) [1] "1970-01-01T00:00:00.000000001+00:00" "1970-01-01T00:00:00.000000002+00:00" > > print(x == y) [1] FALSE TRUE > > od <- getOption("digits.secs") > options("digits.secs"=6) > as.POSIXct(x) [1] "1970-01-01 01:00:00 CET" > as.POSIXct(x+1000) [1] "1970-01-01 01:00:00.000001 CET" > as.POSIXlt(x) [1] "1970-01-01 01:00:00 CET" > as.POSIXlt(x+1000) [1] "1970-01-01 01:00:00.000001 CET" > as.Date(x) [1] "1970-01-01" > as.Date(x, tz="UTC") [1] "1970-01-01" > options("digits.secs"=od) > > > y <- nanotime(1L) # integer, may dispatch via nanotime.numeric > print(y) [1] 1970-01-01T00:00:00.000000001+00:00 > > y <- nanotime(1) # numeric > print(y) [1] 1970-01-01T00:00:00.000000001+00:00 > > ## v <- nanotime:::nanotime.default(1) # forced call, gets imprecise value > ## print(v) > > > options("nanotimeFormat"="%Y-%m-%d %H:%M:%S") > format(x <- nanotime("1970-01-01 00:00:00")) [1] "1970-01-01 00:00:00" > > options("nanotimeFormat"="%Y-%m-%d %H:%M:%E*S") > format(x <- nanotime("1970-01-01 00:00:00.123456789")) [1] "1970-01-01 00:00:00.123456789" > > options("nanotimeFormat"="%Y-%m-%d %H:%M:%E*S%Ez") # default > > cat("Done\n") Done > > proc.time() user system elapsed 0.54 0.07 0.61