tidyverse / lubridate

Make working with dates in R just that little bit easier
https://lubridate.tidyverse.org
GNU General Public License v3.0
728 stars 207 forks source link

Adding date to period of length zero gives error #1115

Open michael-dewar opened 1 year ago

michael-dewar commented 1 year ago

If I add a date to a period with length zero I get an error.

as.Date("1899/12/31") + lubridate::days(numeric())

My use case is that I must mutate a tibble that sometimes has zero rows. I would expect to get back a tibble with zero rows. Instead, the following also gives me an error.

tibble::tibble(num_days = numeric()) %>% 
    dplyr::mutate(my_date = lubridate::days(num_days) + as.Date("1899/12/31"))