Skip to content

Commit e9dee3d

Browse files
author
maechler
committed
use notOk(.) instead of !identical(., NA) when checking world clock; re-enable "old" http: variant
git-svn-id: https://svn.r-project.org/R/trunk@87710 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 9e4828a commit e9dee3d

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/NEWS.Rd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,14 @@
538538
\code{summary()} method results, and it is documented explicitly.
539539
540540
\item \code{options(show.error.locations = TRUE)} once
541-
again shows the most recent known location when an
542-
error is reported. Setting its value to \code{"bottom"}
541+
again shows the most recent known location when an
542+
error is reported. Setting its value to \code{"bottom"}
543543
is no longer supported. Numerical values are converted
544544
to logical.
545545
546546
\item C API function \code{R_GetCurrentSrcref(skip)} now
547547
returns \code{srcref} entries correctly. (Note that there
548-
is also a change to the interpretation of \code{skip};
548+
is also a change to the interpretation of \code{skip};
549549
see the C-LEVEL API entry above.)
550550
551551
\item \code{tools::Rd2latex()} now removes leading and trailing
@@ -558,6 +558,10 @@
558558
\item The argument of \code{as.environment()} is named \code{x} now,
559559
not \code{object}, as it was always documented and shown when
560560
printing it; thanks to \I{Gael Millot}'s \PR{18849}.
561+
562+
\item When \command{R CMD check} aims at getting the time+date from a
563+
world clock, it is more robust against unexpected non-error results,
564+
thanks to \I{Michael Chirico}'s \PR{18852}.
561565
}
562566
}
563567
}

src/library/tools/R/check.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,15 @@ add_dummies <- function(dir, Log)
521521
if(config_val_to_logical(Sys.getenv("_R_CHECK_SYSTEM_CLOCK_", "TRUE"))) {
522522
## First check time on system running 'check',
523523
## by reading an external source in UTC
524+
notOK <- function(t) !length(t) || is.na(t[1]) # seen length > 1
524525
now <- tryCatch({
525526
foo <- suppressWarnings(readLines("https://worldtimeapi.org/api/timezone/etc/UTC",
526527
warn = FALSE))
527528
## gives time in sub-secs
528529
as.POSIXct(gsub(".*\"datetime\":\"([^Z]*).*", "\\1", foo),
529530
"UTC", "%Y-%m-%dT%H:%M:%S")
530531
}, error = function(e) NA)
531-
if(identical(NA, now)) { # try http (no 's')
532+
if(notOK(now)) { # try http (no 's')
532533
now <- tryCatch({
533534
foo <- suppressWarnings(readLines("http://worldtimeapi.org/api/timezone/etc/UTC",
534535
warn = FALSE))
@@ -537,7 +538,7 @@ add_dummies <- function(dir, Log)
537538
"UTC", "%Y-%m-%dT%H:%M:%S")
538539
}, error = function(e) NA)
539540
}
540-
if (FALSE && identical(NA, now)) { ## seems permanently stopped
541+
if(notOK(now)) { ## seemed permanently stopped, yet works 2025-02-08 and *-*-09
541542
now <- tryCatch({
542543
foo <- suppressWarnings(readLines("http://worldclockapi.com/api/json/utc/now",
543544
warn = FALSE))
@@ -546,7 +547,7 @@ add_dummies <- function(dir, Log)
546547
"UTC", "%Y-%m-%dT%H:%M")
547548
}, error = function(e) NA)
548549
}
549-
if(identical(NA, now)) {
550+
if(notOK(now)) {
550551
any <- TRUE
551552
noteLog(Log, "unable to verify current time")
552553
} else {
@@ -1292,7 +1293,7 @@ add_dummies <- function(dir, Log)
12921293
"\n")
12931294
}
12941295
}
1295-
1296+
12961297
if (!any) resultLog(Log, "OK")
12971298
## return (<never used in caller>):
12981299
db

0 commit comments

Comments
 (0)