Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POSIXct objects that differ by fractional seconds are considered equal when run manually but not within reprex() #1977

Closed
billdenney opened this issue Aug 3, 2024 · 1 comment

Comments

@billdenney
Copy link
Contributor

When I ran the code below within reprex::reprex() I got the expected error below. When I ran it manually, I got no error.

testthat::expect_equal(
  as.POSIXct("2024-08-02 20:47:03.123", tz = "UTC"),
  as.POSIXct("2024-08-02 20:47:03", tz = "UTC")
)
#> Error: as.POSIXct("2024-08-02 20:47:03.123", tz = "UTC") not equal to as.POSIXct("2024-08-02 20:47:03", tz = "UTC").
#> 1/1 mismatches
#> [1] 2024-08-02 20:47:03.122 - 2024-08-02 20:47:03 == 0.123 secs

dput(as.POSIXct("2024-08-02 20:47:03.123", tz = "UTC"))
#> structure(1722631623.123, class = c("POSIXct", "POSIXt"), tzone = "UTC")
dput(as.POSIXct("2024-08-02 20:47:03", tz = "UTC"))
#> structure(1722631623, class = c("POSIXct", "POSIXt"), tzone = "UTC")

Created on 2024-08-03 with reprex v2.1.1

@hadley
Copy link
Member

hadley commented Oct 22, 2024

Depends on whether you're using 2e or 3e.

@hadley hadley closed this as completed Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants