From b9eb4f9223db9c324b3f335320c0427050ad00da Mon Sep 17 00:00:00 2001 From: Thomas Neitmann Date: Thu, 29 Sep 2022 10:51:11 +0200 Subject: [PATCH 1/2] Pre-release v0.8.2 Co-authored-by: Ben Straub --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ tests/testthat/test-user_helpers.R | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4136f1ee34..f6a758abdc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: admiral Type: Package Title: ADaM in R Asset Library -Version: 0.8.1 +Version: 0.8.2 Authors@R: c( person("Thomas", "Neitmann", email = "thomas.neitmann@roche.com", role = c("aut", "cre")), person("Stefan", "Bundfuss", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 1a0eaa67ff..10a3e9e563 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# admiral 0.8.2 + +- Fixed an issue where CRAN identified a failing test when "a strict Latin-1* locale" is used. (#1469) + # admiral 0.8.1 - `derive_var_extreme_dt()` and `derive_var_extreme_dtm()` were updated such diff --git a/tests/testthat/test-user_helpers.R b/tests/testthat/test-user_helpers.R index 867fc7f410..e39d9c99b7 100644 --- a/tests/testthat/test-user_helpers.R +++ b/tests/testthat/test-user_helpers.R @@ -65,8 +65,8 @@ test_that("`adam_templates` objects are printed as intended: some templates", { structure(class = c("adam_templates", "character"), package = "admiral") expected_print_output <- c( "Existing ADaM templates in package 'admiral':", - "• ADAE", - "• ADSL" + "\U2022 ADAE", + "\U2022 ADSL" ) expect_identical(capture.output(print(templates)), expected_print_output) }) From 108df481ef2169c2bbb505171c7b316ec620b9ce Mon Sep 17 00:00:00 2001 From: Thomas Neitmann Date: Fri, 7 Oct 2022 07:23:13 +0200 Subject: [PATCH 2/2] Pre-release v0.8.3 Co-authored-by: Ben Straub --- DESCRIPTION | 2 +- NEWS.md | 7 ++++++- R/compute_duration.R | 22 ++++++++++++++++++---- R/user_helpers.R | 3 ++- README.md | 1 + tests/testthat/test-user_helpers.R | 4 ++-- 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f6a758abdc..67a5bb9356 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: admiral Type: Package Title: ADaM in R Asset Library -Version: 0.8.2 +Version: 0.8.3 Authors@R: c( person("Thomas", "Neitmann", email = "thomas.neitmann@roche.com", role = c("aut", "cre")), person("Stefan", "Bundfuss", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 10a3e9e563..f02b80b395 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,11 @@ +# admiral 0.8.3 + +- Second attempt to address issue where CRAN identified a failing test when "a strict Latin-1* locale" is used (#1469) +- Fixed a bug in `derive_vars_duration()` that surfaced after changes in R-devel (#1486) + # admiral 0.8.2 -- Fixed an issue where CRAN identified a failing test when "a strict Latin-1* locale" is used. (#1469) +- Fixed an issue where CRAN identified a failing test when "a strict Latin-1* locale" is used (#1469) # admiral 0.8.1 diff --git a/R/compute_duration.R b/R/compute_duration.R index bbf808c83f..9b60838349 100644 --- a/R/compute_duration.R +++ b/R/compute_duration.R @@ -127,10 +127,24 @@ compute_duration <- function(start_date, # Derivation if (floor_in) { - # remove information more precise than the input unit, e.g., if input unit - # is days, the time part of the dates is removed. - start_date <- floor_date(start_date, unit = in_unit) - end_date <- floor_date(end_date, unit = in_unit) + # Remove information more precise than the input unit, e.g., if input unit + # is days, the time part of the dates is removed. After updates in R `NA` + # values have to be explicitly handled here because otherwise + # `floor_date(as.Date(NA), unit = "days")` will return `"1970-01-01"` rather + # than `NA` (#1486). See also here: + # https://github.com/tidyverse/lubridate/issues/1069 + start_date_fun <- if (is.Date(start_date)) as.Date else as.POSIXct + end_date_fun <- if (is.Date(end_date)) as.Date else as.POSIXct + start_date <- if_else( + is.na(start_date), + start_date_fun(NA), + floor_date(start_date, unit = in_unit) + ) + end_date <- if_else( + is.na(end_date), + end_date_fun(NA), + floor_date(end_date, unit = in_unit) + ) } # derive the duration in the output unit diff --git a/R/user_helpers.R b/R/user_helpers.R index 0a19aafd8e..a448c429bc 100644 --- a/R/user_helpers.R +++ b/R/user_helpers.R @@ -123,6 +123,7 @@ print.adam_templates <- function(x, ...) { cat("No ADaM templates available in package '", pkg, "'\n", sep = "") } else { cat("Existing ADaM templates in package '", pkg, "':\n", sep = "") - cat(paste0("\U2022 ", x), sep = "\n") + bullet <- if (is.na(iconv("\U2022"))) "-" else "\U2022" + cat(paste(bullet, x), sep = "\n") } } diff --git a/README.md b/README.md index 4df87fcadc..a58c3af076 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ if (!requireNamespace("remotes", quietly = TRUE)) { } remotes::install_github("pharmaverse/admiral.test", ref = "devel") # This is a required dependency of {admiral} +remotes::install_github("pharmaverse/admiraldev", ref = "devel") # This is a required dependency of {admiral} remotes::install_github("pharmaverse/admiral", ref = "devel") ``` diff --git a/tests/testthat/test-user_helpers.R b/tests/testthat/test-user_helpers.R index e39d9c99b7..48db7d35a6 100644 --- a/tests/testthat/test-user_helpers.R +++ b/tests/testthat/test-user_helpers.R @@ -65,8 +65,8 @@ test_that("`adam_templates` objects are printed as intended: some templates", { structure(class = c("adam_templates", "character"), package = "admiral") expected_print_output <- c( "Existing ADaM templates in package 'admiral':", - "\U2022 ADAE", - "\U2022 ADSL" + if (is.na(iconv("\U2022"))) "- ADAE" else "\U2022 ADAE", + if (is.na(iconv("\U2022"))) "- ADSL" else "\U2022 ADSL" ) expect_identical(capture.output(print(templates)), expected_print_output) })