eddelbuettel / nanotime

Nanosecond Resolution Time Functionality for R
https://eddelbuettel.github.io/nanotime
GNU General Public License v2.0
53 stars 7 forks source link

feat: Add 'as.nanoduration.difftime()' #106

Closed trevorld closed 2 years ago

trevorld commented 2 years ago

For external dependency reasons I assumed you are not interested in the similar method for lubridate::duration() objects:

setMethod("as.nanoduration", "Duration", function(x) {
    x <- as.numeric(x, "seconds")
    s <- as.integer(x) # seconds
    n <- as.integer(1e9 * (x - s)) # nanoseconds
    nanoduration(seconds = s, nanoseconds = n)
})
eddelbuettel commented 2 years ago

This looks useful too.

Could you let us know how many more of these you have planned? We are of the 'issue ticket before PR' school of thought and find it helps. Your PRs have been of very good quality, but it may help us to know how many more you have planned.

eddelbuettel commented 2 years ago

I presume we're all good here too @lsilvest ?

lsilvest commented 2 years ago

I presume we're all good here too @lsilvest ?

Yes, this should work.