subISOWeekYears.mjs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { addISOWeekYears } from "./addISOWeekYears.mjs";
  2. /**
  3. * @name subISOWeekYears
  4. * @category ISO Week-Numbering Year Helpers
  5. * @summary Subtract the specified number of ISO week-numbering years from the given date.
  6. *
  7. * @description
  8. * Subtract the specified number of ISO week-numbering years from the given date.
  9. *
  10. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_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 ISO week-numbering years to be subtracted.
  16. *
  17. * @returns The new date with the ISO week-numbering years subtracted
  18. *
  19. * @example
  20. * // Subtract 5 ISO week-numbering years from 1 September 2014:
  21. * const result = subISOWeekYears(new Date(2014, 8, 1), 5)
  22. * //=> Mon Aug 31 2009 00:00:00
  23. */
  24. export function subISOWeekYears(date, amount) {
  25. return addISOWeekYears(date, -amount);
  26. }
  27. // Fallback for modularized imports:
  28. export default subISOWeekYears;