| 18005 | } |
| 18006 | |
| 18007 | function monthDiff (a, b) { |
| 18008 | // difference in months |
| 18009 | var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()), |
| 18010 | // b is in (anchor - 1 month, anchor + 1 month) |
| 18011 | anchor = a.clone().add(wholeMonthDiff, 'months'), |
| 18012 | anchor2, adjust; |
| 18013 | |
| 18014 | if (b - anchor < 0) { |
| 18015 | anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); |
| 18016 | // linear across the month |
| 18017 | adjust = (b - anchor) / (anchor - anchor2); |
| 18018 | } else { |
| 18019 | anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); |
| 18020 | // linear across the month |
| 18021 | adjust = (b - anchor) / (anchor2 - anchor); |
| 18022 | } |
| 18023 | |
| 18024 | //check for negative zero, return zero if negative zero |
| 18025 | return -(wholeMonthDiff + adjust) || 0; |
| 18026 | } |
| 18027 | |
| 18028 | hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ'; |
| 18029 | hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]'; |