Skip to content
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

DateTime API using minus and plus APIs #74

Closed
Kyle-Thayer opened this issue Oct 2, 2013 · 2 comments
Closed

DateTime API using minus and plus APIs #74

Kyle-Thayer opened this issue Oct 2, 2013 · 2 comments

Comments

@Kyle-Thayer
Copy link

Hi!

I am running into an issue that just started this month. Here is come sample code:

DateTime now = new DateTime();
now = now.minusMonths(11);
now = now.minusWeeks(3);
now = now.plusMonths(11);
System.out.println(Weeks.weeksBetween(now, new DateTime()).getWeeks());

weeksBetween will return 2 instead of 3. Anyone know why this is occurring? I am using 2.2 version of the API.

Thanks!

@Kyle-Thayer
Copy link
Author

For a little more information on the subject. If I take the testing back one month, everything works correctly:

DateTime now = new DateTime();
now = now.minusMonths(11);
now = now.minusWeeks(3);
now = now.plusMonths(11);
System.out.println(Weeks.weeksBetween(now.minusMonths(1), new DateTime().minusMonths(1)).getWeeks());

This test correctly produces 3 weeks, but something about the month of October yields incorrect results

@jodastephen
Copy link
Member

Just to note for anyone googling this thread that plusMonths(n).minusMonths(n) will not necessarily result in the same date. For example, March 31st plus one month is April 30th, minus one month is March 30th.

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

No branches or pull requests

2 participants