You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The floor_date() function returns NA for infinite times (positive or negative). This seems wrong.
An Inf time is a time after all others, and flooring or rounding that to the nearest day, hour, minute or second, should also result in a time after all others, rather than a missing value. This can be quite useful, and other issues have discussed how this is a legitimate use (see e.g. #1020, but note that this is not a duplicate of that issue, the value of floor_date() does not just print as NA it reallly is NA).
This applies to -Inf and to ceiling_date()as well.
But notably not to round_date()!
See reprex below.
# A double for comparisonx<- as.double(Inf)
x|> floor()
#> [1] Infx|> ceiling()
#> [1] Infx|> round()
#> [1] Infx|> round(digits=2)
#> [1] Inf# Load, set
library(lubridate, warn.conflicts=FALSE)
t<- as.POSIXct(Inf)
# Various examplest#> [1] "Inf"t|> as_date()
#> [1] "Inf"t|> floor_date()
#> [1] NAt|> floor_date(unit="seconds")
#> [1] NAt|> floor_date(unit="minutes")
#> [1] NAt|> floor_date(unit="hours")
#> [1] NAt|> floor_date(unit="days")
#> [1] NA# Applies to ceiling_date()t|> ceiling_date()
#> [1] NA# But not to round_date()t|> round_date()
#> [1] "Inf"# It really is an NAt|> floor_date() |> is.na()
#> [1] TRUE
The text was updated successfully, but these errors were encountered:
The
floor_date()
function returnsNA
for infinite times (positive or negative). This seems wrong.An
Inf
time is a time after all others, and flooring or rounding that to the nearest day, hour, minute or second, should also result in a time after all others, rather than a missing value. This can be quite useful, and other issues have discussed how this is a legitimate use (see e.g. #1020, but note that this is not a duplicate of that issue, the value offloor_date()
does not just print asNA
it reallly isNA
).This applies to
-Inf
and toceiling_date()
as well.But notably not to
round_date()
!See reprex below.
The text was updated successfully, but these errors were encountered: