Skip to content

Commit

Permalink
use notOk(.) instead of !identical(., NA) when checking world clock; …
Browse files Browse the repository at this point in the history
…re-enable "old" http: variant

git-svn-id: https://svn.r-project.org/R/trunk@87710 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Feb 10, 2025
1 parent 9e4828a commit e9dee3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}.
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/library/tools/R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -521,14 +521,15 @@ 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))
## gives time in sub-secs
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))
Expand All @@ -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))
Expand All @@ -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 {
Expand Down Expand Up @@ -1292,7 +1293,7 @@ add_dummies <- function(dir, Log)
"\n")
}
}

if (!any) resultLog(Log, "OK")
## return (<never used in caller>):
db
Expand Down

0 comments on commit e9dee3d

Please sign in to comment.