diff -Nru r-cran-nanotime-0.3.5/ChangeLog r-cran-nanotime-0.3.6/ChangeLog --- r-cran-nanotime-0.3.5/ChangeLog 2021-12-14 13:27:50.000000000 +0000 +++ r-cran-nanotime-0.3.6/ChangeLog 2022-03-06 17:52:45.000000000 +0000 @@ -1,6 +1,21 @@ +2021-03-06 Leonardo Silvestri + + * DESCRIPTION (Version, Date): Release 0.3.6 + * R/nanoival.R: Fix incorrect subsetting with operator `%in%` + * NAMESPACE: Added export + * man/set_operations.Rd: Added file + * src/period.cpp: Fix parse of negative period + +2022-03-06 Dirk Eddelbuettel + + * R/nanoduration.R: Use 'inherits()' instead of 'class() ==' + * R/nanoival.R: Idem + * R/nanoperiod.R: Idem + * R/nanotime.R: Idem + 2021-12-14 Dirk Eddelbuettel - * DESCRIPTION (Version, Date): Release 0.3.4 + * DESCRIPTION (Version, Date): Release 0.3.5 2021-12-09 Dirk Eddelbuettel @@ -9,7 +24,7 @@ 2021-11-23 Dirk Eddelbuettel - * DESCRIPTION (Version, Date): Release 0.3.3 + * DESCRIPTION (Version, Date): Release 0.3.4 2021-11-21 Dirk Eddelbuettel diff -Nru r-cran-nanotime-0.3.5/debian/changelog r-cran-nanotime-0.3.6/debian/changelog --- r-cran-nanotime-0.3.5/debian/changelog 2021-12-15 05:31:58.000000000 +0000 +++ r-cran-nanotime-0.3.6/debian/changelog 2022-03-06 19:28:12.000000000 +0000 @@ -1,3 +1,9 @@ +r-cran-nanotime (0.3.6-1) unstable; urgency=medium + + * New upstream release + + -- Dirk Eddelbuettel Sun, 06 Mar 2022 13:28:12 -0600 + r-cran-nanotime (0.3.5-1) unstable; urgency=medium * New upstream release diff -Nru r-cran-nanotime-0.3.5/DESCRIPTION r-cran-nanotime-0.3.6/DESCRIPTION --- r-cran-nanotime-0.3.5/DESCRIPTION 2021-12-15 03:50:11.000000000 +0000 +++ r-cran-nanotime-0.3.6/DESCRIPTION 2022-03-06 18:30:02.000000000 +0000 @@ -1,8 +1,8 @@ Package: nanotime Type: Package Title: Nanosecond-Resolution Time Support for R -Version: 0.3.5 -Date: 2021-12-14 +Version: 0.3.6 +Date: 2022-03-06 Author: Dirk Eddelbuettel and Leonardo Silvestri Maintainer: Dirk Eddelbuettel Description: Full 64-bit resolution date and time functionality with @@ -14,6 +14,7 @@ LinkingTo: Rcpp, RcppCCTZ, RcppDate License: GPL (>= 2) URL: https://github.com/eddelbuettel/nanotime, + https://eddelbuettel.github.io/nanotime/, https://dirk.eddelbuettel.com/code/nanotime.html BugReports: https://github.com/eddelbuettel/nanotime/issues RoxygenNote: 7.1.2 @@ -21,6 +22,6 @@ 'RcppExports.R' Encoding: UTF-8 NeedsCompilation: yes -Packaged: 2021-12-14 13:29:33 UTC; edd +Packaged: 2022-03-06 17:53:20 UTC; edd Repository: CRAN -Date/Publication: 2021-12-15 03:50:11 UTC +Date/Publication: 2022-03-06 18:30:02 UTC Binary files /tmp/tmp7c7jtg31/zMNb46Jzda/r-cran-nanotime-0.3.5/inst/doc/nanotime-introduction.pdf and /tmp/tmp7c7jtg31/eXmemEp9N3/r-cran-nanotime-0.3.6/inst/doc/nanotime-introduction.pdf differ diff -Nru r-cran-nanotime-0.3.5/inst/NEWS.Rd r-cran-nanotime-0.3.6/inst/NEWS.Rd --- r-cran-nanotime-0.3.5/inst/NEWS.Rd 2021-12-14 13:28:48.000000000 +0000 +++ r-cran-nanotime-0.3.6/inst/NEWS.Rd 2022-03-06 17:37:07.000000000 +0000 @@ -3,6 +3,15 @@ \newcommand{\ghpr}{\href{https://github.com/eddelbuettel/nanotime/pull/#1}{##1}} \newcommand{\ghit}{\href{https://github.com/eddelbuettel/nanotime/issues/#1}{##1}} +\section{Changes in version 0.3.6 (2022-03-06)}{ + \itemize{ + \item Fix incorrect subsetting with operator \code{\%in\%} (Leonardo + in \ghpr{100} fixing \ghit{99}). + \item Fix incorrect parsing for negative nanoperiod (Leonardo in + \ghpr{100} fixing \ghit{96}). + } +} + \section{Changes in version 0.3.5 (2021-12-14)}{ \itemize{ \item Applied patch by Tomas Kalibera for Windows UCRT under the diff -Nru r-cran-nanotime-0.3.5/inst/tinytest/test_nanoperiod.R r-cran-nanotime-0.3.6/inst/tinytest/test_nanoperiod.R --- r-cran-nanotime-0.3.5/inst/tinytest/test_nanoperiod.R 2021-10-13 13:35:28.000000000 +0000 +++ r-cran-nanotime-0.3.6/inst/tinytest/test_nanoperiod.R 2022-03-06 17:15:17.000000000 +0000 @@ -38,6 +38,10 @@ expect_identical(as.character(as.nanoperiod("1w/00:01:01")), "0m7d/00:01:01") expect_identical(names(as.nanoperiod(c(a="1m"))), "a") +## check negative duration +expect_identical(as.nanoperiod("-00:00:01"), as.nanoperiod(as.nanoduration("-00:00:01"))) +expect_identical(as.nanoperiod("-0:00:01"), as.nanoperiod(as.nanoduration("-00:00:01"))) + ##test_as.nanoperiod_character_error <- function() { expect_error(as.nanoperiod("1wm00:01:01"), "cannot parse nanoperiod") expect_error(as.nanoperiod("1ym00:01:01"), "cannot parse nanoperiod") diff -Nru r-cran-nanotime-0.3.5/man/set_operations.Rd r-cran-nanotime-0.3.6/man/set_operations.Rd --- r-cran-nanotime-0.3.5/man/set_operations.Rd 2020-09-01 16:16:37.000000000 +0000 +++ r-cran-nanotime-0.3.6/man/set_operations.Rd 2022-03-06 17:15:17.000000000 +0000 @@ -7,6 +7,7 @@ \alias{intersect.idx,nanotime,nanoival-method} \alias{intersect.idx} \alias{\%in\%.nanotime} +\alias{\%in\%,nanotime,nanoival-method} \alias{intersect,nanotime,nanoival-method} \alias{setdiff,nanotime,nanoival-method} \alias{setdiff.idx,nanotime,nanoival-method} @@ -26,6 +27,8 @@ \method{\%in\%}{nanotime}(x, table) +\S4method{\%in\%}{nanotime,nanoival}(x, table) + \S4method{intersect}{nanotime,nanoival}(x, y) \S4method{setdiff}{nanotime,nanoival}(x, y) diff -Nru r-cran-nanotime-0.3.5/MD5 r-cran-nanotime-0.3.6/MD5 --- r-cran-nanotime-0.3.5/MD5 2021-12-15 03:50:11.000000000 +0000 +++ r-cran-nanotime-0.3.6/MD5 2022-03-06 18:30:02.000000000 +0000 @@ -1,20 +1,20 @@ -c668b1dd83e336cd29accaba26eb156e *ChangeLog -b2a10d3723db13b2489d5d22c154b2f8 *DESCRIPTION -5f4a803bb0fd0fc4233c8fa20406bf2b *NAMESPACE +fd058ef642d25b4682f01c61e825037e *ChangeLog +6c300c2cb17e432fdb3c6ffc3a434678 *DESCRIPTION +13b69ea4df4fda6eda80d499fee574a8 *NAMESPACE d0e5f558664e47ad9849a0a8c0917c4f *R/RcppExports.R -5914d0dd759e6e9e0a6b0c251d446183 *R/nanoduration.R -4e695d476edf40ebf85d197420e62fff *R/nanoival.R -f6f7566cbb8719cb4c26904c5934c30a *R/nanoperiod.R -860385050a39269aeaa57f3e49f147b3 *R/nanotime.R -9bf6ffdc8a815ec51b6907554f5b3cb8 *README.md +4304602dffa9fd24c70d16fedb343ccb *R/nanoduration.R +40fd54cb15c037aa4439f4e0ed572363 *R/nanoival.R +bf48ab606ed0227756fc5fe0294ea7a3 *R/nanoperiod.R +acd1542d7b0c7849eab9da6f9d44530d *R/nanotime.R +15f30401c69222a849bb4e75012d0130 *README.md aa8dadaa5f20d440852b1e5c821b8575 *build/vignette.rds 5e2d19193e19de97094be5c8e1475da1 *cleanup e891df765a0a3b337fe656e18bd2ac5f *demo/00Index 96a72e2a6d51ab7ddf927a6b57e03463 *demo/ggplot2Example.R 524ee00e164d537a07a28be1f0cfb8ee *demo/nanosecondDelayExample.R -8015dde0bedeb069ac9c20d2ae48a8aa *inst/NEWS.Rd +9ea4e30fe9fb6ea99da044fe1287bb62 *inst/NEWS.Rd f6411e74660ca98c5c9c0f6a3684cf21 *inst/doc/nanotime-introduction.Rnw -5d18a4080f55a389ea8ff0459601bf90 *inst/doc/nanotime-introduction.pdf +853c9a566f3b91a24df8fe98a851f012 *inst/doc/nanotime-introduction.pdf adef692683d6f7ce9ffee8b6865d25ec *inst/include/nanotime/duration.hpp a9a428be2c0d0c284a7bc45639e3b6a0 *inst/include/nanotime/globals.hpp 70ff665fe75f9471a41ca39926b6caa1 *inst/include/nanotime/interval.hpp @@ -25,7 +25,7 @@ 40a0ec652117210b75f2615b69e5b69d *inst/tinytest/test_data.table.R e81ecb4d8b0f462cf716e1cc6feda47f *inst/tinytest/test_nanoduration.R 5ea87d640a31b8a0e83024330208d1d4 *inst/tinytest/test_nanoival.R -536e3fff861541633d884afc254e116c *inst/tinytest/test_nanoperiod.R +f253c2790b8ba8b24ed75c930dc13eb5 *inst/tinytest/test_nanoperiod.R f04c5c10243d72ed18c5b49167d1aeec *inst/tinytest/test_nanotime.R c0e44816ea79a16af48d3568a1a763c9 *inst/tinytest/test_ops.R 985688e5b84e698baddf7b7e013194ea *inst/tinytest/test_xts.R @@ -49,7 +49,7 @@ 91b842a9b6b872593dd936ae6601d42b *man/seq-nanoival-method.Rd dc0abaddeca76a45f2c7bfecc8f4b89b *man/seq.nanoduration.Rd 85133c918e850455542a54660f211c6d *man/seq.nanotime.Rd -31eef92a28fda4dbc5b7b95ffa791371 *man/set_operations.Rd +78f5cf6b044e00166c73e165e82d20d5 *man/set_operations.Rd 28ff2a81b9f145882a904c265ca8b56d *man/sort-nanoival-method.Rd 4a5cfbe0ef328b4a4e142e74dae49074 *src/Makevars 7b9ece8073039677486a297b6597df26 *src/Makevars.ucrt @@ -58,7 +58,7 @@ 335131307ca491c6a7fd435f65028f16 *src/duration.cpp b00194feaa12a82aba6b46642795971a *src/interval.cpp dc36c0c1a7b65733dcbd75e3d2d58493 *src/nanotime.cpp -eb0b6a1150a6cb94f68bda715970ad1c *src/period.cpp +03717c954e6a1c19a38b6c547524ce00 *src/period.cpp ed8fe9cef2698c95c4109862a5a02e37 *src/rounding.cpp 4ce68f543c2378a92e4940c057e825fe *src/strnlen.cpp 22fdad0781464eb37925e754e70a041a *tests/POSIXt.R diff -Nru r-cran-nanotime-0.3.5/NAMESPACE r-cran-nanotime-0.3.6/NAMESPACE --- r-cran-nanotime-0.3.5/NAMESPACE 2021-10-13 13:35:28.000000000 +0000 +++ r-cran-nanotime-0.3.6/NAMESPACE 2022-03-06 17:15:17.000000000 +0000 @@ -112,5 +112,5 @@ exportMethods(nano_ceiling) exportMethods(nano_floor) -export("%in%.nanotime") S3method("%in%", nanotime) +exportMethods("%in%") diff -Nru r-cran-nanotime-0.3.5/R/nanoduration.R r-cran-nanotime-0.3.6/R/nanoduration.R --- r-cran-nanotime-0.3.5/R/nanoduration.R 2021-10-13 13:35:28.000000000 +0000 +++ r-cran-nanotime-0.3.6/R/nanoduration.R 2022-03-06 17:49:20.000000000 +0000 @@ -649,8 +649,8 @@ ## we have to redefine 'all.equal.nanotime' and it is correct for ## all 'integer64'-based S4 classes; in theory they would all ## three be the same function: - if (class(target) == "nanoduration") target <- as.nanotime(target) - if (class(current) == "nanoduration") current <- as.nanotime(current) + if (inherits(target, "nanoduration")) target <- as.nanotime(target) + if (inherits(current, "nanoduration")) current <- as.nanotime(current) all.equal.nanotime(target, current, tolerance, scale, countEQ, formatFUN, ..., check.attributes=check.attributes) } @@ -666,7 +666,7 @@ ##' @rdname rounding setMethod("nano_ceiling", c(x="nanotime", precision="nanoduration"), function(x, precision, origin=nanotime()) { - if (class(origin) != "nanotime") { + if (!inherits(origin, "nanotime")) { stop("'origin' must be of class 'nanotime'") } ceiling_impl(x, precision, origin) @@ -675,7 +675,7 @@ ##' @rdname rounding setMethod("nano_floor", c(x="nanotime", precision="nanoduration"), function(x, precision, origin=nanotime()) { - if (class(origin) != "nanotime") { + if (!inherits(origin, "nanotime")) { stop("'origin' must be of class 'nanotime'") } floor_impl(x, precision, origin) diff -Nru r-cran-nanotime-0.3.5/R/nanoival.R r-cran-nanotime-0.3.6/R/nanoival.R --- r-cran-nanotime-0.3.5/R/nanoival.R 2021-10-13 13:35:28.000000000 +0000 +++ r-cran-nanotime-0.3.6/R/nanoival.R 2022-03-06 17:46:02.000000000 +0000 @@ -739,9 +739,9 @@ ##' @rdname set_operations -##' @aliases %in%.nanotime +##' @method %in% nanotime `%in%.nanotime` <- function(x, table) { - if (class(table) == "nanoival") { + if (inherits(table, "nanoival")) { if (is.unsorted(x)) stop("x must be sorted") table <- sort(table) nanoival_intersect_idx_time_interval_logical_impl(x, table) @@ -750,15 +750,14 @@ } } -## ##' @rdname set_operations -## ##' @aliases %in%,nanotime,nanoival-method -## setMethod("%in%", -## c("nanotime", "nanoival"), -## function(x, table) { -## if (is.unsorted(x)) stop("x must be sorted") -## table <- sort(table) -## nanoival_intersect_idx_time_interval_logical_impl(x, table) -## }) +##' @rdname set_operations +setMethod("%in%", + c("nanotime", "nanoival"), + function(x, table) { + if (is.unsorted(x)) stop("x must be sorted") ## #nocov + table <- sort(table) ## #nocov + nanoival_intersect_idx_time_interval_logical_impl(x, table) ## #nocov + }) ##' @rdname set_operations setMethod("intersect", diff -Nru r-cran-nanotime-0.3.5/R/nanoperiod.R r-cran-nanotime-0.3.6/R/nanoperiod.R --- r-cran-nanotime-0.3.5/R/nanoperiod.R 2021-10-11 17:52:17.000000000 +0000 +++ r-cran-nanotime-0.3.6/R/nanoperiod.R 2022-03-06 17:48:29.000000000 +0000 @@ -740,7 +740,7 @@ ##' @param tz a \code{character} scalar indicating the time zone in which to conduct the rounding setMethod("nano_ceiling", c(x="nanotime", precision="nanoperiod"), function(x, precision, origin=nanotime(), tz) { - if (class(origin) != "nanotime") { + if (!inherits(origin, "nanotime")) { stop("'origin' must be of class 'nanotime'") } if (!is.character(tz)) { @@ -755,7 +755,7 @@ ##' @rdname rounding setMethod("nano_floor", c(x="nanotime", precision="nanoperiod"), function(x, precision, origin=nanotime(), tz) { - if (class(origin) != "nanotime") { + if (!inherits(origin, "nanotime")) { stop("'origin' must be of class 'nanotime'") } if (!is.character(tz)) { diff -Nru r-cran-nanotime-0.3.5/R/nanotime.R r-cran-nanotime-0.3.6/R/nanotime.R --- r-cran-nanotime-0.3.5/R/nanotime.R 2021-10-13 13:35:28.000000000 +0000 +++ r-cran-nanotime-0.3.6/R/nanotime.R 2022-03-06 17:50:27.000000000 +0000 @@ -492,7 +492,7 @@ ##' @rdname nanotime setMethod("Compare", c("nanotime", "ANY"), function(e1, e2) { - if (class(e2) == "nanotime") { + if (inherits(e2, "nanotime")) { e2 <- S3Part(e2, strictS3=TRUE) } callNextMethod(S3Part(e1, strictS3=TRUE), e2) @@ -704,7 +704,7 @@ stop("'by' must be specified if 'length.out' is NULL") else { # dealing with 'by' if (length(by) != 1L) stop("'by' must be of length 1") - if (class(by) == "nanoperiod") { + if (inherits(by, "nanoperiod")) { ## fish out the 'tz' parameter: args <- list(...) if (!any("tz" %in% names(args))) { @@ -727,7 +727,7 @@ } else if (missing(to) || is.null(to)) { if (length(by) != 1L) stop("'by' must be of length 1") - if (class(by) == "nanoperiod") { + if (inherits(by, "nanoperiod")) { ## fish out the 'tz' parameter: args <- list(...) if (!any("tz" %in% names(args))) { @@ -784,8 +784,8 @@ all.equal.nanotime <- function(target, current, tolerance = sqrt(.Machine$double.eps), scale = NULL, countEQ = FALSE, formatFUN = function(err, what) format(err), ..., check.attributes = TRUE) { - if (class(target) == "nanotime") target <- as.integer64(target) - if (class(current) == "nanotime") current <- as.integer64(current) + if (inherits(target, "nanotime")) target <- as.integer64(target) + if (inherits(current, "nanotime")) current <- as.integer64(current) if (!is.numeric(tolerance)) stop("'tolerance' should be numeric") diff -Nru r-cran-nanotime-0.3.5/README.md r-cran-nanotime-0.3.6/README.md --- r-cran-nanotime-0.3.5/README.md 2021-11-24 00:24:27.000000000 +0000 +++ r-cran-nanotime-0.3.6/README.md 2021-12-22 14:43:54.000000000 +0000 @@ -5,7 +5,7 @@ [![CRAN](https://www.r-pkg.org/badges/version/nanotime)](https://cran.r-project.org/package=nanotime) [![Dependencies](https://tinyverse.netlify.com/badge/nanotime)](https://cran.r-project.org/package=nanotime) [![Downloads](https://cranlogs.r-pkg.org/badges/nanotime?color=brightgreen)](https://www.r-pkg.org/pkg/nanotime) -[![Code Coverage](https://app.codecov.io/gh/eddelbuettel/nanotime/graph/badge.svg)](https://app.codecov.io/gh/eddelbuettel/nanotime) +[![Code Coverage](https://codecov.io/gh/eddelbuettel/nanotime/graph/badge.svg)](https://app.codecov.io/gh/eddelbuettel/nanotime) [![Last Commit](https://img.shields.io/github/last-commit/eddelbuettel/nanotime)](https://github.com/eddelbuettel/nanotime) [![Documentation](https://img.shields.io/badge/documentation-is_here-blue)](https://eddelbuettel.github.io/nanotime/) diff -Nru r-cran-nanotime-0.3.5/src/period.cpp r-cran-nanotime-0.3.6/src/period.cpp --- r-cran-nanotime-0.3.5/src/period.cpp 2021-11-21 22:28:48.000000000 +0000 +++ r-cran-nanotime-0.3.6/src/period.cpp 2022-03-06 17:15:17.000000000 +0000 @@ -42,7 +42,13 @@ dur = std::chrono::seconds(0); int n; - if (s < e && (*s == '/' || (s+2 < e && s[2] == ':'))) goto getduration; + if (s < e && (*s == '/' || (*s != '-' && s+2 < e && s[2] == ':'))) goto getduration; + // test the case where we have only a negative duration: + if (s < e && *s == '-' && + ((s+3 < e && s[3] == ':') || (s+2 < e && s[2] == ':'))) { + --s; // because getduration will increment it + goto getduration; + } if (!readNumber(s, e, n, true) || s == e) throw std::range_error("cannot parse nanoperiod"); if (*s == 'y') { months += 12*n;