Skip to content
Prev 386159 / 398513 Next

strptime() keeps emitting warnings after establishing a handler with tryCatch()

Thanks, Rui, for checking on your end. I don't think any Linux-based
system is affected, as they silently ignore invalid timezone
identifiers (at least the versions I know of).

I now also had a chance to test on Windows 10 and get the same errors
as under macOS. The session info for this test is
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.0.2

I also tested a bit more and it seems that attaching handlers really
messes up `strptime()`. For example, `strptime()` stops to emit any
warning for invalid timezone identifiers:
+                   warning = function (w) { stop("Error") })
Error in value[[3L]](cond) : Error
[1] "2020-10-31 18:30:00"

But a subsequent call to `strptime()` with a valid timezone identifier
does emit the original warning (continuing the R session from above):
[1] "2020-10-31 18:30:00 GMT"
Warning messages:
1: In strptime("2020-10-31 18:30", format = "%Y-%m-%d %H:%M", tz = "GMT") :
  unknown timezone 'Wrong Timezone!'

And the next call with an incorrect tz identifier, doesn't emit a
warning, but uses the timezone from the previous call (continuing the
R session as above):
[1] "2020-10-31 18:30:00 GMT"

Best wishes,
David
On Sun, Nov 1, 2020 at 9:51 AM Rui Barradas <ruipbarradas at sapo.pt> wrote: