MCPcopy
hub / github.com/moment/luxon / plus

Method plus

src/duration.js:654–667  ·  view source on GitHub ↗

* Make this Duration longer by the specified amount. Return a newly-constructed Duration. * @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() * @return {Duration}

(duration)

Source from the content-addressed store, hash-verified

652 * @return {Duration}
653 */
654 plus(duration) {
655 if (!this.isValid) return this;
656
657 const dur = Duration.fromDurationLike(duration),
658 result = {};
659
660 for (const k of orderedUnits) {
661 if (hasOwnProperty(dur.values, k) || hasOwnProperty(this.values, k)) {
662 result[k] = dur.get(k) + this.get(k);
663 }
664 }
665
666 return clone(this, { values: result }, true);
667 }
668
669 /**
670 * Make this Duration shorter by the specified amount. Return a newly-constructed Duration.

Callers 15

minusMethod · 0.95
math.test.jsFile · 0.45
toFormat.test.jsFile · 0.45
dst.test.jsFile · 0.45
diff.test.jsFile · 0.45
format.test.jsFile · 0.45
relative.test.jsFile · 0.45
misc.test.jsFile · 0.45
math.test.jsFile · 0.45
many.test.jsFile · 0.45
create.test.jsFile · 0.45
info.test.jsFile · 0.45

Calls 4

getMethod · 0.95
hasOwnPropertyFunction · 0.90
fromDurationLikeMethod · 0.80
cloneFunction · 0.70

Tested by

no test coverage detected