This is not a mistake, this is a documented function. This is definitely not a bug in lubridate since months and as.Date are base package functions. . (Change. months.numeric and months.integer are invisible functions from the lubridate package.
However, luibridate has the answer!
This is done exactly as indicated in the help file for %m+% (which is part of the lubridate package.)
Adding months violates basic arithmetic, since consecutive months have different lengths. With other elements, it is useful for arithmetic to perform automatic flipping. For example, 12:00:00 + 61 seconds becomes 12:01:01. However, people often prefer that this behavior does not occur for months. For example, we sometimes want January 31 + 1 month = February 28, not March 3. (N) always returns the date in the nth month after the date. If the new date usually flows to n + 1 month, month. Date of the nth month to date.
The %m+% function is designed to provide the required function, ensuring that the month is not upside down
d %m+% months(1)
Please note that this feature was introduced in version 1.2.0 and thus was not documented at http://www.jstatsoft.org/v40/i03/paper , as it was written before implementation
Also note that you can also use duration(1, 'months')
d + duration(1, 'months')
source share