xdate icon indicating copy to clipboard operation
xdate copied to clipboard

XDate diffMonths/addMonths returning incorrect date.

Open shriniketsarkar-zz opened this issue 8 years ago • 0 comments

Eg :

new XDate('2011-05-22').diffMonths(new XDate('2016-02-26T14:06:00.000Z')) Response : 57.13991935483871 new XDate('2011-05-22').addMonths(57.13991935483871) Response : h {0: Fri Feb 26 2016 08:06:00 GMT-0600 (CST)}

The above example has a correct response indicating that adding the difference in months to the initial date gets you the second date.

new XDate('2011-05-22').diffMonths(new XDate('2016-03-01T15:26:00.000Z')) Response : 57.33525985663083 new XDate('2011-05-22').addMonths(57.33525985663083) Response : h {0: Thu Mar 03 2016 09:26:00 GMT-0600 (CST)}

The above example has an incorrect response where adding the difference in months to the initial date gets you a date which is 2 days after the expected date.

Is this an issue or am I just using the library incorrectly ?

I have tried this with the latest tag version : XDate v0.8.2 of the library.

shriniketsarkar-zz avatar Jul 05 '17 21:07 shriniketsarkar-zz