A minor update 0.3.10 for our nanotime
package is now on CRAN. nanotime
relies on the RcppCCTZ
package (as well as the RcppDate
package for additional C++ operations) and offers efficient high(er)
resolution time parsing and formatting up to nanosecond resolution,
using the bit64
package for the actual integer64
arithmetic. Initially
implemented using the S3 system, it has benefitted greatly from a
rigorous refactoring by Leonardo who not only rejigged
nanotime
internals in S4 but also added new S4 types for
periods, intervals and durations.
This release updates one S4 methods to very recent changes in r-devel
for which CRAN had reached out.
This concerns the setdiff()
method when applied to two
nanotime
objects. As it only affected R 4.5.0, due next
April, if rebuilt in the last two or so weeks it will not have been
visible to that many users, if any. In any event, it now works again for
that setup too, and should be going forward.
We also retired one demo function from the very early days,
apparently it relied on ggplot2
features that have since
moved on. If someone would like to help out and resurrect the demo,
please get in touch. We also cleaned out some no longer used tests, and
updated DESCRIPTION to what is required now. The NEWS snippet below has
the full details.
Changes in version 0.3.10 (2024-09-16)
Thanks to my CRANberries, there is a diffstat report for this release. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository – and all documentation is provided at the nanotime documentation site.
If you like this or other open-source work I do, you can sponsor me at GitHub.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
A quick bug fix release 0.3.9 for our nanotime
package is now on CRAN,
following up on the 0.3.8
release made this week. nanotime
relies on the RcppCCTZ
package (as well as the RcppDate
package for additional C++ operations) and offers efficient high(er)
resolution time parsing and formatting up to nanosecond resolution,
using the bit64
package for the actual integer64
arithmetic. Initially
implemented using the S3 system, it has benefitted greatly from a
rigorous refactoring by Leonardo who not only rejigged
nanotime
internals in S4 but also added new S4 types for
periods, intervals and durations.
The 0.3.8
release added a accurate
parameter for
POSIXct
conversions, and it turns out that this did not
test as expected on arm64 so we disabled the test on that platform. The
NEWS snippet below has the full details.
Changes in version 0.3.9 (2024-06-21)
Thanks to my CRANberries, there is a diffstat report for this release. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository – and all documentation is provided at the nanotime documentation site.
If you like this or other open-source work I do, you can sponsor me at GitHub.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
Leonardo and I are happy to
annunce that a new version 0.3.8 of our nanotime
package arrived on CRAN today.
It is the first release in over 1 1/2 years. nanotime
relies on the RcppCCTZ
package (as well as the RcppDate
package for additional C++ operations) and offers efficient high(er)
resolution time parsing and formatting up to nanosecond resolution,
using the bit64
package for the actual integer64
arithmetic. Initially
implemented using the S3 system, it has benefitted greatly from a
rigorous refactoring by Leonardo who not only rejigged
nanotime
internals in S4 but also added new S4 types for
periods, intervals and durations.
This release responds to a number of enhancements including a new
paramter accurate
for POSIXct
to
nanotime
conversions, a vector date converter, a switch to
double
return value when durations objects are dividded –
as well as a small battery of CRAN requests for changes and
updates. This started with a move away from the now ‘non-API’ function
SET_S4_OBJECT
which has been replaced by use of
Rf_asS4
. We also no longer need a custom compiler flag on
Windows (where for some reasons nobody understands or remembers,
bitfields are not packed) to small enhancements of manual page
formatting and last-but-not-least avoidance of some new UBSAN warnings.
The NEWS snippet has the full details.
Changes in version 0.3.8 (2024-06-19)
Time format documentation now has a reference to RcppCCTZ
The package no longer sets a default C++ compilation standard of C++11 (Dirk initially in #114, and later switched to C++17)
New
accurate
parameter for conversion fromPOSIXct
tonanotime
(Davor Josipovic and Leonardo in #116 closing #115)The
as.Date()
function is now vectorized and can take a TZ argument (Leonardo and Dirk in #119 closing #118)Use of internal function
SET_S4_OBJECT
has been replaced by API functionRf_asS4
(Leonardo in #121 closing #120)An
nanoduration
/nanoduration
expression now returns a double (Leonardo in #122 closing #117)Bitfield calculations no longer require an Windows-only compiler switch (Leonardo in #124)
A simple manual page format nag involving has been addressed (Dirk in #126 fixing #125)
An set of tests tickling an UBSAN issue via Rcpp code no longer run unless
CI
is set (Dirk in #127 fixing #123)
Thanks to my CRANberries, there is a diffstat report for this release. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository – and all documentation is provided at the nanotime documentation site.
If you like this or other open-source work I do, you can sponsor me at GitHub.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
A new version of our nanotime package arrived at CRAN today as version 0.3.7. nanotime relies on the RcppCCTZ package (as well as the RcppDate package for additional C++ operations) and offers efficient high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it has benefitted greatly from a rigorous refactoring by Leonardo who not only rejigged nanotime
internals in S4 but also added new S4 types for periods, intervals and durations.
This release adds a few more operators, plus some other fixes, that were contributed in several PRs by Trevor Davis. The NEWS snippet has the full details.
Changes in version 0.3.7 (2022-10-23)
Update mkdocs for material docs generator (Dirk in #102)
Use
inherits()
instead comparing toclass()
(Trevor Davis in #104)Set default arguments in
nanoduration()
(Trevor Davis in #105)Add
as.nanoduration.difftime()
support (Trevor Davis in #106)Add +/- methods for
nanotime
anddifftime
objects (Trevor Davis in #110 closing #108, #107)
Thanks to my CRANberries there is also a diff to the previous version. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository – and all documentation is provided at the nanotime documentation site.
If you like this or other open-source work I do, you can now sponsor me at GitHub.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
Leonardo and I are pleased to another update to our nanotime package bringing it to version 0.3.6 which landed on CRAN earlier today.
nanotime relies on the RcppCCTZ package (as well as the RcppDate package for additional C++ operations) and offers efficient high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it has benefitted greatly from a rigorous refactoring by Leonardo who not only rejigged nanotime
internals in S4 but also added new S4 types for periods, intervals and durations.
This release corrects subsetting with %in%
operator, integrates it better fit in the mixed S3/S4 setup, fixes a negative period parse, and updates class comparisons to rely on inherits()
. The NEWS snippet has the full more details.
Changes in version 0.3.6 (2022-03-06)
Thanks to my CRANberries there is also a diff to the previous version. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository – and all documentation is provided at the nanotime documentation site.
If you like this or other open-source work I do, you can now sponsor me at GitHub.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
Another (minor) nanotime release, now at version 0.3.5, just arrived at CRAN. It follows the updates RDieHarder 0.2.3 and RcppCCTZ 0.2.10 earlier today in bringing a patch kindly prepared by Tomas Kalibera for the upcoming (and very useful) ‘UCRT’ changes for Windows involving small build changes for the updated Windows toolchain.
nanotime relies on the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it has benefitted greatly from a rigorous refactoring by Leonardo who not only rejigged nanotime
internals in S4 but also added new S4 types for periods, intervals and durations.
The NEWS snippet adds more details.
Changes in version 0.3.5 (2021-12-14)
- Applied patch by Tomas Kalibera for Windows UCRT under the upcoming R 4.2.0 expected for April.
Thanks to my CRANberries there is also a diff to the previous version. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
If you like this or other open-source work I do, you can now sponsor me at GitHub.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
Another (minor) nanotime release, now at version 0.3.4, arrived at CRAN overnight. It exports some nanoperiod
functionality via a C++ header, and Leonardo and I will use this in an upcoming package that we hope to talk about a little more in a few days. It also adds a few as.character.*()
methods that had not been included before.
nanotime relies on the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it has benefitted greatly from a rigorous refactoring by Leonardo who not only rejigged nanotime
internals in S4 but also added new S4 types for periods, intervals and durations.
The NEWS snippet adds more details.
Changes in version 0.3.4 (2021-11-24)
Thanks to CRANberries there is also a diff to the previous version. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
If you like this or other open-source work I do, you can now sponsor me at GitHub.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
Leonardo and I are pleased to share that a new nanotime version 0.3.3 was released today, and arrived on CRAN. This release brings a new (plotting) demo, an updated documentation site, additional nanoduration
and nanoperiod
functionality, and enhanced testing.
nanotime relies on the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it has benefitted greatly from work by co-author Leonardo who not only rejigged nanotime
internals in S4 but also added new S4 types for periods, intervals and durations.
The NEWS snippet adds full details.
Changes in version 0.3.3 (2021-08-09)
New demo
ggplot2Example.R
(Leonardo and Dirk).New documentation website using mkdocs-material (Dirk).
Updated unit test to account for r-devel POSIXct changes, and re-enable full testing under r-devel (Dirk).
Additional
nanoduration
andcharacter
ops plus tests (Colin Umansky in #88 addressing #87).New
plus
andminus
functions for periods (Leonardo in #91).
Thanks to CRANberries there is also a diff to the previous version. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
If you like this or other open-source work I do, you can now sponsor me at GitHub.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
Another (minor) nanotime release, now at version 0.3.2. This release brings an endianness correction which was kindly contributed in a PR, switches to using the API header exported by RcppCCTZ, and tweaks test coverage a little with respect to r-devel.
nanotime relies on the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it has benefitted greatly from work by co-author Leonardo who not only rejigged nanotime
internals in S4 but also added new S4 types for periods, intervals and durations.
The NEWS snippet adds full details.
Changes in version 0.3.2 (2020-09-03)
Thanks to CRANberries there is also a diff to the previous version. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
If you like this or other open-source work I do, you can now sponsor me at GitHub. For the first year, GitHub will match your contributions.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
The nanotime 0.3.0 release four days ago was so exciting that we decided to do it again! Kidding aside, and fairly extensive tests notwithstanding we were bitten by a few build errors: who knew clang
on macOS needed extra curlies to be happy, another manifestation of Solaris having no idea what a timezone setting “America/New_York” is, plus some extra pickyness from the SAN tests and whatnot. So Leonardo and I gave it some extra care over the weekend, uploaded it late yesterday and here we are with 0.3.1. Thanks again to CRAN for prompt processing even though they are clearly deluged shortly before their (brief) summer break.
nanotime relies on the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it has benefitted greatly from work by Leonardo Silvestri who rejigged internals in S4—and now added new types for periods, intervals and durations.
The NEWS snippet adds full details.
Changes in version 0.3.1 (2020-08-09)
Thanks to CRANberries there is also a diff to the previous version. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
If you like this or other open-source work I do, you can now sponsor me at GitHub. For the first year, GitHub will match your contributions.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
A fresh major release of the nanotime package for working with nanosecond timestamps is hitting CRAN mirrors right now.
nanotime relies on the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it has benefitted greatly from work by Leonardo Silvestri who rejigged internals in S4—and now added new types for periods, intervals and durations. This is what is commonly called a big fucking deal!! So a really REALLY big thank you to my coauthor Leonardo for all these contributions.
With all these Yuge changes patiently chisseled in by Leonardo, it took some time since the last release and a few more things piled up. Matt Dowle corrected something we borked for integration with the lovely and irreplacable data.table. We also switched to the awesome yet minimal tinytest package by Mark van der Loo, and last but not least we added the beginnings of a proper vignette—currently at nine pages but far from complete.
The NEWS snippet adds full details.
Changes in version 0.3.0 (2020-08-06)
Use
tzstr=
instead oftz=
in call to RcppCCTZ::parseDouble()) (Matt Dowle in #49).Add new comparison operators for
nanotime
andcharcters
(Dirk in #54 fixing #52).Switch from RUnit to tinytest (Dirk in #55)
Substantial functionality extension in with new types
nanoduration
,nanoival
andnanoperiod
(Leonardo in #58, #60, #62, #63, #65, #67, #70 fixing #47, #51, #57, #61, #64 with assistance from Dirk).A new (yet still draft-ish) vignette was added describing the four core types (Leonardo and Dirk in #71).
A required compilation flag for Windows was added (Leonardo in #72).
RcppCCTZ function are called in new 'non-throwing' variants to not trigger exeception errors (Leonardo in #73).
We also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
If you like this or other open-source work I do, you can now sponsor me at GitHub. For the first year, GitHub will match your contributions.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
Another minor maintenance release of the nanotime package for working with nanosecond timestamps arrived on CRAN yesterday.
nanotime uses the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it now uses a more rigorous S4-based approach thanks to a rewrite by Leonardo Silvestri.
This release adds the [[
accessor; this had not come up before in direct use or via data.table (which, to its credit, has supported nanotime for years already). But it came up in another usage pattern so we quickly added it as it it really is merely a dispatch to the excellent bit64 package underlying this.
Changes in version 0.2.4 (2019-05-25)
We also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
A minor maintenance release of the nanotime package for working with nanosecond timestamps just arrived on CRAN.
nanotime uses the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it now uses a more rigorous S4-based approach thanks to a rewrite by Leonardo Silvestri.
This release disables some tests on the Slowlaris platform we are asked to conform to (which is a good thing as wider variety of test platforms widens test converage) yet have no real access to (which is bad thing, obviously) beyind what the helpful rhub service offers. We also updated the Travis setup. No code changes.
Changes in version 0.2.3 (2018-09-30)
Skip some tests on Solaris which seems borked with timezones. As we have no real, no fixed possible (Dirk in #42).
Update Travis setup
Once this updates on the next hourly cron
iteration, we also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
A new maintenance release of the nanotime package for working with nanosecond timestamps just arrived on CRAN.
nanotime uses the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it now uses a more rigorous S4-based approach thanks to a rewrite by Leonardo Silvestri.
This release re-disables tests for xts
use. At some point we had hoped a new xts
version would know what nanotime
is. That xts
version is out now, and it doesn’t. Our bad for making that assumption.
Changes in version 0.2.2 (2018-07-18)
We also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
A new minor version of the nanotime package for working with nanosecond timestamps just arrived on CRAN.
nanotime uses the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic. Initially implemented using the S3 system, it now uses a more rigorous S4-based approach thanks to a rewrite by Leonardo Silvestri.
This release brings three different enhancements / fixes that robustify usage. No new features were added.
Changes in version 0.2.1 (2018-07-01)
We also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
A new version of the nanotime package for working with nanosecond timestamps just arrived on CRAN.
nanotime uses the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic.
Thanks to a metric ton of work by Leonardo Silvestri, the package now uses S4 classes internally allowing for greater consistency of operations on nanotime objects.
Changes in version 0.2.0 (2017-06-22)
Rewritten in S4 to provide more robust operations (#17 by Leonardo)
Ensure
tz=""
is treated as unset (Leonardo in #20)Added
format
andtz
arguments tonanotime
,format
,Ensure printing respect
options()$max.print
, ensure names are kept with vector (#23 by Leonardo)Correct
summary()
by definingnames<-
(Leonardo in #25 fixing #24)Report error on operations that are meaningful for type; handled NA, NaN, Inf, -Inf correctly (Leonardo in #27 fixing #26)
We also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
A new minor version of the nanotime package for working with nanosecond timestamps arrived yesterday on CRAN.
nanotime uses the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64
arithmetic.
This release just arranges things neatly before Leonardo Silvestri and I may shake things up with a possible shift to doing it all in S4 as we may need the added rigour for nanotime
object operations for use in his ztsdb project.
Changes in version 0.1.2 (2017-03-27)
- The
as.integer64
function is now exported as well.
We also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
A new version of the nanotime package for working with nanosecond timestamps is now on CRAN.
nanotime uses the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting, and the bit64 package for the actual integer64
arithmetic.
This release adds an improved default display format always showing nine digits of fractional seconds. It also changes the print()
method to call format()
first, and we started to provide some better default Ops
methods. These fixes were suggested by Matt Dowle. We also corrected a small issue which could lead to precision loss in formatting as pointed out by Leonardo Silvestri.
Changes in version 0.1.1 (2017-02-04)
The default display format now always shows nine digits (#10 closing #9)
The default print method was updated to use formated output, and a new new converter
as.integer64
was addedSeveral 'Ops' method are now explicitly defined allowing casting of results (rather than falling back on bit64 behaviour)
The format routine is now more careful about not loosing precision (#13 closing #12)
We also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
Last month, we released nanotime, a package to work with nanosecond timestamps. See the initial release announcement for some background material and a few first examples.
nanotime relies on the RcppCCTZ package for high(er) resolution time parsing and formatting: R itself stops a little short of a microsecond. And it uses the bit64 package for the actual arithmetic: time at this granularity is commonly represented at (integer) increments (at nanosecond resolution) relative to an offset, for which the standard epoch of Januar 1, 1970 is used. int64
types are a perfect match here, and bit64 gives us an integer64
. Naysayers will point out some technical limitations with R's S3 classes, but it works pretty much as needed here.
The one thing we did not have was Windows support. RcppCCTZ and the CCTZ library it uses need real C++11 support, and the g++-4.9
compiler used on Windows falls a little short lacking inter alia a suitable std::get_time()
implementation. Enter Dan Dillon who ported this from LLVM's libc++ which lead to Sunday's RcppCCTZ 0.2.0 release.
And now we have all our ducks in a row: everything works on Windows too. The next paragraph summarizes the changes for both this release as well as the initial one last month:
Changes in version 0.1.0 (2017-01-10)
Added Windows support thanks to expanded RcppCCTZ (closes #6)
Added "mocked up" demo with nanosecond delay networking analysis
Added 'fmt' and 'tz' options to output functions, expanded
format.nanotime
(closing #2 and #3)Added data.frame support
Expanded tests
Changes in version 0.0.1 (2016-12-15)
Initial CRAN upload.
Package is functional and provides examples.
We also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
R has excellent tools for dates and times. The Date
and POSIXct
classes (as well as the 'wide' representation in POSIXlt
) are versatile, and a lot of useful tooling has been built around them.
However, POSIXct
is implemented as a double
with fractional seconds since the epoch. Given the 53 bits accuracy, it leaves just a bit less than microsecond resolution. Which is good enough for most things.
But more and more performance measurements, latency statistics, ... are now measured more finely, and we need nanosecond resolution. For which commonly an integer64
is used to represent nanoseconds since the epoch.
And while R does not a native type for this, the bit64 package by Jens Oehlschlägel offers a performant one implemented as a lightweight S3 class. So this package uses this integer64
class, along with two helper functions for parsing and formatting, respectively, at nano-second resolution from the RcppCCTZ package which wraps the CCTZ library from Google. CCTZ is a modern C++11 library extending the (C++11-native) chrono
type.
R> x <- nanotime("1970-01-01T00:00:00.000000001+00:00")
R> print(x)
integer64
[1] 1
R> format(x)
[1] "1970-01-01T00:00:00.000000001+00:00"
R> cat("x+1 is: ")
x+1 is: R> x <- x + 1
R> print(x)
integer64
[1] 2
R> format(x)
[1] "1970-01-01T00:00:00.000000002+00:00"
R>
R> options("width"=60)
R> v <- nanotime(Sys.time()) + 1:5
R> v
integer64
[1] 1481505724483583001 1481505724483583002
[3] 1481505724483583003 1481505724483583004
[5] 1481505724483583005
R> format(v)
[1] "2016-12-12T01:22:04.483583001+00:00"
[2] "2016-12-12T01:22:04.483583002+00:00"
[3] "2016-12-12T01:22:04.483583003+00:00"
[4] "2016-12-12T01:22:04.483583004+00:00"
[5] "2016-12-12T01:22:04.483583005+00:00"
R>
zoo
R> z <- zoo(cbind(A=1:5, B=5:1), v)
R> options("nanotimeFormat"="%d %b %H:%M:%E*S") ## override default
R> z
A B
12 Dec 01:47:55.812513001 1 5
12 Dec 01:47:55.812513002 2 4
12 Dec 01:47:55.812513003 3 3
12 Dec 01:47:55.812513004 4 2
12 Dec 01:47:55.812513005 5 1
R>
The bit64 package (by Jens Oehlschlägel) supplies the integer64
type used to store the nanosecond resolution time as (positive or negative) offsets to the epoch of January 1, 1970. The RcppCCTZ package supplies the formatting and parsing routines based on the (modern C++) library CCTZ from Google.
Version 0.0.1 has now been released. It works with some other packages, notably zoo and data.table.
It (at least currently) requires RcppCCTZ to parse and format nanosecond resolution time objects from / to text --- and this package is on Linux and OS X only due to its use of system time zoneinfo. The requirement could be relaxed in the future by rewriting formating and parsing code. Contributions are welcome.
The package is not yet on CRAN. Until it gets there, or to install the development versions, it can also be installed via a standard
install.packages("RcppCCTZ") # need 0.1.0 or later
remotes::install_github("eddelbuettel/nanotime")
If you prefer install.packages()
(as I do), use the version from the ghrr drat:
install.packages("drat") # easier repo access + creation
drat:::add("ghrr") # make it known
install.packages("nanotime") # install it
If and when it gets to CRAN you will be able to do
install.packages("nanotime")
For questions or comments use the issue tracker off the GitHub repo.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.