arshaw / xdate

A Modern JavaScript Date Library
http://arshaw.com/xdate/
GNU General Public License v2.0
681 stars 81 forks source link

XDate diffMonths/addMonths returning incorrect date. #36

Open shriniketsarkar-zz opened 7 years ago

shriniketsarkar-zz commented 7 years ago

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.