4935dd77c0dafa713208267a5931d4aa17c24736396e7b053d1ad2b595fc7b88d18b8e1c8282419163e83b84e7d8bfba6328068602e5bc26c52399ad4b6912 661 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. }