{"ast":null,"code":"import { constructFrom } from \"./constructFrom.mjs\";\nimport { differenceInCalendarDays } from \"./differenceInCalendarDays.mjs\";\nimport { startOfISOWeekYear } from \"./startOfISOWeekYear.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * @name setISOWeekYear\n * @category ISO Week-Numbering Year Helpers\n * @summary Set the ISO week-numbering year to the given date.\n *\n * @description\n * Set the ISO week-numbering year to the given date,\n * saving the week number and the weekday number.\n *\n * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date\n *\n * @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).\n *\n * @param date - The date to be changed\n * @param weekYear - The ISO week-numbering year of the new date\n *\n * @returns The new date with the ISO week-numbering year set\n *\n * @example\n * // Set ISO week-numbering year 2007 to 29 December 2008:\n * const result = setISOWeekYear(new Date(2008, 11, 29), 2007)\n * //=> Mon Jan 01 2007 00:00:00\n */\nexport function setISOWeekYear(date, weekYear) {\n  let _date = toDate(date);\n  const diff = differenceInCalendarDays(_date, startOfISOWeekYear(_date));\n  const fourthOfJanuary = constructFrom(date, 0);\n  fourthOfJanuary.setFullYear(weekYear, 0, 4);\n  fourthOfJanuary.setHours(0, 0, 0, 0);\n  _date = startOfISOWeekYear(fourthOfJanuary);\n  _date.setDate(_date.getDate() + diff);\n  return _date;\n}\n\n// Fallback for modularized imports:\nexport default setISOWeekYear;","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}