{"ast":null,"code":"import { constructFrom } from \"./constructFrom.mjs\";\nimport { setMonth } from \"./setMonth.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * @name set\n * @category Common Helpers\n * @summary Set date values to a given date.\n *\n * @description\n * Set date values to a given date.\n *\n * Sets time values to date from object `values`.\n * A value is not set if it is undefined or null or doesn't exist in `values`.\n *\n * Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts\n * to use native `Date#setX` methods. If you use this function, you may not want to include the\n * other `setX` functions that date-fns provides if you are concerned about the bundle size.\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 values - The date values to be set\n *\n * @returns The new date with options set\n *\n * @example\n * // Transform 1 September 2014 into 20 October 2015 in a single line:\n * const result = set(new Date(2014, 8, 20), { year: 2015, month: 9, date: 20 })\n * //=> Tue Oct 20 2015 00:00:00\n *\n * @example\n * // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:\n * const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })\n * //=> Mon Sep 01 2014 12:23:45\n */\n\nexport function set(date, values) {\n  let _date = toDate(date);\n\n  // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date\n  if (isNaN(+_date)) {\n    return constructFrom(date, NaN);\n  }\n  if (values.year != null) {\n    _date.setFullYear(values.year);\n  }\n  if (values.month != null) {\n    _date = setMonth(_date, values.month);\n  }\n  if (values.date != null) {\n    _date.setDate(values.date);\n  }\n  if (values.hours != null) {\n    _date.setHours(values.hours);\n  }\n  if (values.minutes != null) {\n    _date.setMinutes(values.minutes);\n  }\n  if (values.seconds != null) {\n    _date.setSeconds(values.seconds);\n  }\n  if (values.milliseconds != null) {\n    _date.setMilliseconds(values.milliseconds);\n  }\n  return _date;\n}\n\n// Fallback for modularized imports:\nexport default set;","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}