tidyverse / lubridate

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

Do we need something like `%m-%` to subtract years from leap 02/29? #1158

Closed jcrodriguez1989 closed 5 months ago

jcrodriguez1989 commented 5 months ago

Today is 02/29, and when subtracting years, it returns NA's.

> lubridate::today() - lubridate::years(1)
[1] NA
> lubridate::today() - lubridate::years(4)
[1] "2020-02-29"
jcrodriguez1989 commented 5 months ago

My bad, %m-% already handles this 💪 You're awesome!!

> today() %m-% years(1)
[1] "2023-02-28"