Skip to content

Commit

Permalink
test: Fix tests for older R versions
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Dec 15, 2024
1 parent a14fcb9 commit d7fb43a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/shaft-.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,13 @@ pillar_shaft.POSIXt <- function(x, ...) {
date <- format(x, format = "%Y-%m-%d")
time <- format(x, format = "%H:%M:%OS")

datetime <- paste0(date, ifelse(is.finite(x), paste0(" ", style_subtle(time)), ""))
# R < 4.3 don't support is.finite() for POSIXlt
time_styled <- paste0(" ", style_subtle(time))
if (inherits(x, "POSIXct")) {
time_styled[!is.finite(x)] <- ""
}

datetime <- paste0(date, time_styled)
datetime[is.na(x)] <- NA

new_pillar_shaft_simple(datetime, width = width, align = "left")
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-shaft-.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test_that("S4 character class (tidyverse/tibble#1367)", {
})

test_that("Infinite times (#645)", {
skip_if(getRversion() < "4.3")
expect_snapshot({
pillar(.POSIXct(Inf))
})
Expand Down

0 comments on commit d7fb43a

Please sign in to comment.