2

Working with nanoseconds from epoch is a breeze with nanotime, e.g.:

> x  <- 1639142792837258898
> xn <- nanotime::nanotime(x)
> xn
[1] 2021-12-10T22:26:32.837259008+09:00
> format(xn, format = "%Y-%m-%dT%H:%M:%E9S")
[1] "2021-12-10T22:26:32.837259008"

nanotime also allows to use an underscore as separator for fractions of seconds when parsing, like so:

> y <- nanotime::as.nanotime("2021-12-10T22:26:32.837_259_008+09:00")
> y
[1] 2021-12-10T22:26:32.837259008+09:00

How can I achieve the same style when formatting?

Ryogi
  • 5,497
  • 5
  • 26
  • 46

0 Answers0