{"ast":null,"code":"import { setMonth } from \"./setMonth.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * @name setQuarter\n * @category Quarter Helpers\n * @summary Set the year quarter to the given date.\n *\n * @description\n * Set the year quarter to the given 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 quarter - The quarter of the new date\n *\n * @returns The new date with the quarter set\n *\n * @example\n * // Set the 2nd quarter to 2 July 2014:\n * const result = setQuarter(new Date(2014, 6, 2), 2)\n * //=> Wed Apr 02 2014 00:00:00\n */\nexport function setQuarter(date, quarter) {\n  const _date = toDate(date);\n  const oldQuarter = Math.trunc(_date.getMonth() / 3) + 1;\n  const diff = quarter - oldQuarter;\n  return setMonth(_date, _date.getMonth() + diff * 3);\n}\n\n// Fallback for modularized imports:\nexport default setQuarter;","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}