From e544a1a545714bc0cbf3463c2d6de79f24127de3 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 20 May 2024 15:28:23 -0700 Subject: [PATCH] Document known false positive for as.POSIXct (#2579) --- R/inner_combine_linter.R | 7 +++++++ man/inner_combine_linter.Rd | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/R/inner_combine_linter.R b/R/inner_combine_linter.R index b83a120a3..bac85955e 100644 --- a/R/inner_combine_linter.R +++ b/R/inner_combine_linter.R @@ -6,6 +6,13 @@ #' preferred so that the most expensive part of the operation ([as.Date()]) #' is applied only once. #' +#' Note that [strptime()] has one idiosyncrasy to be aware of, namely that +#' auto-detected `format=` is set by the first matching input, which means +#' that a case like `c(as.POSIXct("2024-01-01"), as.POSIXct("2024-01-01 01:02:03"))` +#' gives different results to `as.POSIXct(c("2024-01-01", "2024-01-01 01:02:03"))`. +#' This false positive is rare; a workaround where possible is to use +#' consistent formatting, i.e., `"2024-01-01 00:00:00"` in the example. +#' #' @examples #' # will produce lints #' lint( diff --git a/man/inner_combine_linter.Rd b/man/inner_combine_linter.Rd index 73ac594e2..6455f5d68 100644 --- a/man/inner_combine_linter.Rd +++ b/man/inner_combine_linter.Rd @@ -13,6 +13,14 @@ The same equivalence holds for several other vectorized functions like preferred so that the most expensive part of the operation (\code{\link[=as.Date]{as.Date()}}) is applied only once. } +\details{ +Note that \code{\link[=strptime]{strptime()}} has one idiosyncrasy to be aware of, namely that +auto-detected \verb{format=} is set by the first matching input, which means +that a case like \code{c(as.POSIXct("2024-01-01"), as.POSIXct("2024-01-01 01:02:03"))} +gives different results to \code{as.POSIXct(c("2024-01-01", "2024-01-01 01:02:03"))}. +This false positive is rare; a workaround where possible is to use +consistent formatting, i.e., \code{"2024-01-01 00:00:00"} in the example. +} \examples{ # will produce lints lint(