938424bbb013c4381d4b264a3aa7aff929a73c7a499918c2a12142ae461f30c51fe0e887c28a8206e82439bd9a8869c9f8bd502d16068f978b7416c573d6ff 644 B

123456789101112131415161718192021
  1. import { createDuration } from './create';
  2. function addSubtract(duration, input, value, direction) {
  3. var other = createDuration(input, value);
  4. duration._milliseconds += direction * other._milliseconds;
  5. duration._days += direction * other._days;
  6. duration._months += direction * other._months;
  7. return duration._bubble();
  8. }
  9. // supports only 2.0-style add(1, 's') or add(duration)
  10. export function add(input, value) {
  11. return addSubtract(this, input, value, 1);
  12. }
  13. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  14. export function subtract(input, value) {
  15. return addSubtract(this, input, value, -1);
  16. }