MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / addSubtract

Function addSubtract

tests/test_code/js/moment/moment.js:3587–3611  ·  view source on GitHub ↗
(mom, duration, isAdding, updateOffset)

Source from the content-addressed store, hash-verified

3585 }
3586
3587 function addSubtract(mom, duration, isAdding, updateOffset) {
3588 var milliseconds = duration._milliseconds,
3589 days = absRound(duration._days),
3590 months = absRound(duration._months);
3591
3592 if (!mom.isValid()) {
3593 // No op
3594 return;
3595 }
3596
3597 updateOffset = updateOffset == null ? true : updateOffset;
3598
3599 if (months) {
3600 setMonth(mom, get(mom, 'Month') + months * isAdding);
3601 }
3602 if (days) {
3603 set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
3604 }
3605 if (milliseconds) {
3606 mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
3607 }
3608 if (updateOffset) {
3609 hooks.updateOffset(mom, days || months);
3610 }
3611 }
3612
3613 var add = createAdder(1, 'add'),
3614 subtract = createAdder(-1, 'subtract');

Callers 2

getSetOffsetFunction · 0.85
createAdderFunction · 0.85

Calls 4

absRoundFunction · 0.85
setMonthFunction · 0.85
getFunction · 0.85
set$1Function · 0.85

Tested by

no test coverage detected