New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End-of-month arithmetic can cause mixed-polarity periods #223

Closed
GoogleCodeExporter opened this Issue Mar 15, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@GoogleCodeExporter

GoogleCodeExporter commented Mar 15, 2015

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

@GoogleCodeExporter

This comment has been minimized.

Show comment
Hide comment
@GoogleCodeExporter

GoogleCodeExporter Mar 15, 2015

This issue was closed by revision eb9bdae7e482.

Original comment by jonathan.skeet on 11 Jun 2013 at 3:40

  • Changed state: Fixed

GoogleCodeExporter commented Mar 15, 2015

This issue was closed by revision eb9bdae7e482.

Original comment by jonathan.skeet on 11 Jun 2013 at 3:40

  • Changed state: Fixed
@GoogleCodeExporter

This comment has been minimized.

Show comment
Hide comment
@GoogleCodeExporter

GoogleCodeExporter Mar 15, 2015

Note that it's possible that we have similar issues for years. I'll need to 
investigate that separately.

Original comment by jonathan.skeet on 11 Jun 2013 at 3:40

GoogleCodeExporter commented Mar 15, 2015

Note that it's possible that we have similar issues for years. I'll need to 
investigate that separately.

Original comment by jonathan.skeet on 11 Jun 2013 at 3:40

@GoogleCodeExporter

This comment has been minimized.

Show comment
Hide comment
@GoogleCodeExporter

GoogleCodeExporter Mar 15, 2015

Original comment by malcolm.rowe on 26 Jul 2013 at 10:02

  • Added labels: Milestone-1.2.0

GoogleCodeExporter commented Mar 15, 2015

Original comment by malcolm.rowe on 26 Jul 2013 at 10:02

  • Added labels: Milestone-1.2.0

@malcolmr malcolmr added the bug label Mar 15, 2015

@malcolmr malcolmr modified the milestone: 1.2.0 Mar 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment