{"ast":null,"code":"import { getRoundingMethod } from \"./_lib/getRoundingMethod.mjs\";\nimport { constructFrom } from \"./constructFrom.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * The {@link roundToNearestHours} function options.\n */\n\n/**\n * @name roundToNearestHours\n * @category Hour Helpers\n * @summary Rounds the given date to the nearest hour\n *\n * @description\n * Rounds the given date to the nearest hour (or number of hours).\n * Rounds up when the given date is exactly between the nearest round hours.\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 round\n * @param options - An object with options.\n *\n * @returns The new date rounded to the closest hour\n *\n * @example\n * // Round 10 July 2014 12:34:56 to nearest hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56))\n * //=> Thu Jul 10 2014 13:00:00\n *\n * @example\n * // Round 10 July 2014 12:34:56 to nearest half hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56), { nearestTo: 6 })\n * //=> Thu Jul 10 2014 12:00:00\n\n * @example\n * // Round 10 July 2014 12:34:56 to nearest half hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56), { nearestTo: 8 })\n * //=> Thu Jul 10 2014 16:00:00\n\n* @example\n * // Floor (rounds down) 10 July 2014 12:34:56 to nearest hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 1, 23, 45), { roundingMethod: 'ceil' })\n * //=> Thu Jul 10 2014 02:00:00\n *\n * @example\n * // Ceil (rounds up) 10 July 2014 12:34:56 to nearest quarter hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56), { roundingMethod: 'floor', nearestTo: 8 })\n * //=> Thu Jul 10 2014 08:00:00\n */\nexport function roundToNearestHours(date, options) {\n  const nearestTo = options?.nearestTo ?? 1;\n  if (nearestTo < 1 || nearestTo > 12) return constructFrom(date, NaN);\n  const _date = toDate(date);\n  const fractionalMinutes = _date.getMinutes() / 60;\n  const fractionalSeconds = _date.getSeconds() / 60 / 60;\n  const fractionalMilliseconds = _date.getMilliseconds() / 1000 / 60 / 60;\n  const hours = _date.getHours() + fractionalMinutes + fractionalSeconds + fractionalMilliseconds;\n\n  // Unlike the `differenceIn*` functions, the default rounding behavior is `round` and not 'trunc'\n  const method = options?.roundingMethod ?? \"round\";\n  const roundingMethod = getRoundingMethod(method);\n\n  // nearestTo option does not care daylight savings time\n  const roundedHours = roundingMethod(hours / nearestTo) * nearestTo;\n  const result = constructFrom(date, _date);\n  result.setHours(roundedHours, 0, 0, 0);\n  return result;\n}\n\n// Fallback for modularized imports:\nexport default roundToNearestHours;","map":{"version":3,"names":["getRoundingMethod","constructFrom","toDate","roundToNearestHours","date","options","nearestTo","NaN","_date","fractionalMinutes","getMinutes","fractionalSeconds","getSeconds","fractionalMilliseconds","getMilliseconds","hours","getHours","method","roundingMethod","roundedHours","result","setHours"],"sources":["/root/rfcontavagas_hom/12.-Servidor-local-Docker/Front-Parking-Angular/node_modules/date-fns/roundToNearestHours.mjs"],"sourcesContent":["import { getRoundingMethod } from \"./_lib/getRoundingMethod.mjs\";\nimport { constructFrom } from \"./constructFrom.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * The {@link roundToNearestHours} function options.\n */\n\n/**\n * @name roundToNearestHours\n * @category Hour Helpers\n * @summary Rounds the given date to the nearest hour\n *\n * @description\n * Rounds the given date to the nearest hour (or number of hours).\n * Rounds up when the given date is exactly between the nearest round hours.\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 round\n * @param options - An object with options.\n *\n * @returns The new date rounded to the closest hour\n *\n * @example\n * // Round 10 July 2014 12:34:56 to nearest hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56))\n * //=> Thu Jul 10 2014 13:00:00\n *\n * @example\n * // Round 10 July 2014 12:34:56 to nearest half hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56), { nearestTo: 6 })\n * //=> Thu Jul 10 2014 12:00:00\n\n * @example\n * // Round 10 July 2014 12:34:56 to nearest half hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56), { nearestTo: 8 })\n * //=> Thu Jul 10 2014 16:00:00\n\n* @example\n * // Floor (rounds down) 10 July 2014 12:34:56 to nearest hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 1, 23, 45), { roundingMethod: 'ceil' })\n * //=> Thu Jul 10 2014 02:00:00\n *\n * @example\n * // Ceil (rounds up) 10 July 2014 12:34:56 to nearest quarter hour:\n * const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56), { roundingMethod: 'floor', nearestTo: 8 })\n * //=> Thu Jul 10 2014 08:00:00\n */\nexport function roundToNearestHours(date, options) {\n  const nearestTo = options?.nearestTo ?? 1;\n\n  if (nearestTo < 1 || nearestTo > 12) return constructFrom(date, NaN);\n\n  const _date = toDate(date);\n  const fractionalMinutes = _date.getMinutes() / 60;\n  const fractionalSeconds = _date.getSeconds() / 60 / 60;\n  const fractionalMilliseconds = _date.getMilliseconds() / 1000 / 60 / 60;\n  const hours =\n    _date.getHours() +\n    fractionalMinutes +\n    fractionalSeconds +\n    fractionalMilliseconds;\n\n  // Unlike the `differenceIn*` functions, the default rounding behavior is `round` and not 'trunc'\n  const method = options?.roundingMethod ?? \"round\";\n  const roundingMethod = getRoundingMethod(method);\n\n  // nearestTo option does not care daylight savings time\n  const roundedHours = roundingMethod(hours / nearestTo) * nearestTo;\n\n  const result = constructFrom(date, _date);\n  result.setHours(roundedHours, 0, 0, 0);\n  return result;\n}\n\n// Fallback for modularized imports:\nexport default roundToNearestHours;\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,8BAA8B;AAChE,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,MAAM,QAAQ,cAAc;;AAErC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,IAAI,EAAEC,OAAO,EAAE;EACjD,MAAMC,SAAS,GAAGD,OAAO,EAAEC,SAAS,IAAI,CAAC;EAEzC,IAAIA,SAAS,GAAG,CAAC,IAAIA,SAAS,GAAG,EAAE,EAAE,OAAOL,aAAa,CAACG,IAAI,EAAEG,GAAG,CAAC;EAEpE,MAAMC,KAAK,GAAGN,MAAM,CAACE,IAAI,CAAC;EAC1B,MAAMK,iBAAiB,GAAGD,KAAK,CAACE,UAAU,CAAC,CAAC,GAAG,EAAE;EACjD,MAAMC,iBAAiB,GAAGH,KAAK,CAACI,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE;EACtD,MAAMC,sBAAsB,GAAGL,KAAK,CAACM,eAAe,CAAC,CAAC,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE;EACvE,MAAMC,KAAK,GACTP,KAAK,CAACQ,QAAQ,CAAC,CAAC,GAChBP,iBAAiB,GACjBE,iBAAiB,GACjBE,sBAAsB;;EAExB;EACA,MAAMI,MAAM,GAAGZ,OAAO,EAAEa,cAAc,IAAI,OAAO;EACjD,MAAMA,cAAc,GAAGlB,iBAAiB,CAACiB,MAAM,CAAC;;EAEhD;EACA,MAAME,YAAY,GAAGD,cAAc,CAACH,KAAK,GAAGT,SAAS,CAAC,GAAGA,SAAS;EAElE,MAAMc,MAAM,GAAGnB,aAAa,CAACG,IAAI,EAAEI,KAAK,CAAC;EACzCY,MAAM,CAACC,QAAQ,CAACF,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACtC,OAAOC,MAAM;AACf;;AAEA;AACA,eAAejB,mBAAmB","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}