subISOWeekYears.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { addISOWeekYears } from "./addISOWeekYears.js";
  2. /**
  3. * The {@link subISOWeekYears} function options.
  4. */
  5. /**
  6. * @name subISOWeekYears
  7. * @category ISO Week-Numbering Year Helpers
  8. * @summary Subtract the specified number of ISO week-numbering years from the given date.
  9. *
  10. * @description
  11. * Subtract the specified number of ISO week-numbering years from the given date.
  12. *
  13. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  14. *
  15. * @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).
  16. * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
  17. *
  18. * @param date - The date to be changed
  19. * @param amount - The amount of ISO week-numbering years to be subtracted.
  20. * @param options - The options
  21. *
  22. * @returns The new date with the ISO week-numbering years subtracted
  23. *
  24. * @example
  25. * // Subtract 5 ISO week-numbering years from 1 September 2014:
  26. * const result = subISOWeekYears(new Date(2014, 8, 1), 5)
  27. * //=> Mon Aug 31 2009 00:00:00
  28. */
  29. export function subISOWeekYears(date, amount, options) {
  30. return addISOWeekYears(date, -amount, options);
  31. }
  32. // Fallback for modularized imports:
  33. export default subISOWeekYears;