I'm using current version of lubridate (1.7.9) from CRAN.
While investigating some code left by a predecessor, I found the following inconsistency:
library(lubridate)
interval(ymd('2019-01-29'), ymd('2019-01-30'))/months(1) # 0.06451613
interval(ymd('2020-01-29'), ymd('2020-01-30'))/months(1) # 0.03225806
The 2019 figure seems wrong, equating to 2 (/31) days, when it should be 1.
I have a workaround using time_length(), which returns consistent results
time_length(interval(ymd('2019-01-29'), ymd('2019-01-30')), 'month') # 0.03225806
time_length(interval(ymd('2020-01-29'), ymd('2020-01-30')), 'month') # 0.03225806
Perhaps the approach taken by my predecessor is an anti-pattern, but I figured it was worth raising, as it does seem like a bug.
I'm using current version of lubridate (1.7.9) from CRAN.
While investigating some code left by a predecessor, I found the following inconsistency:
The 2019 figure seems wrong, equating to 2 (/31) days, when it should be 1.
I have a workaround using
time_length(), which returns consistent resultsPerhaps the approach taken by my predecessor is an anti-pattern, but I figured it was worth raising, as it does seem like a bug.