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

Date differences in months not working as expected #1

Open
aaronazlant opened this issue Dec 17, 2014 · 1 comment
Open

Date differences in months not working as expected #1

aaronazlant opened this issue Dec 17, 2014 · 1 comment

Comments

@aaronazlant
Copy link

If I give the library two dates like so:

batchStartTime = new Date("1/2/2015")
batchEndTime = new Date("4/1/2015")

and then do

console.log date.difference(batchStartTime, batchEndTime, "month")

I would expect to see 2 as my result. I do not: I see 3.

@JesperMadsen123
Copy link

Just a question:

batchStartTime = new Date("1/2/2015")
batchEndTime = new Date("2/1/2015")

and then do

console.log date.difference(batchStartTime, batchEndTime, "month")

What would be the expected outcome?

Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec
-**|----|-----|----|-----|----|----|-----|-----|----|----|----
Both january and february are "touched", but their entire period is not within the date range. So is it 0 - month: since no complete month is within the range?
1 - month: since the date range crosses the boundary between january and february?
2 - months: since 2 different months are in the range??

And what if:

batchStartTime = new Date("1/20/2015")
batchEndTime = new Date("3/19/2015")

what would be the expected outcome?
Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec
---|_|_--|----|-----|----|----|-----|-----|----|----|----

1 - month: since one complete month is within the range?
2 - months: since the date range crosses the boundary between january, february and march?
3 - months: since 3 different months are in the range??

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

No branches or pull requests

2 participants