index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = subISOWeekYears;
  6. var _index = _interopRequireDefault(require("../_lib/toInteger/index.js"));
  7. var _index2 = _interopRequireDefault(require("../addISOWeekYears/index.js"));
  8. var _index3 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. /**
  11. * @name subISOWeekYears
  12. * @category ISO Week-Numbering Year Helpers
  13. * @summary Subtract the specified number of ISO week-numbering years from the given date.
  14. *
  15. * @description
  16. * Subtract the specified number of ISO week-numbering years from the given date.
  17. *
  18. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  19. *
  20. * ### v2.0.0 breaking changes:
  21. *
  22. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  23. *
  24. * - The function was renamed from `subISOYears` to `subISOWeekYears`.
  25. * "ISO week year" is short for [ISO week-numbering year](https://en.wikipedia.org/wiki/ISO_week_date).
  26. * This change makes the name consistent with
  27. * locale-dependent week-numbering year helpers, e.g., `setWeekYear`.
  28. *
  29. * @param {Date|Number} date - the date to be changed
  30. * @param {Number} amount - the amount of ISO week-numbering years to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
  31. * @returns {Date} the new date with the ISO week-numbering years subtracted
  32. * @throws {TypeError} 2 arguments required
  33. *
  34. * @example
  35. * // Subtract 5 ISO week-numbering years from 1 September 2014:
  36. * const result = subISOWeekYears(new Date(2014, 8, 1), 5)
  37. * //=> Mon Aug 31 2009 00:00:00
  38. */
  39. function subISOWeekYears(dirtyDate, dirtyAmount) {
  40. (0, _index3.default)(2, arguments);
  41. var amount = (0, _index.default)(dirtyAmount);
  42. return (0, _index2.default)(dirtyDate, -amount);
  43. }
  44. module.exports = exports.default;