Version 0.0.5 of RcppCCTZ arrived on CRAN a couple of days ago. It reflects an upstream fixed made a few weeks ago. CRAN tests revealed that
g++-6 was tripping over one missing
#define; this was added upstream and I subsequently synchronized with upstream. At the same time the set of examples was extended (see below).
Somehow useR! 2016 got in the way and while working on the then-incomplete examples during the traveling I forgot to release this until CRAN reminded me that their tests still failed. I promptly prepared the 0.0.5 release but somehow failed to update NEWS files etc. They are correct in the repo but not in the shipped package. Oh well.
CCTZ is a C++ library for translating between absolute and civil times using the rules of a time zone. In fact, it is two libraries. One for dealing with civil time: human-readable dates and times, and one for converting between between absolute and civil times via time zones. It requires only a proper C++11 compiler and the standard IANA time zone data base which standard Unix, Linux, OS X, … computers tend to have in
/usr/share/zoneinfo. RcppCCTZ connects this library to R by relying on Rcpp.
Two good examples are now included, and shown here. The first one tabulates the time difference between New York and London (at a weekly level for compactness):
R> example(tzDiff) tzDiffR> # simple call: difference now tzDiffR> tzDiff("America/New_York", "Europe/London", Sys.time())  5 tzDiffR> # tabulate difference for every week of the year tzDiffR> table(sapply(0:52, function(d) tzDiff("America/New_York", "Europe/London", tzDiff+ as.POSIXct(as.Date("2016-01-01") + d*7)))) 4 5 3 50 R>
Because the two continents happen to spring forward and fall backwards between regular and daylight savings times, there are, respectively, two and one week periods where the difference is one hour less than usual.
A second example shifts the time to a different time zone:
R> example(toTz) toTzR> toTz(Sys.time(), "America/New_York", "Europe/London")  "2016-07-14 10:28:39.91740 CDT" R>
Note that because we return a
POSIXct object, it is printed by R with the default (local) TZ attribute (for “America/Chicago” in my case). A more direct example asks what time it is in my time zone when it is midnight in Tokyo:
R> toTz(ISOdatetime(2016,7,15,0,0,0), "Japan", "America/Chicago")  "2016-07-14 15:00:00 CDT" R>
More changes will come in 0.0.6 as soon as I find time to translate the nice
time_tool (command-line) example into an R function.
Changes in this version are summarized here:
Changes in version 0.0.5 (2016-07-09)
New utility example functions
Synchronized with small upstream change for additional
#ifdeffor compiler differentiation