diff --git a/src/utils.js b/src/utils.js index 7b1712bda..6ef4ce629 100644 --- a/src/utils.js +++ b/src/utils.js @@ -16,11 +16,12 @@ const padZoneStr = (instance) => { const monthDiff = (a, b) => { // function from moment.js in order to keep the same result + if (a.date() < b.date()) return -monthDiff(b, a) const wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()) - const anchor = a.clone().add(wholeMonthDiff, C.M) + const anchor = a.add(wholeMonthDiff, C.M) const c = b - anchor < 0 - const anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), C.M) - return Number(-(wholeMonthDiff + ((b - anchor) / (c ? (anchor - anchor2) : + const anchor2 = a.add(wholeMonthDiff + (c ? -1 : 1), C.M) + return +(-(wholeMonthDiff + ((b - anchor) / (c ? (anchor - anchor2) : (anchor2 - anchor)))) || 0) }