subQuarters.js 904 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. exports.subQuarters = subQuarters;
  3. var _index = require("./addQuarters.js");
  4. /**
  5. * @name subQuarters
  6. * @category Quarter Helpers
  7. * @summary Subtract the specified number of year quarters from the given date.
  8. *
  9. * @description
  10. * Subtract the specified number of year quarters from the given date.
  11. *
  12. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  13. *
  14. * @param date - The date to be changed
  15. * @param amount - The amount of quarters to be subtracted.
  16. *
  17. * @returns The new date with the quarters subtracted
  18. *
  19. * @example
  20. * // Subtract 3 quarters from 1 September 2014:
  21. * const result = subQuarters(new Date(2014, 8, 1), 3)
  22. * //=> Sun Dec 01 2013 00:00:00
  23. */
  24. function subQuarters(date, amount) {
  25. return (0, _index.addQuarters)(date, -amount);
  26. }