index.js 992 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = setUTCISOWeek;
  6. var _index = _interopRequireDefault(require("../toInteger/index.js"));
  7. var _index2 = _interopRequireDefault(require("../../toDate/index.js"));
  8. var _index3 = _interopRequireDefault(require("../getUTCISOWeek/index.js"));
  9. var _index4 = _interopRequireDefault(require("../requiredArgs/index.js"));
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. // This function will be a part of public API when UTC function will be implemented.
  12. // See issue: https://github.com/date-fns/date-fns/issues/376
  13. function setUTCISOWeek(dirtyDate, dirtyISOWeek) {
  14. (0, _index4.default)(2, arguments);
  15. var date = (0, _index2.default)(dirtyDate);
  16. var isoWeek = (0, _index.default)(dirtyISOWeek);
  17. var diff = (0, _index3.default)(date) - isoWeek;
  18. date.setUTCDate(date.getUTCDate() - diff * 7);
  19. return date;
  20. }
  21. module.exports = exports.default;