diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index effe9a6bd2..461248ef80 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -538,14 +538,14 @@ \code{summary()} method results, and it is documented explicitly. \item \code{options(show.error.locations = TRUE)} once - again shows the most recent known location when an - error is reported. Setting its value to \code{"bottom"} + again shows the most recent known location when an + error is reported. Setting its value to \code{"bottom"} is no longer supported. Numerical values are converted to logical. \item C API function \code{R_GetCurrentSrcref(skip)} now returns \code{srcref} entries correctly. (Note that there - is also a change to the interpretation of \code{skip}; + is also a change to the interpretation of \code{skip}; see the C-LEVEL API entry above.) \item \code{tools::Rd2latex()} now removes leading and trailing @@ -558,6 +558,10 @@ \item The argument of \code{as.environment()} is named \code{x} now, not \code{object}, as it was always documented and shown when printing it; thanks to \I{Gael Millot}'s \PR{18849}. + + \item When \command{R CMD check} aims at getting the time+date from a + world clock, it is more robust against unexpected non-error results, + thanks to \I{Michael Chirico}'s \PR{18852}. } } } diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index d44a8c1255..3380924863 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -521,6 +521,7 @@ add_dummies <- function(dir, Log) if(config_val_to_logical(Sys.getenv("_R_CHECK_SYSTEM_CLOCK_", "TRUE"))) { ## First check time on system running 'check', ## by reading an external source in UTC + notOK <- function(t) !length(t) || is.na(t[1]) # seen length > 1 now <- tryCatch({ foo <- suppressWarnings(readLines("https://worldtimeapi.org/api/timezone/etc/UTC", warn = FALSE)) @@ -528,7 +529,7 @@ add_dummies <- function(dir, Log) as.POSIXct(gsub(".*\"datetime\":\"([^Z]*).*", "\\1", foo), "UTC", "%Y-%m-%dT%H:%M:%S") }, error = function(e) NA) - if(identical(NA, now)) { # try http (no 's') + if(notOK(now)) { # try http (no 's') now <- tryCatch({ foo <- suppressWarnings(readLines("http://worldtimeapi.org/api/timezone/etc/UTC", warn = FALSE)) @@ -537,7 +538,7 @@ add_dummies <- function(dir, Log) "UTC", "%Y-%m-%dT%H:%M:%S") }, error = function(e) NA) } - if (FALSE && identical(NA, now)) { ## seems permanently stopped + if(notOK(now)) { ## seemed permanently stopped, yet works 2025-02-08 and *-*-09 now <- tryCatch({ foo <- suppressWarnings(readLines("http://worldclockapi.com/api/json/utc/now", warn = FALSE)) @@ -546,7 +547,7 @@ add_dummies <- function(dir, Log) "UTC", "%Y-%m-%dT%H:%M") }, error = function(e) NA) } - if(identical(NA, now)) { + if(notOK(now)) { any <- TRUE noteLog(Log, "unable to verify current time") } else { @@ -1292,7 +1293,7 @@ add_dummies <- function(dir, Log) "\n") } } - + if (!any) resultLog(Log, "OK") ## return (): db