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
{{ message }}
Repository navigation
End-of-month arithmetic can cause mixed-polarity periods #223
We claim that Period.Between(x, y) will always return a period of either
all-non-negative values, or all-non-positive values. Unfortunately this doesn't
quite work:
LocalDate d1 = new LocalDate(2013, 3, 31);
LocalDate d2 = new LocalDate(2013, 4, 30);
Period period = Period.Between(d2, d1);
The result is P-1M1D, as subtraction is always really performed from a later
value to an earlier one... the first part is determined to be -1 month, but
then adding -1 month to April 30th gives March 30th, so an extra day is added.
When we find the number of months, we should disallow the end-of-month rounding
if we were originally going "backwards".
Original issue reported on code.google.com by jonathan.skeet on 11 Jun 2013 at 3:30
Activity