index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = startOfUTCWeekYear;
  6. var _index = _interopRequireDefault(require("../toInteger/index.js"));
  7. var _index2 = _interopRequireDefault(require("../getUTCWeekYear/index.js"));
  8. var _index3 = _interopRequireDefault(require("../startOfUTCWeek/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 startOfUTCWeekYear(dirtyDate, dirtyOptions) {
  14. (0, _index4.default)(1, arguments);
  15. var options = dirtyOptions || {};
  16. var locale = options.locale;
  17. var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
  18. var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : (0, _index.default)(localeFirstWeekContainsDate);
  19. var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : (0, _index.default)(options.firstWeekContainsDate);
  20. var year = (0, _index2.default)(dirtyDate, dirtyOptions);
  21. var firstWeek = new Date(0);
  22. firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
  23. firstWeek.setUTCHours(0, 0, 0, 0);
  24. var date = (0, _index3.default)(firstWeek, dirtyOptions);
  25. return date;
  26. }
  27. module.exports = exports.default;