subDays.cjs 1.0 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. exports.subDays = subDays;
  3. var _index = require("./addDays.cjs");
  4. /**
  5. * The {@link subDays} function options.
  6. */
  7. /**
  8. * @name subDays
  9. * @category Day Helpers
  10. * @summary Subtract the specified number of days 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. * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
  14. *
  15. * @param date - The date to be changed
  16. * @param amount - The amount of days to be subtracted.
  17. * @param options - An object with options
  18. *
  19. * @returns The new date with the days subtracted
  20. *
  21. * @example
  22. * // Subtract 10 days from 1 September 2014:
  23. * const result = subDays(new Date(2014, 8, 1), 10)
  24. * //=> Fri Aug 22 2014 00:00:00
  25. */
  26. function subDays(date, amount, options) {
  27. return (0, _index.addDays)(date, -amount, options);
  28. }