Whilst uncommon, it believe it should be possible to have a period with an infinite value (which when applied to a date with an operation, should result in an infinite date). Currently there is some code in periods.r which prevents this from being a possibility:
if (sum(values - trunc(values))) {
msg <- "periods must have integer values"
errors <- c(errors, msg)
}
Reprex:
lubridate::today() + Inf
#> [1] "Inf"
lubridate::today() + lubridate::days(Inf)
#> Error in if (sum(values - trunc(values))) {: argument is not interpretable as logical
I should note, the reason I am doing this is in a dplyr::mutate I need to add a number of days to a date to determine a deadline: Inf is used to specify that there is no deadline, whereas NA is used to specify that no deadline has been specified yet
Thanks for reporting! I have fixed the error but the actual computation has to be fixed in https://github.com/vspinu/timechange/issues/29 For now you will get the NA instead of the Inf date.
Whilst uncommon, it believe it should be possible to have a period with an infinite value (which when applied to a date with an operation, should result in an infinite date). Currently there is some code in periods.r which prevents this from being a possibility:
https://github.com/tidyverse/lubridate/blob/cae67eaee701f5041425968fc2a838e9fa25ed19/R/periods.r#L29C1-L32C4
Reprex:
I should note, the reason I am doing this is in a dplyr::mutate I need to add a number of days to a date to determine a deadline: Inf is used to specify that there is no deadline, whereas NA is used to specify that no deadline has been specified yet