Include trailing 0 (always 9 digits) for easier scanning #9

Closed
mattdowle opened this Issue Jan 26, 2017 · 4 comments

Projects

None yet

2 participants

@mattdowle

For example, this looks like 7 nanoseconds on first glance :

> format(nanotime(cooked$rdsent[1]))
[1] "2016-09-28T15:30:00.00000007+00:00"

but you have to look closely to realize there's just 8 subsecond digits there. So it's actually 70 nanoseconds.

Current behaviour :

format(nanotime(as.integer64("1475076600000000070")))
[1] "2016-09-28T15:30:00.00000007+00:00"
format(nanotime(as.integer64("1475076600000000071")))
[1] "2016-09-28T15:30:00.000000071+00:00"

Desired behaviour :

format(nanotime(as.integer64("1475076600000000070")))
[1] "2016-09-28T15:30:00.000000070+00:00"
format(nanotime(as.integer64("1475076600000000071")))
[1] "2016-09-28T15:30:00.000000071+00:00"

@eddelbuettel
Owner

Not me but the underlying CCTZ C++ library so ...

@eddelbuettel
Owner

This line in the corresponding CCTZ source file is your friend. Witness:

R> library(nanotime)
R> matt <- nanotime(70)
R> format(matt)
[1] "1970-01-01T00:00:00.00000007+00:00"
R> options("nanotimeFormat"="%Y-%m-%d %H:%M:%E9S%Ez")  # force nine digits
R> format(matt)
[1] "1970-01-01 00:00:00.000000070+00:00"
R> 
@eddelbuettel eddelbuettel added a commit that referenced this issue Jan 26, 2017
@eddelbuettel better printing method and other small fixes
Ops defined
as.integer64 converter
better default format (cf #9)
9b6e032
@eddelbuettel
Owner

I made the change in this branch which also fixes the printing issue. Try that.

@eddelbuettel
Owner

Thanks again for this, I folded it into master now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment