You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main issue is that the computation of as.period assumes that the period between start and end is the negative of the period between end and start. This causes problems with the arithmetics because the addition of days takes into account the previous months of the end date. While subtracting the period from end, the number of days in the next month of start are used for computation. That because of the addition logic of POSIXlt follow year -> month -> day sequence.
In principle there are two ways out. Either make period(start, end) be different from period(end, start), or change the semantic of addition with negative intervals such that days are added first and then the month operation is performed.
I feel that the first option is cleaner, but will likely result in a lot of existing code. The second option might have less severe consequences, but will result in asymmetric arithmetics which is hard to reason about. More-over, lubridate relies on internal POSIXlt conversions which are incompatible with this "reversed" arithmetics. Thus second option is probably not really an option.