index.js 879 B

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