MCPcopy Create free account
hub / github.com/csev/py4e / monthDiff

Function monthDiff

code/gmane/Chart.bundle.js:3505–3523  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

3503 }
3504
3505 function monthDiff (a, b) {
3506 // difference in months
3507 var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
3508 // b is in (anchor - 1 month, anchor + 1 month)
3509 anchor = a.clone().add(wholeMonthDiff, 'months'),
3510 anchor2, adjust;
3511
3512 if (b - anchor < 0) {
3513 anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
3514 // linear across the month
3515 adjust = (b - anchor) / (anchor - anchor2);
3516 } else {
3517 anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
3518 // linear across the month
3519 adjust = (b - anchor) / (anchor2 - anchor);
3520 }
3521
3522 return -(wholeMonthDiff + adjust);
3523 }
3524
3525 utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
3526

Callers 1

diffFunction · 0.85

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected