Skip to content

Commit

Permalink
fix: Fix printing of infinite times (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Dec 14, 2024
1 parent 11822e2 commit 951a63e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/shaft-.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pillar_shaft.POSIXt <- function(x, ...) {
date <- format(x, format = "%Y-%m-%d")
time <- format(x, format = "%H:%M:%OS")

datetime <- paste0(date, " ", style_subtle(time))
datetime <- paste0(date, ifelse(is.finite(x), paste0(" ", style_subtle(time)), ""))
datetime[is.na(x)] <- NA

new_pillar_shaft_simple(datetime, width = width, align = "left")
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/_snaps/shaft-.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@
<SQL>
x

# Infinite times (#645)

Code
pillar(.POSIXct(Inf))
Output
<pillar>
<dttm>
Inf

6 changes: 6 additions & 0 deletions tests/testthat/test-shaft-.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ test_that("S4 character class (tidyverse/tibble#1367)", {
pillar(DBI::SQL("x"))
})
})

test_that("Infinite times (#645)", {
expect_snapshot({
pillar(.POSIXct(Inf))
})
})

0 comments on commit 951a63e

Please sign in to comment.