@hebcal/core 6.9.3 → 6.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +8 -7
  2. package/dist/bundle.js +1123 -996
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/bundle.min.js +9 -9
  5. package/dist/bundle.min.js.map +1 -1
  6. package/dist/esm/DailyLearning.js +1 -1
  7. package/dist/esm/DailyLearning.js.map +1 -1
  8. package/dist/esm/HebrewDateEvent.js +1 -1
  9. package/dist/esm/HebrewDateEvent.js.map +1 -1
  10. package/dist/esm/HolidayEvent.js +3 -3
  11. package/dist/esm/HolidayEvent.js.map +1 -1
  12. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  13. package/dist/esm/MevarchimChodeshEvent.js.map +1 -1
  14. package/dist/esm/ParshaEvent.js +1 -1
  15. package/dist/esm/ParshaEvent.js.map +1 -1
  16. package/dist/esm/TimedEvent.js +1 -1
  17. package/dist/esm/TimedEvent.js.map +1 -1
  18. package/dist/esm/YomKippurKatanEvent.js +1 -1
  19. package/dist/esm/YomKippurKatanEvent.js.map +1 -1
  20. package/dist/esm/ashkenazi.po.js +1 -1
  21. package/dist/esm/ashkenazi.po.js.map +1 -1
  22. package/dist/esm/calendar.js +15 -12
  23. package/dist/esm/calendar.js.map +1 -1
  24. package/dist/esm/candles.js +7 -7
  25. package/dist/esm/candles.js.map +1 -1
  26. package/dist/esm/cities.json.js +1 -1
  27. package/dist/esm/cities.json.js.map +1 -1
  28. package/dist/esm/event.d.ts +47 -0
  29. package/dist/esm/event.js +63 -4
  30. package/dist/esm/event.js.map +1 -1
  31. package/dist/esm/getStartAndEnd.js +1 -1
  32. package/dist/esm/getStartAndEnd.js.map +1 -1
  33. package/dist/esm/hallel.js +3 -5
  34. package/dist/esm/hallel.js.map +1 -1
  35. package/dist/esm/he-x-NoNikud.po.js +1 -1
  36. package/dist/esm/he-x-NoNikud.po.js.map +1 -1
  37. package/dist/esm/he.po.js +1 -1
  38. package/dist/esm/he.po.js.map +1 -1
  39. package/dist/esm/hebcal.d.ts +2 -2
  40. package/dist/esm/hebcal.js +4 -5
  41. package/dist/esm/hebcal.js.map +1 -1
  42. package/dist/esm/holidays.js +2 -2
  43. package/dist/esm/holidays.js.map +1 -1
  44. package/dist/esm/index.d.ts +8 -8
  45. package/dist/esm/index.js +1 -1
  46. package/dist/esm/isAssurBemlacha.js +3 -5
  47. package/dist/esm/isAssurBemlacha.js.map +1 -1
  48. package/dist/esm/isAveilut.js +1 -1
  49. package/dist/esm/isAveilut.js.map +1 -1
  50. package/dist/esm/isFastDay.js +2 -8
  51. package/dist/esm/isFastDay.js.map +1 -1
  52. package/dist/esm/locale.js +1 -1
  53. package/dist/esm/location.js +1 -1
  54. package/dist/esm/location.js.map +1 -1
  55. package/dist/esm/modern.js +1 -1
  56. package/dist/esm/modern.js.map +1 -1
  57. package/dist/esm/molad.js +1 -1
  58. package/dist/esm/molad.js.map +1 -1
  59. package/dist/esm/moladBase.js +1 -1
  60. package/dist/esm/moladBase.js.map +1 -1
  61. package/dist/esm/moladDate.js +1 -1
  62. package/dist/esm/moladDate.js.map +1 -1
  63. package/dist/esm/omer.js +1 -1
  64. package/dist/esm/omer.js.map +1 -1
  65. package/dist/esm/parshaName.js +1 -1
  66. package/dist/esm/parshaName.js.map +1 -1
  67. package/dist/esm/parshaYear.js +1 -1
  68. package/dist/esm/parshaYear.js.map +1 -1
  69. package/dist/esm/pkgVersion.d.ts +1 -1
  70. package/dist/esm/pkgVersion.js +2 -2
  71. package/dist/esm/pkgVersion.js.map +1 -1
  72. package/dist/esm/reformatTimeStr.js +1 -1
  73. package/dist/esm/reformatTimeStr.js.map +1 -1
  74. package/dist/esm/sedra.js +1 -1
  75. package/dist/esm/sedra.js.map +1 -1
  76. package/dist/esm/sefira.json.js +1 -1
  77. package/dist/esm/sefira.json.js.map +1 -1
  78. package/dist/esm/staticHolidays.js +1 -1
  79. package/dist/esm/staticHolidays.js.map +1 -1
  80. package/dist/esm/string.js +1 -1
  81. package/dist/esm/string.js.map +1 -1
  82. package/dist/esm/tachanun.js +1 -1
  83. package/dist/esm/tachanun.js.map +1 -1
  84. package/dist/esm/zmanim.js +1 -1
  85. package/dist/esm/zmanim.js.map +1 -1
  86. package/package.json +10 -10
package/dist/bundle.js CHANGED
@@ -1,9 +1,9 @@
1
- /*! @hebcal/core v6.9.3, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.10.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
5
5
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
6
- const version = '6.9.3';
6
+ const version = '6.10.0';
7
7
 
8
8
  /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
9
9
  /** @private */
@@ -2487,6 +2487,13 @@ const flags = {
2487
2487
  /** BeHaB fast days on Monday, Thursday and Monday after Pesach and Sukkot */
2488
2488
  BEHAB: 0x10000000,
2489
2489
  };
2490
+ const flagEntries = Object.entries(flags);
2491
+ function flagBit(name) {
2492
+ if (!Object.hasOwn(flags, name)) {
2493
+ throw new RangeError(`Unknown flag name: ${String(name)}`);
2494
+ }
2495
+ return flags[name];
2496
+ }
2490
2497
  const flagToCategory = [
2491
2498
  [flags.MAJOR_FAST, 'holiday', 'major', 'fast'],
2492
2499
  [flags.CHANUKAH_CANDLES, 'holiday', 'minor'],
@@ -2567,10 +2574,62 @@ class Event {
2567
2574
  }
2568
2575
  /**
2569
2576
  * Bitmask of optional event flags. See {@link flags}
2577
+ * @deprecated Use {@link Event.hasFlag} to test for a flag, or
2578
+ * {@link Event.flagNames} to list them. Code that genuinely needs the
2579
+ * raw bitmask can read {@link Event.mask}.
2570
2580
  */
2571
2581
  getFlags() {
2572
2582
  return this.mask;
2573
2583
  }
2584
+ /**
2585
+ * Does this event have the given flag?
2586
+ *
2587
+ * A readable alternative to testing the bitmask with `&`.
2588
+ * @example
2589
+ * import {Event, HDate, flags} from '@hebcal/core';
2590
+ * const ev = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II',
2591
+ * flags.CHAG | flags.CHUL_ONLY);
2592
+ * ev.hasFlag('CHAG'); // true
2593
+ * ev.hasFlag('CHUL_ONLY'); // true
2594
+ * ev.hasFlag('MINOR_FAST'); // false
2595
+ * @param name flag name, one of the keys of {@link flags}
2596
+ * @throws {RangeError} if `name` is not a key of {@link flags}
2597
+ */
2598
+ hasFlag(name) {
2599
+ return (this.mask & flagBit(name)) !== 0;
2600
+ }
2601
+ /**
2602
+ * Does this event have at least one of the given flags?
2603
+ *
2604
+ * Returns `false` when called with no arguments.
2605
+ * @example
2606
+ * import {Event, HDate, flags} from '@hebcal/core';
2607
+ * const ev = new Event(new HDate(10, 'Tishrei', 5784), 'Yom Kippur',
2608
+ * flags.CHAG | flags.MAJOR_FAST);
2609
+ * ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST'); // true
2610
+ * ev.hasAnyFlag('ROSH_CHODESH', 'MINOR_FAST'); // false
2611
+ * @param names flag names, each one of the keys of {@link flags}
2612
+ * @throws {RangeError} if any name is not a key of {@link flags}
2613
+ */
2614
+ hasAnyFlag(...names) {
2615
+ let bits = 0;
2616
+ for (const name of names) {
2617
+ bits |= flagBit(name);
2618
+ }
2619
+ return (this.mask & bits) !== 0;
2620
+ }
2621
+ /**
2622
+ * Names of all {@link flags} set on this event, in ascending bit order.
2623
+ * Returns an empty array for an event with no flags.
2624
+ * @example
2625
+ * import {Event, HDate, flags} from '@hebcal/core';
2626
+ * const ev = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II',
2627
+ * flags.CHAG | flags.CHUL_ONLY);
2628
+ * ev.flagNames(); // ['CHAG', 'CHUL_ONLY']
2629
+ */
2630
+ flagNames() {
2631
+ return flagEntries.filter(([, bit]) => this.mask & bit).map(([name]) => name);
2632
+ }
2574
2633
  /**
2575
2634
  * Returns (translated) description of this event
2576
2635
  * @example
@@ -2645,7 +2704,7 @@ class Event {
2645
2704
  * ev2.observedInIsrael(); // true
2646
2705
  */
2647
2706
  observedInIsrael() {
2648
- return !(this.mask & flags.CHUL_ONLY);
2707
+ return !this.hasFlag('CHUL_ONLY');
2649
2708
  }
2650
2709
  /**
2651
2710
  * Is this event observed in the Diaspora?
@@ -2656,7 +2715,7 @@ class Event {
2656
2715
  * ev2.observedInDiaspora(); // true
2657
2716
  */
2658
2717
  observedInDiaspora() {
2659
- return !(this.mask & flags.IL_ONLY);
2718
+ return !this.hasFlag('IL_ONLY');
2660
2719
  }
2661
2720
  /**
2662
2721
  * Is this event observed in Israel/Diaspora?
@@ -2687,7 +2746,7 @@ class Event {
2687
2746
  * .getCategories(); // ['roshchodesh']
2688
2747
  */
2689
2748
  getCategories() {
2690
- const mask = this.getFlags();
2749
+ const mask = this.mask;
2691
2750
  for (const attrs of flagToCategory) {
2692
2751
  const attr0 = attrs[0];
2693
2752
  if (mask & attr0) {
@@ -2829,6 +2888,259 @@ function requireObjectLike(arg) {
2829
2888
  return arg;
2830
2889
  }
2831
2890
 
2891
+ function normalizeOptionsOrString(options, optionName) {
2892
+ return "string" == typeof options ? ((optionName, optionVal) => {
2893
+ const res = Object.create(null);
2894
+ return res[optionName] = optionVal, res;
2895
+ })(optionName, options) : requireObjectLike(options);
2896
+ }
2897
+
2898
+ const smallestUnitStr = "smallestUnit";
2899
+
2900
+ const overflowMap = {
2901
+ constrain: 0,
2902
+ reject: 1
2903
+ };
2904
+
2905
+ const epochDisambigMap = {
2906
+ compatible: 0,
2907
+ reject: 1,
2908
+ earlier: 2,
2909
+ later: 3
2910
+ };
2911
+
2912
+ const offsetDisambigMap = {
2913
+ reject: 0,
2914
+ use: 1,
2915
+ prefer: 2,
2916
+ ignore: 3
2917
+ };
2918
+
2919
+ const calendarDisplayMap = {
2920
+ auto: 0,
2921
+ never: 1,
2922
+ critical: 2,
2923
+ always: 3
2924
+ };
2925
+
2926
+ const timeZoneDisplayMap = {
2927
+ auto: 0,
2928
+ never: 1,
2929
+ critical: 2
2930
+ };
2931
+
2932
+ const offsetDisplayMap = {
2933
+ auto: 0,
2934
+ never: 1
2935
+ };
2936
+
2937
+ const roundingModeMap = {
2938
+ floor: 0,
2939
+ halfFloor: 1,
2940
+ ceil: 2,
2941
+ halfCeil: 3,
2942
+ trunc: 4,
2943
+ halfTrunc: 5,
2944
+ expand: 6,
2945
+ halfExpand: 7,
2946
+ halfEven: 8
2947
+ };
2948
+
2949
+ const roundingModeFuncs = [ Math.floor, roundHalfFloor, Math.ceil, roundHalfCeil, Math.trunc, roundHalfTrunc, roundExpand, roundHalfExpand, roundHalfEven ];
2950
+
2951
+ const directionMap = {
2952
+ previous: -1,
2953
+ next: 1
2954
+ };
2955
+
2956
+ function coerceRoundingIncInteger(options) {
2957
+ const roundingInc = options.roundingIncrement;
2958
+ return void 0 === roundingInc ? 1 : toIntegerWithTrunc(roundingInc, "roundingIncrement");
2959
+ }
2960
+
2961
+ function coerceFractionalSecondDigits(options) {
2962
+ let subsecDigits = options.fractionalSecondDigits;
2963
+ if (void 0 !== subsecDigits) {
2964
+ if ("number" != typeof subsecDigits) {
2965
+ if ("auto" === toString(subsecDigits)) {
2966
+ return;
2967
+ }
2968
+ throwRangeError(invalidEntity("fractionalSecondDigits", subsecDigits));
2969
+ }
2970
+ subsecDigits = clampEntity("fractionalSecondDigits", Math.floor(subsecDigits), 0, 9, 1);
2971
+ }
2972
+ return subsecDigits;
2973
+ }
2974
+
2975
+ function coerceUnitOption(optionName, options, minUnit = 0, ensureDefined) {
2976
+ let unitStr = options[optionName];
2977
+ if (void 0 === unitStr) {
2978
+ return ensureDefined ? minUnit : void 0;
2979
+ }
2980
+ if (unitStr = toString(unitStr), "auto" === unitStr) {
2981
+ return ensureDefined ? minUnit : null;
2982
+ }
2983
+ let unit = unitNameMap[unitStr];
2984
+ return void 0 === unit && (unit = durationFieldNamesAsc.indexOf(unitStr)), unit < 0 && throwRangeError(invalidChoice(optionName, unitStr, unitNameMap)),
2985
+ unit;
2986
+ }
2987
+
2988
+ function coerceChoiceOption(optionName, enumNameMap, options, defaultChoice = 0) {
2989
+ const enumArg = options[optionName];
2990
+ if (void 0 === enumArg) {
2991
+ return defaultChoice;
2992
+ }
2993
+ const enumStr = toString(enumArg);
2994
+ const enumNum = enumNameMap[enumStr];
2995
+ return void 0 === enumNum && throwRangeError(invalidChoice(optionName, enumStr, enumNameMap)),
2996
+ enumNum;
2997
+ }
2998
+
2999
+ const coerceSmallestUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, smallestUnitStr);
3000
+
3001
+ const coerceLargestUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, "largestUnit");
3002
+
3003
+ const coerceTotalUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, "unit");
3004
+
3005
+ const coerceOverflow = /*@__PURE__*/ bindArgs(coerceChoiceOption, "overflow", overflowMap);
3006
+
3007
+ const coerceEpochDisambig = /*@__PURE__*/ bindArgs(coerceChoiceOption, "disambiguation", epochDisambigMap);
3008
+
3009
+ const coerceOffsetDisambig = /*@__PURE__*/ bindArgs(coerceChoiceOption, "offset", offsetDisambigMap);
3010
+
3011
+ const coerceCalendarDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "calendarName", calendarDisplayMap);
3012
+
3013
+ const coerceTimeZoneDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "timeZoneName", timeZoneDisplayMap);
3014
+
3015
+ const coerceOffsetDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "offset", offsetDisplayMap);
3016
+
3017
+ const coerceRoundingMode = /*@__PURE__*/ bindArgs(coerceChoiceOption, "roundingMode", roundingModeMap);
3018
+
3019
+ const coerceDirection = /*@__PURE__*/ bindArgs(coerceChoiceOption, "direction", directionMap);
3020
+
3021
+ function validateRoundingInc(roundingInc, smallestUnit, allowManyLargeUnits, solarMode) {
3022
+ const upUnitNano = solarMode ? nanoInUtcDay : unitNanoMap[smallestUnit + 1];
3023
+ if (upUnitNano) {
3024
+ const unitNano = unitNanoMap[smallestUnit];
3025
+ upUnitNano % ((roundingInc = clampEntity("roundingIncrement", roundingInc, 1, upUnitNano / unitNano - (solarMode ? 0 : 1), 1)) * unitNano) && throwRangeError(invalidEntity("roundingIncrement", roundingInc));
3026
+ } else {
3027
+ roundingInc = clampEntity("roundingIncrement", roundingInc, 1, allowManyLargeUnits ? 10 ** 9 : 1, 1);
3028
+ }
3029
+ return roundingInc;
3030
+ }
3031
+
3032
+ function validateUnitRange(optionName, unit, minUnit, maxUnit) {
3033
+ return null != unit && clampEntity(optionName, unit, minUnit, maxUnit, 1, unitNamesAsc),
3034
+ unit;
3035
+ }
3036
+
3037
+ function checkLargestSmallestUnit(largestUnit, smallestUnit) {
3038
+ smallestUnit > largestUnit && throwRangeError(flippedSmallestLargestUnit);
3039
+ }
3040
+
3041
+ function refineDiffOptions(roundingModeInvert, options, defaultLargestUnit, maxUnit = 9, minUnit = 0, defaultRoundingMode = 4) {
3042
+ options = normalizeOptions(options);
3043
+ let largestUnit = coerceLargestUnit(options, minUnit);
3044
+ let roundingInc = coerceRoundingIncInteger(options);
3045
+ let roundingMode = coerceRoundingMode(options, defaultRoundingMode);
3046
+ let smallestUnit = coerceSmallestUnit(options, minUnit, 1);
3047
+ return largestUnit = validateUnitRange("largestUnit", largestUnit, minUnit, maxUnit),
3048
+ smallestUnit = validateUnitRange(smallestUnitStr, smallestUnit, minUnit, maxUnit),
3049
+ null == largestUnit ? largestUnit = Math.max(defaultLargestUnit, smallestUnit) : checkLargestSmallestUnit(largestUnit, smallestUnit),
3050
+ roundingInc = validateRoundingInc(roundingInc, smallestUnit, 1), roundingModeInvert && (roundingMode = (roundingMode => roundingMode < 4 ? (roundingMode + 2) % 4 : roundingMode)(roundingMode)),
3051
+ [ largestUnit, smallestUnit, roundingInc, roundingMode ];
3052
+ }
3053
+
3054
+ function refineDurationRoundOptions(options, defaultLargestUnit, refineRelativeTo) {
3055
+ options = normalizeOptionsOrString(options, smallestUnitStr);
3056
+ let largestUnit = coerceLargestUnit(options);
3057
+ const relativeToInternals = refineRelativeTo(options.relativeTo);
3058
+ let roundingInc = coerceRoundingIncInteger(options);
3059
+ const roundingMode = coerceRoundingMode(options, 7);
3060
+ let smallestUnit = coerceSmallestUnit(options);
3061
+ return void 0 === largestUnit && void 0 === smallestUnit && throwRangeError(missingSmallestLargestUnit),
3062
+ null == smallestUnit && (smallestUnit = 0), null == largestUnit && (largestUnit = Math.max(smallestUnit, defaultLargestUnit)),
3063
+ checkLargestSmallestUnit(largestUnit, smallestUnit), roundingInc = validateRoundingInc(roundingInc, smallestUnit, 1),
3064
+ roundingInc > 1 && smallestUnit > 5 && largestUnit !== smallestUnit && throwRangeError("For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit"),
3065
+ [ largestUnit, smallestUnit, roundingInc, roundingMode, relativeToInternals ];
3066
+ }
3067
+
3068
+ function refineRoundingOptions(options, maxUnit = 6, solarMode) {
3069
+ let roundingInc = coerceRoundingIncInteger(options = normalizeOptionsOrString(options, smallestUnitStr));
3070
+ const roundingMode = coerceRoundingMode(options, 7);
3071
+ let smallestUnit = coerceSmallestUnit(options);
3072
+ return smallestUnit = requirePropDefined(smallestUnitStr, smallestUnit), smallestUnit = validateUnitRange(smallestUnitStr, smallestUnit, 0, maxUnit),
3073
+ roundingInc = validateRoundingInc(roundingInc, smallestUnit, void 0, solarMode),
3074
+ [ smallestUnit, roundingInc, roundingMode ];
3075
+ }
3076
+
3077
+ function refineTotalOptions(options, refineRelativeTo) {
3078
+ const relativeToInternals = refineRelativeTo((options = normalizeOptionsOrString(options, "unit")).relativeTo);
3079
+ let totalUnit = coerceTotalUnit(options);
3080
+ return totalUnit = requirePropDefined("unit", totalUnit), [ totalUnit, relativeToInternals ];
3081
+ }
3082
+
3083
+ function refineOverflowOptions(options) {
3084
+ return void 0 === options ? 0 : coerceOverflow(requireObjectLike(options));
3085
+ }
3086
+
3087
+ function refineZonedFieldOptions(options, defaultOffsetDisambig = 0) {
3088
+ options = normalizeOptions(options);
3089
+ const epochDisambig = coerceEpochDisambig(options);
3090
+ const offsetDisambig = coerceOffsetDisambig(options, defaultOffsetDisambig);
3091
+ return [ coerceOverflow(options), offsetDisambig, epochDisambig ];
3092
+ }
3093
+
3094
+ function refineEpochDisambigOptions(options) {
3095
+ return coerceEpochDisambig(normalizeOptions(options));
3096
+ }
3097
+
3098
+ function refineTimeDisplayTuple(options, maxSmallestUnit = 4) {
3099
+ const subsecDigits = coerceFractionalSecondDigits(options);
3100
+ const roundingMode = coerceRoundingMode(options, 4);
3101
+ const smallestUnit = coerceSmallestUnit(options);
3102
+ return [ roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, maxSmallestUnit), subsecDigits) ];
3103
+ }
3104
+
3105
+ function refineDateTimeDisplayOptions(options) {
3106
+ return options = normalizeOptions(options), [ coerceCalendarDisplay(options), ...refineTimeDisplayTuple(options) ];
3107
+ }
3108
+
3109
+ function refineDateDisplayOptions(options) {
3110
+ return coerceCalendarDisplay(normalizeOptions(options));
3111
+ }
3112
+
3113
+ function refineTimeDisplayOptions(options, maxSmallestUnit) {
3114
+ return refineTimeDisplayTuple(normalizeOptions(options), maxSmallestUnit);
3115
+ }
3116
+
3117
+ function refineZonedDateTimeDisplayOptions(options) {
3118
+ options = normalizeOptions(options);
3119
+ const calendarDisplay = coerceCalendarDisplay(options);
3120
+ const subsecDigits = coerceFractionalSecondDigits(options);
3121
+ const offsetDisplay = coerceOffsetDisplay(options);
3122
+ const roundingMode = coerceRoundingMode(options, 4);
3123
+ const smallestUnit = coerceSmallestUnit(options);
3124
+ return [ calendarDisplay, coerceTimeZoneDisplay(options), offsetDisplay, roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, 4), subsecDigits) ];
3125
+ }
3126
+
3127
+ function refineInstantDisplayOptions(options) {
3128
+ const subsecDigits = coerceFractionalSecondDigits(options = normalizeOptions(options));
3129
+ const roundingMode = coerceRoundingMode(options, 4);
3130
+ const smallestUnit = coerceSmallestUnit(options);
3131
+ return [ options.timeZone, roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, 4), subsecDigits) ];
3132
+ }
3133
+
3134
+ function resolveSmallestUnitAndSubsecDigits(smallestUnit, subsecDigits) {
3135
+ return null != smallestUnit ? [ unitNanoMap[smallestUnit], smallestUnit < 4 ? 9 - 3 * smallestUnit : -1 ] : [ void 0 === subsecDigits ? 1 : 10 ** (9 - subsecDigits), subsecDigits ];
3136
+ }
3137
+
3138
+ function refineDirectionOptions(options) {
3139
+ const normalizedOptions = normalizeOptionsOrString(options, "direction");
3140
+ const res = coerceDirection(normalizedOptions, 0);
3141
+ return res || throwRangeError(invalidEntity("direction", res)), res;
3142
+ }
3143
+
2832
3144
  const invalidEntity = invalidEntity$1;
2833
3145
 
2834
3146
  const missingField = fieldName => `Missing ${fieldName}`;
@@ -2855,6 +3167,10 @@ const invalidTimeZone = calendarId => invalidEntity$1("TimeZone", calendarId);
2855
3167
 
2856
3168
  const outOfBoundsDate = "Out-of-bounds date";
2857
3169
 
3170
+ const missingSmallestLargestUnit = "Required smallestUnit or largestUnit";
3171
+
3172
+ const flippedSmallestLargestUnit = "smallestUnit > largestUnit";
3173
+
2858
3174
  const failedParse = s => `Cannot parse: ${s}`;
2859
3175
 
2860
3176
  const invalidSubstring = substring => `Invalid substring: ${substring}`;
@@ -3040,21 +3356,45 @@ function modTrunc(num, divisor) {
3040
3356
  return num % divisor || 0;
3041
3357
  }
3042
3358
 
3359
+ function roundExpand(num) {
3360
+ return num < 0 ? Math.floor(num) : Math.ceil(num);
3361
+ }
3362
+
3043
3363
  function fabricateNearHalfFraction(halfCompare, sign = 1) {
3044
3364
  return sign * (.5 + halfCompare / 5);
3045
3365
  }
3046
3366
 
3047
- function hasHalf(num) {
3048
- return .5 === Math.abs(num % 1);
3367
+ function roundHalfExpand(num) {
3368
+ return Math.sign(num) * Math.round(Math.abs(num)) || 0;
3049
3369
  }
3050
3370
 
3051
- const isoCalendarId = "iso8601";
3371
+ function roundHalfFloor(num) {
3372
+ return hasHalf(num) ? Math.floor(num) : Math.round(num);
3373
+ }
3052
3374
 
3053
- const gregoryCalendarId = "gregory";
3375
+ function roundHalfCeil(num) {
3376
+ return hasHalf(num) ? Math.ceil(num) : Math.round(num);
3377
+ }
3054
3378
 
3055
- const gregoryEraOrigins = {
3056
- "bce": -1,
3057
- "ce": 0
3379
+ function roundHalfTrunc(num) {
3380
+ return hasHalf(num) ? Math.trunc(num) || 0 : Math.round(num);
3381
+ }
3382
+
3383
+ function roundHalfEven(num) {
3384
+ return hasHalf(num) ? (num = Math.trunc(num) || 0) + num % 2 : Math.round(num);
3385
+ }
3386
+
3387
+ function hasHalf(num) {
3388
+ return .5 === Math.abs(num % 1);
3389
+ }
3390
+
3391
+ const isoCalendarId = "iso8601";
3392
+
3393
+ const gregoryCalendarId = "gregory";
3394
+
3395
+ const gregoryEraOrigins = {
3396
+ "bce": -1,
3397
+ "ce": 0
3058
3398
  };
3059
3399
 
3060
3400
  function normalizeEraName(era) {
@@ -3255,6 +3595,10 @@ function epochNanoToSecMod(epochNano) {
3255
3595
  return [ Number(epochSec), Number(nano) ];
3256
3596
  }
3257
3597
 
3598
+ function epochNanoToMilli(epochNano) {
3599
+ return Number(divFloorBigInt(epochNano, bigNanoInMilli));
3600
+ }
3601
+
3258
3602
  function isoDateTimeToEpochNano(isoDateTime) {
3259
3603
  return isoDateToEpochNano(isoDateTime) + BigInt(timeFieldsToNano(isoDateTime));
3260
3604
  }
@@ -3272,10 +3616,10 @@ function isoDateToEpochMilli(isoDate) {
3272
3616
  }
3273
3617
 
3274
3618
  function isoDateToEpochDays(isoDate) {
3275
- return isoArgsToEpochDays(isoDate.year, isoDate.month, isoDate.day);
3619
+ return isoPartsToEpochDays(isoDate.year, isoDate.month, isoDate.day);
3276
3620
  }
3277
3621
 
3278
- function isoArgsToEpochDays(isoYear, isoMonth = 1, isoDay = 1) {
3622
+ function isoPartsToEpochDays(isoYear, isoMonth = 1, isoDay = 1) {
3279
3623
  const monthIndex = isoMonth - 1;
3280
3624
  return isoYear += Math.floor(monthIndex / 12), isoMonth = modFloor(monthIndex, 12),
3281
3625
  Date.UTC(isoYear % 400 - 400, isoMonth, 0) / 864e5 + 146097 * (divTrunc(isoYear, 400) + 1) + isoDay;
@@ -3355,23 +3699,23 @@ function diffIsoMonthSlots(year0, month0, year1, month1) {
3355
3699
  return 12 * (year1 - year0) + month1 - month0;
3356
3700
  }
3357
3701
 
3358
- function computeIsoDayOfWeek(isoDateFields) {
3359
- return modFloor(isoArgsToEpochDays(isoDateFields.year, isoDateFields.month, isoDateFields.day) + 4, 7) || 7;
3702
+ function computeIsoDayOfWeek(isoDate) {
3703
+ return modFloor(isoPartsToEpochDays(isoDate.year, isoDate.month, isoDate.day) + 4, 7) || 7;
3360
3704
  }
3361
3705
 
3362
- function computeIsoDayOfYear(isoDateFields) {
3363
- return isoArgsToEpochDays(isoDateFields.year, isoDateFields.month, isoDateFields.day) - isoArgsToEpochDays(isoDateFields.year) + 1;
3706
+ function computeIsoDayOfYear(isoDate) {
3707
+ return isoPartsToEpochDays(isoDate.year, isoDate.month, isoDate.day) - isoPartsToEpochDays(isoDate.year) + 1;
3364
3708
  }
3365
3709
 
3366
- function computeIsoWeekFields(isoDateFields) {
3367
- let yearOfWeek = isoDateFields.year;
3368
- let weekOfYear = Math.floor((computeIsoDayOfYear(isoDateFields) - computeIsoDayOfWeek(isoDateFields) + 10) / 7);
3710
+ function computeIsoWeekFields(isoDate) {
3711
+ let yearOfWeek = isoDate.year;
3712
+ let weekOfYear = Math.floor((computeIsoDayOfYear(isoDate) - computeIsoDayOfWeek(isoDate) + 10) / 7);
3369
3713
  let weeksInYear = computeIsoWeeksInYear(yearOfWeek);
3370
3714
  return weekOfYear < 1 ? weekOfYear = weeksInYear = computeIsoWeeksInYear(--yearOfWeek) : weekOfYear > weeksInYear && (weekOfYear = 1,
3371
3715
  weeksInYear = computeIsoWeeksInYear(++yearOfWeek)), {
3372
3716
  weekOfYear: weekOfYear,
3373
3717
  yearOfWeek: yearOfWeek,
3374
- Be: weeksInYear
3718
+ De: weeksInYear
3375
3719
  };
3376
3720
  }
3377
3721
 
@@ -3417,11 +3761,11 @@ function constrainIsoDateFields(isoDate, overflow) {
3417
3761
  }
3418
3762
 
3419
3763
  function computeCalendarDateFields(calendar, isoDate) {
3420
- return calendar ? calendar.ae(isoDate) : isoDate;
3764
+ return calendar ? calendar.de(isoDate) : isoDate;
3421
3765
  }
3422
3766
 
3423
3767
  function computeCalendarMonthCodeParts(calendar, year, month) {
3424
- return calendar ? calendar.L(year, month) : computeIsoMonthCodeParts(month);
3768
+ return calendar ? calendar.N(year, month) : computeIsoMonthCodeParts(month);
3425
3769
  }
3426
3770
 
3427
3771
  function computeCalendarEraFields(calendar, isoDate) {
@@ -3429,7 +3773,7 @@ function computeCalendarEraFields(calendar, isoDate) {
3429
3773
  }
3430
3774
 
3431
3775
  function computeCalendarIsoFieldsFromParts(calendar, year, month, day) {
3432
- return calendar ? calendar.de(year, month, day) : computeIsoFieldsFromParts(year, month, day);
3776
+ return calendar ? calendar.fe(year, month, day) : computeIsoFieldsFromParts(year, month, day);
3433
3777
  }
3434
3778
 
3435
3779
  function computeCalendarMonthsInYearForYear(calendar, year) {
@@ -3522,8 +3866,17 @@ function toString(arg) {
3522
3866
  String(arg);
3523
3867
  }
3524
3868
 
3525
- function toStringViaPrimitive(arg, entityName) {
3526
- return isObjectLike$1(arg) ? String(arg) : requireString(arg, entityName);
3869
+ function toPrimitiveWithStringHint(arg) {
3870
+ if (!isObjectLike$1(arg)) {
3871
+ return arg;
3872
+ }
3873
+ const exoticToPrimitive = arg[Symbol.toPrimitive];
3874
+ if (null != exoticToPrimitive) {
3875
+ "function" != typeof exoticToPrimitive && throwTypeError();
3876
+ const primitive = Reflect.apply(exoticToPrimitive, arg, [ "string" ]);
3877
+ return isObjectLike$1(primitive) && throwTypeError(), primitive;
3878
+ }
3879
+ return Date.prototype[Symbol.toPrimitive].call(arg, "string");
3527
3880
  }
3528
3881
 
3529
3882
  function toBigInt(bi) {
@@ -3535,193 +3888,10 @@ function toStrictInteger(arg, entityName) {
3535
3888
  return requireNumberIsInteger(toFiniteNumber(arg, entityName), entityName);
3536
3889
  }
3537
3890
 
3538
- function normalizeOptionsOrString(options, optionName) {
3539
- return "string" == typeof options ? ((optionName, optionVal) => {
3540
- const res = Object.create(null);
3541
- return res[optionName] = optionVal, res;
3542
- })(optionName, options) : requireObjectLike(options);
3543
- }
3544
-
3545
- const smallestUnitStr = "smallestUnit";
3546
-
3547
- const overflowMap = {
3548
- constrain: 0,
3549
- reject: 1
3550
- };
3551
-
3552
- const epochDisambigMap = {
3553
- compatible: 0,
3554
- reject: 1,
3555
- earlier: 2,
3556
- later: 3
3557
- };
3558
-
3559
- const offsetDisambigMap = {
3560
- reject: 0,
3561
- use: 1,
3562
- prefer: 2,
3563
- ignore: 3
3564
- };
3565
-
3566
- const calendarDisplayMap = {
3567
- auto: 0,
3568
- never: 1,
3569
- critical: 2,
3570
- always: 3
3571
- };
3572
-
3573
- const timeZoneDisplayMap = {
3574
- auto: 0,
3575
- never: 1,
3576
- critical: 2
3577
- };
3578
-
3579
- const offsetDisplayMap = {
3580
- auto: 0,
3581
- never: 1
3582
- };
3583
-
3584
- const roundingModeMap = {
3585
- floor: 0,
3586
- halfFloor: 1,
3587
- ceil: 2,
3588
- halfCeil: 3,
3589
- trunc: 4,
3590
- halfTrunc: 5,
3591
- expand: 6,
3592
- halfExpand: 7,
3593
- halfEven: 8
3594
- };
3595
-
3596
- const roundingModeFuncs = [ Math.floor, num => hasHalf(num) ? Math.floor(num) : Math.round(num), Math.ceil, num => hasHalf(num) ? Math.ceil(num) : Math.round(num), Math.trunc, num => hasHalf(num) ? Math.trunc(num) || 0 : Math.round(num), num => num < 0 ? Math.floor(num) : Math.ceil(num), num => Math.sign(num) * Math.round(Math.abs(num)) || 0, num => hasHalf(num) ? (num = Math.trunc(num) || 0) + num % 2 : Math.round(num) ];
3597
-
3598
- const directionMap = {
3599
- previous: -1,
3600
- next: 1
3601
- };
3602
-
3603
- function coerceRoundingIncInteger(options) {
3604
- const roundingInc = options.roundingIncrement;
3605
- return void 0 === roundingInc ? 1 : toIntegerWithTrunc(roundingInc, "roundingIncrement");
3606
- }
3607
-
3608
- function coerceFractionalSecondDigits(options) {
3609
- let subsecDigits = options.fractionalSecondDigits;
3610
- if (void 0 !== subsecDigits) {
3611
- if ("number" != typeof subsecDigits) {
3612
- if ("auto" === toString(subsecDigits)) {
3613
- return;
3614
- }
3615
- throwRangeError(invalidEntity("fractionalSecondDigits", subsecDigits));
3616
- }
3617
- subsecDigits = clampEntity("fractionalSecondDigits", Math.floor(subsecDigits), 0, 9, 1);
3618
- }
3619
- return subsecDigits;
3620
- }
3621
-
3622
- function coerceUnitOption(optionName, options, minUnit = 0, ensureDefined) {
3623
- let unitStr = options[optionName];
3624
- if (void 0 === unitStr) {
3625
- return ensureDefined ? minUnit : void 0;
3626
- }
3627
- if (unitStr = toString(unitStr), "auto" === unitStr) {
3628
- return ensureDefined ? minUnit : null;
3629
- }
3630
- let unit = unitNameMap[unitStr];
3631
- return void 0 === unit && (unit = durationFieldNamesAsc.indexOf(unitStr)), unit < 0 && throwRangeError(invalidChoice(optionName, unitStr, unitNameMap)),
3632
- unit;
3633
- }
3634
-
3635
- function coerceChoiceOption(optionName, enumNameMap, options, defaultChoice = 0) {
3636
- const enumArg = options[optionName];
3637
- if (void 0 === enumArg) {
3638
- return defaultChoice;
3639
- }
3640
- const enumStr = toString(enumArg);
3641
- const enumNum = enumNameMap[enumStr];
3642
- return void 0 === enumNum && throwRangeError(invalidChoice(optionName, enumStr, enumNameMap)),
3643
- enumNum;
3644
- }
3645
-
3646
- const coerceSmallestUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, smallestUnitStr);
3647
-
3648
- const coerceLargestUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, "largestUnit");
3649
-
3650
- const coerceTotalUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, "unit");
3651
-
3652
- const coerceOverflow = /*@__PURE__*/ bindArgs(coerceChoiceOption, "overflow", overflowMap);
3653
-
3654
- const coerceEpochDisambig = /*@__PURE__*/ bindArgs(coerceChoiceOption, "disambiguation", epochDisambigMap);
3655
-
3656
- const coerceOffsetDisambig = /*@__PURE__*/ bindArgs(coerceChoiceOption, "offset", offsetDisambigMap);
3657
-
3658
- const coerceCalendarDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "calendarName", calendarDisplayMap);
3659
-
3660
- const coerceTimeZoneDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "timeZoneName", timeZoneDisplayMap);
3661
-
3662
- const coerceOffsetDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "offset", offsetDisplayMap);
3663
-
3664
- const coerceRoundingMode = /*@__PURE__*/ bindArgs(coerceChoiceOption, "roundingMode", roundingModeMap);
3665
-
3666
- const coerceDirection = /*@__PURE__*/ bindArgs(coerceChoiceOption, "direction", directionMap);
3667
-
3668
- function validateRoundingInc(roundingInc, smallestUnit, allowManyLargeUnits, solarMode) {
3669
- const upUnitNano = solarMode ? nanoInUtcDay : unitNanoMap[smallestUnit + 1];
3670
- if (upUnitNano) {
3671
- const unitNano = unitNanoMap[smallestUnit];
3672
- upUnitNano % ((roundingInc = clampEntity("roundingIncrement", roundingInc, 1, upUnitNano / unitNano - (solarMode ? 0 : 1), 1)) * unitNano) && throwRangeError(invalidEntity("roundingIncrement", roundingInc));
3673
- } else {
3674
- roundingInc = clampEntity("roundingIncrement", roundingInc, 1, allowManyLargeUnits ? 10 ** 9 : 1, 1);
3675
- }
3676
- return roundingInc;
3677
- }
3678
-
3679
- function validateUnitRange(optionName, unit, minUnit, maxUnit) {
3680
- return null != unit && clampEntity(optionName, unit, minUnit, maxUnit, 1, unitNamesAsc),
3681
- unit;
3682
- }
3683
-
3684
- function checkLargestSmallestUnit(largestUnit, smallestUnit) {
3685
- smallestUnit > largestUnit && throwRangeError("smallestUnit > largestUnit");
3686
- }
3687
-
3688
- function refineDiffOptions(roundingModeInvert, options, defaultLargestUnit, maxUnit = 9, minUnit = 0, defaultRoundingMode = 4) {
3689
- options = normalizeOptions(options);
3690
- let largestUnit = coerceLargestUnit(options, minUnit);
3691
- let roundingInc = coerceRoundingIncInteger(options);
3692
- let roundingMode = coerceRoundingMode(options, defaultRoundingMode);
3693
- let smallestUnit = coerceSmallestUnit(options, minUnit, 1);
3694
- return largestUnit = validateUnitRange("largestUnit", largestUnit, minUnit, maxUnit),
3695
- smallestUnit = validateUnitRange(smallestUnitStr, smallestUnit, minUnit, maxUnit),
3696
- null == largestUnit ? largestUnit = Math.max(defaultLargestUnit, smallestUnit) : checkLargestSmallestUnit(largestUnit, smallestUnit),
3697
- roundingInc = validateRoundingInc(roundingInc, smallestUnit, 1), roundingModeInvert && (roundingMode = (roundingMode => roundingMode < 4 ? (roundingMode + 2) % 4 : roundingMode)(roundingMode)),
3698
- [ largestUnit, smallestUnit, roundingInc, roundingMode ];
3699
- }
3700
-
3701
- function refineRoundingOptions(options, maxUnit = 6, solarMode) {
3702
- let roundingInc = coerceRoundingIncInteger(options = normalizeOptionsOrString(options, smallestUnitStr));
3703
- const roundingMode = coerceRoundingMode(options, 7);
3704
- let smallestUnit = coerceSmallestUnit(options);
3705
- return smallestUnit = requirePropDefined(smallestUnitStr, smallestUnit), smallestUnit = validateUnitRange(smallestUnitStr, smallestUnit, 0, maxUnit),
3706
- roundingInc = validateRoundingInc(roundingInc, smallestUnit, void 0, solarMode),
3707
- [ smallestUnit, roundingInc, roundingMode ];
3708
- }
3709
-
3710
3891
  function combineDateAndTime(isoDate, time) {
3711
3892
  return pluckProps(calendarDateFieldNamesAsc, isoDate, pluckProps(timeFieldNamesAsc, time));
3712
3893
  }
3713
3894
 
3714
- function refineOverflowOptions(options) {
3715
- return void 0 === options ? 0 : coerceOverflow(requireObjectLike(options));
3716
- }
3717
-
3718
- function refineZonedFieldOptions(options, defaultOffsetDisambig = 0) {
3719
- options = normalizeOptions(options);
3720
- const epochDisambig = coerceEpochDisambig(options);
3721
- const offsetDisambig = coerceOffsetDisambig(options, defaultOffsetDisambig);
3722
- return [ coerceOverflow(options), offsetDisambig, epochDisambig ];
3723
- }
3724
-
3725
3895
  const epochNanoMax = /*@__PURE__*/ BigInt(1e8) * bigNanoInUtcDay;
3726
3896
 
3727
3897
  const epochNanoMin = /*@__PURE__*/ BigInt(-1e8) * bigNanoInUtcDay;
@@ -3737,18 +3907,18 @@ function checkIsoYearMonthInBounds(isoDate) {
3737
3907
  }
3738
3908
 
3739
3909
  function checkIsoDateInBounds(isoDate, allowPlainDateLowerEdge = 1) {
3740
- return checkIsoDateEpochNanoInBounds(isoDateToEpochNano(isoDate), allowPlainDateLowerEdge),
3910
+ const epochNano = isoDateToEpochNano(isoDate);
3911
+ return (epochNano < (allowPlainDateLowerEdge ? plainDateEpochNanoMin : epochNanoMin) || epochNano > epochNanoMax) && throwRangeError(outOfBoundsDate),
3741
3912
  isoDate;
3742
3913
  }
3743
3914
 
3744
3915
  function checkIsoDateTimeInBounds(isoDateTime) {
3745
- const epochNano = isoDateToEpochNano(isoDateTime);
3746
- return checkIsoDateEpochNanoInBounds(epochNano), epochNano !== plainDateEpochNanoMin || timeFieldsToNano(isoDateTime) || throwRangeError(outOfBoundsDate),
3747
- isoDateTime;
3916
+ return checkIsoDateTimeEpochNanoInBounds(isoDateTimeToEpochNano(isoDateTime)), isoDateTime;
3748
3917
  }
3749
3918
 
3750
- function checkIsoDateEpochNanoInBounds(epochNano, allowPlainDateLowerEdge = 1) {
3751
- (epochNano < (allowPlainDateLowerEdge ? plainDateEpochNanoMin : epochNanoMin) || epochNano > epochNanoMax) && throwRangeError(outOfBoundsDate);
3919
+ function checkIsoDateTimeEpochNanoInBounds(epochNano) {
3920
+ return (epochNano <= plainDateEpochNanoMin || epochNano >= epochNanoMax + bigNanoInUtcDay) && throwRangeError(outOfBoundsDate),
3921
+ epochNano;
3752
3922
  }
3753
3923
 
3754
3924
  function checkEpochNanoInBounds(epochNano) {
@@ -3760,108 +3930,41 @@ function isoDateTimeAndOffsetToEpochNano(isoDateTime, offsetNano) {
3760
3930
  return checkEpochNanoInBounds(isoDateToEpochNano(isoDateTime) + BigInt(timeFieldsToNano(isoDateTime) - offsetNano));
3761
3931
  }
3762
3932
 
3763
- function createEpochNanoSlots(epochNano) {
3764
- return {
3765
- epochNanoseconds: epochNano
3766
- };
3767
- }
3768
-
3769
- function createZonedEpochNanoSlots(epochNano, timeZone, calendar) {
3770
- return {
3771
- calendar: calendar,
3772
- timeZone: timeZone,
3773
- epochNanoseconds: epochNano
3774
- };
3775
- }
3776
-
3777
- function createDateTimeSlots(isoDateTime, calendar) {
3778
- return pluckProps(timeFieldNamesAsc, isoDateTime, createDateSlots(isoDateTime, calendar));
3779
- }
3780
-
3781
- function createDateSlots(isoDate, calendar) {
3782
- return pluckProps(calendarDateFieldNamesAsc, isoDate, {
3783
- calendar: calendar
3784
- });
3785
- }
3786
-
3787
- function createTimeSlots(time) {
3788
- return pluckProps(timeFieldNamesAsc, time);
3789
- }
3790
-
3791
- function createDurationSlots(durationFields) {
3792
- return pluckProps(durationFieldNamesAsc, durationFields, {
3793
- sign: computeDurationSign(durationFields)
3794
- });
3795
- }
3796
-
3797
- function getEpochMilli(slots) {
3798
- return epochNano = slots.epochNanoseconds, Number(divFloorBigInt(epochNano, bigNanoInMilli));
3799
- var epochNano;
3933
+ function roundNumberToInc(num, roundingInc, roundingMode) {
3934
+ return roundWithMode(num / roundingInc, roundingMode) * roundingInc;
3800
3935
  }
3801
3936
 
3802
- function getEpochNano(slots) {
3803
- return slots.epochNanoseconds;
3937
+ function roundWithMode(num, roundingMode) {
3938
+ return roundingModeFuncs[roundingMode](num);
3804
3939
  }
3805
3940
 
3806
- function totalDuration(refineRelativeTo, slots, options) {
3807
- const maxDurationUnit = getMaxDurationUnit(slots);
3808
- const [totalUnit, relativeToSlots] = ((options, refineRelativeTo) => {
3809
- const relativeToInternals = refineRelativeTo((options = normalizeOptionsOrString(options, "unit")).relativeTo);
3810
- let totalUnit = coerceTotalUnit(options);
3811
- return totalUnit = requirePropDefined("unit", totalUnit), [ totalUnit, relativeToInternals ];
3812
- })(options, refineRelativeTo);
3813
- const maxUnit = Math.max(totalUnit, maxDurationUnit);
3814
- const isZoned = relativeToSlots && isZonedEpochSlots(relativeToSlots);
3815
- if (!relativeToSlots && isUniformUnit(maxUnit, isZoned)) {
3816
- return totalDayTimeDuration(slots, totalUnit);
3817
- }
3818
- if (relativeToSlots || throwRangeError("Missing relativeTo"), !slots.sign && isUniformUnit(totalUnit, isZoned)) {
3819
- return 0;
3820
- }
3821
- const [balancedDuration, endEpochNano, relativeOps] = spanRelativeDuration(relativeToSlots, slots, totalUnit);
3822
- return isUniformUnit(totalUnit, isZoned) ? totalDayTimeDuration(balancedDuration, totalUnit) : totalRelativeDuration(balancedDuration, endEpochNano, totalUnit, relativeOps);
3941
+ function totalRelativeUnit(wholeValue, sign, endEpochNano, moveValueToEpochNano) {
3942
+ const unitWindow = clampRelativeUnitValue(wholeValue, sign, moveValueToEpochNano, endEpochNano);
3943
+ return interpolateRelativeUnitWindow(unitWindow, Number(endEpochNano - unitWindow.I) / Number(unitWindow.O - unitWindow.I));
3823
3944
  }
3824
3945
 
3825
- function totalRelativeDuration(durationFields, endEpochNano, totalUnit, relativeOps) {
3826
- const sign = computeDurationSign(durationFields) || 1;
3827
- const nudgeWindow = clampRelativeDuration(clearDurationFields(totalUnit, durationFields), totalUnit, sign, relativeOps, endEpochNano);
3828
- const epochNano0 = nudgeWindow.ee;
3829
- const epochNano1 = nudgeWindow.te;
3830
- const denom = Number(epochNano1 - epochNano0);
3831
- const numerator = Number(endEpochNano - epochNano0);
3832
- return nudgeWindow.pe[durationFieldNamesAsc[totalUnit]] + numerator / denom * sign;
3946
+ function roundRelativeUnitWindow(unitWindow, endEpochNano, roundingInc, roundingMode) {
3947
+ return roundNumberToInc(interpolateRelativeUnitWindow(unitWindow, computeEpochNanoFrac(endEpochNano, unitWindow.I, unitWindow.O)), roundingInc, roundingMode);
3833
3948
  }
3834
3949
 
3835
- function totalDayTimeDuration(durationFields, totalUnit) {
3836
- return divideBigNanoToExactNumber(durationDayTimeToBigNano(durationFields), unitNanoMap[totalUnit]);
3950
+ function clampRelativeUnitValue(startValue, valueDelta, moveValueToEpochNano, epochNanoProgress) {
3951
+ let unitWindow = computeRelativeUnitWindow(startValue, valueDelta, moveValueToEpochNano);
3952
+ return ((epochNanoProgress, epochNano0, epochNano1, sign) => sign > 0 ? epochNano0 <= epochNanoProgress && epochNanoProgress <= epochNano1 : epochNano1 <= epochNanoProgress && epochNanoProgress <= epochNano0)(epochNanoProgress, unitWindow.I, unitWindow.O, Math.sign(valueDelta)) || (unitWindow = computeRelativeUnitWindow(startValue + valueDelta, valueDelta, moveValueToEpochNano)),
3953
+ unitWindow;
3837
3954
  }
3838
3955
 
3839
- function clampRelativeDuration(durationFields, clampUnit, clampDistance, relativeOps, epochNanoProgress) {
3840
- const unitName = durationFieldNamesAsc[clampUnit];
3841
- let startDurationFields = durationFields;
3842
- let shifted = 0;
3843
- let window = computeRelativeDurationWindow(startDurationFields, unitName, clampDistance, relativeOps);
3844
- return epochNanoProgress && !((epochNanoProgress, epochNano0, epochNano1, sign) => sign > 0 ? compareBigInts(epochNano0, epochNanoProgress) <= 0 && compareBigInts(epochNanoProgress, epochNano1) <= 0 : compareBigInts(epochNano1, epochNanoProgress) <= 0 && compareBigInts(epochNanoProgress, epochNano0) <= 0)(epochNanoProgress, window.ee, window.te, Math.sign(clampDistance)) && (startDurationFields = {
3845
- ...durationFields,
3846
- [unitName]: durationFields[unitName] + clampDistance
3847
- }, shifted = 1, window = computeRelativeDurationWindow(startDurationFields, unitName, clampDistance, relativeOps)),
3848
- {
3849
- ...window,
3850
- pe: startDurationFields,
3851
- Ae: shifted
3956
+ function computeRelativeUnitWindow(startValue, valueDelta, moveValueToEpochNano) {
3957
+ const endValue = startValue + valueDelta;
3958
+ return {
3959
+ ve: startValue,
3960
+ qe: endValue,
3961
+ I: moveValueToEpochNano(startValue),
3962
+ O: moveValueToEpochNano(endValue)
3852
3963
  };
3853
3964
  }
3854
3965
 
3855
- function computeRelativeDurationWindow(startDurationFields, unitName, clampDistance, relativeOps) {
3856
- const endDurationFields = {
3857
- ...startDurationFields,
3858
- [unitName]: startDurationFields[unitName] + clampDistance
3859
- };
3860
- return {
3861
- ee: moveRelativeToEpochNano(relativeOps, startDurationFields),
3862
- te: moveRelativeToEpochNano(relativeOps, endDurationFields),
3863
- se: endDurationFields
3864
- };
3966
+ function interpolateRelativeUnitWindow(unitWindow, fraction) {
3967
+ return unitWindow.ve + fraction * (unitWindow.qe - unitWindow.ve);
3865
3968
  }
3866
3969
 
3867
3970
  function computeEpochNanoFrac(epochNanoProgress, epochNano0, epochNano1) {
@@ -3876,76 +3979,52 @@ function computeEpochNanoFrac(epochNanoProgress, epochNano0, epochNano1) {
3876
3979
  return compareBigInts(absNumerator, absDenom) <= 0 ? absNumerator === absDenom ? fracSign : fabricateNearHalfFraction(compareBigInts(2n * absNumerator, absDenom), fracSign) : Number(numeratorBig) / Number(denomBig);
3877
3980
  }
3878
3981
 
3879
- function roundZonedEpochSlotsToUnit(slots, smallestUnit, roundingInc, roundingMode) {
3880
- let {epochNanoseconds: epochNanoseconds} = slots;
3881
- const {timeZone: timeZone, calendar: calendar} = slots;
3882
- if (0 === smallestUnit && 1 === roundingInc) {
3883
- return {
3884
- epochNanoseconds: epochNanoseconds,
3885
- timeZone: timeZone,
3886
- calendar: calendar
3887
- };
3888
- }
3889
- if (6 === smallestUnit) {
3890
- const isoFields0 = combineDateAndTime(zonedEpochSlotsToIso(slots), timeFieldDefaults);
3891
- const isoFields1 = combineDateAndTime(moveByDays(isoFields0, 1), timeFieldDefaults);
3892
- const epochNano0 = getStartOfDayInstantFor(timeZone, isoFields0);
3893
- const epochNano1 = getStartOfDayInstantFor(timeZone, isoFields1);
3894
- epochNanoseconds = roundWithMode(computeZonedDayRoundFrac(epochNanoseconds, epochNano0, epochNano1), roundingMode) ? epochNano1 : epochNano0;
3895
- } else {
3896
- const isoDateTime = zonedEpochSlotsToIso(slots);
3897
- const offsetNano = isoDateTime.offsetNanoseconds;
3898
- epochNanoseconds = getMatchingInstantFor(timeZone, roundDateTimeToNano(isoDateTime, computeNanoInc(smallestUnit, roundingInc), roundingMode), offsetNano, 2, 0, 1);
3899
- }
3982
+ function createEpochNanoSlots(epochNano) {
3900
3983
  return {
3901
- epochNanoseconds: epochNanoseconds,
3902
- timeZone: timeZone,
3903
- calendar: calendar
3984
+ epochNanoseconds: epochNano
3904
3985
  };
3905
3986
  }
3906
3987
 
3907
- function computeZonedHoursInDay(slots) {
3908
- const {timeZone: timeZone} = slots;
3909
- const isoFields0 = combineDateAndTime(zonedEpochSlotsToIso(slots), timeFieldDefaults);
3910
- const isoFields1 = combineDateAndTime(moveByDays(isoFields0, 1), timeFieldDefaults);
3911
- const epochNano0 = getStartOfDayInstantFor(timeZone, isoFields0);
3912
- return divideBigNanoToExactNumber(getStartOfDayInstantFor(timeZone, isoFields1) - epochNano0, nanoInHour);
3913
- }
3914
-
3915
- function computeZonedStartOfDay(slots) {
3916
- const {timeZone: timeZone, calendar: calendar} = slots;
3917
- return createZonedEpochNanoSlots(getStartOfDayInstantFor(timeZone, combineDateAndTime(zonedEpochSlotsToIso(slots), timeFieldDefaults)), timeZone, calendar);
3988
+ function createZonedEpochNanoSlots(epochNano, timeZone, calendar) {
3989
+ return {
3990
+ calendar: calendar,
3991
+ timeZone: timeZone,
3992
+ epochNanoseconds: epochNano
3993
+ };
3918
3994
  }
3919
3995
 
3920
- function computeZonedDayRoundFrac(epochNano, epochNano0, epochNano1) {
3921
- return computeEpochNanoFrac(epochNano < epochNano1 ? epochNano : epochNano1 - 1n, epochNano0, epochNano1);
3996
+ function createDateTimeSlots(isoDateTime, calendar) {
3997
+ return pluckProps(timeFieldNamesAsc, isoDateTime, createDateSlots(isoDateTime, calendar));
3922
3998
  }
3923
3999
 
3924
- function roundDateTimeToNano(isoDateTime, nanoInc, roundingMode) {
3925
- const [roundedTimeFields, dayDelta] = roundTimeToNano(isoDateTime, nanoInc, roundingMode);
3926
- const roundedIsoDateTime = combineDateAndTime(moveByDays(isoDateTime, dayDelta), roundedTimeFields);
3927
- return checkIsoDateTimeInBounds(roundedIsoDateTime), roundedIsoDateTime;
4000
+ function createDateSlots(isoDate, calendar) {
4001
+ return pluckProps(calendarDateFieldNamesAsc, isoDate, {
4002
+ calendar: calendar
4003
+ });
3928
4004
  }
3929
4005
 
3930
- function roundTimeToNano(timeFields, nanoInc, roundingMode) {
3931
- return nanoToTimeAndDay(roundNumberToInc(timeFieldsToNano(timeFields), nanoInc, roundingMode));
4006
+ function createTimeSlots(time) {
4007
+ return pluckProps(timeFieldNamesAsc, time);
3932
4008
  }
3933
4009
 
3934
- function roundToMinute(offsetNano) {
3935
- return roundNumberToInc(offsetNano, nanoInMinute, 7);
4010
+ function createDurationSlots(durationFields) {
4011
+ return pluckProps(durationFieldNamesAsc, durationFields, {
4012
+ sign: computeDurationSign(durationFields)
4013
+ });
3936
4014
  }
3937
4015
 
3938
- function computeNanoInc(smallestUnit, roundingInc) {
3939
- return unitNanoMap[smallestUnit] * roundingInc;
4016
+ function roundZonedEpochSlotsToUnit(slots, smallestUnit, roundingInc, roundingMode) {
4017
+ return createZonedEpochNanoSlots(6 === smallestUnit ? roundZonedEpochToDay(slots, roundingMode) : roundZonedEpochToTime(slots, smallestUnit, roundingInc, roundingMode), slots.timeZone, slots.calendar);
3940
4018
  }
3941
4019
 
3942
- function computeBigNanoInc(smallestUnit, roundingInc) {
3943
- return BigInt(unitNanoMap[smallestUnit]) * BigInt(roundingInc);
4020
+ function computeZonedHoursInDay(slots) {
4021
+ const [epochNano0, epochNano1] = computeZonedDayEpochInterval(slots);
4022
+ return divideBigNanoToExactNumber(epochNano1 - epochNano0, nanoInHour);
3944
4023
  }
3945
4024
 
3946
- function roundDayTimeDurationByInc(durationFields, nanoInc, roundingMode) {
3947
- const maxUnit = Math.min(getMaxDurationUnit(durationFields), 6);
3948
- return nanoToDurationDayTimeFields(roundBigNanoToInc(durationDayTimeToBigNano(durationFields), BigInt(nanoInc), roundingMode), maxUnit);
4025
+ function computeZonedStartOfDay(slots) {
4026
+ const {timeZone: timeZone, calendar: calendar} = slots;
4027
+ return createZonedEpochNanoSlots(getStartOfDayInstantFor(timeZone, combineDateAndTime(zonedEpochSlotsToIso(slots), timeFieldDefaults)), timeZone, calendar);
3949
4028
  }
3950
4029
 
3951
4030
  function roundRelativeDuration(durationFields, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode, relativeOps, isZoned) {
@@ -3962,7 +4041,7 @@ function roundRelativeDuration(durationFields, endEpochNano, largestUnit, smalle
3962
4041
  }
3963
4042
  const baseDurationFields = clearDurationFields(currentUnit, durationFields);
3964
4043
  baseDurationFields[durationFieldNamesAsc[currentUnit]] += sign;
3965
- const thresholdCompare = compareBigInts(endEpochNano, moveRelativeToEpochNano(relativeOps, baseDurationFields));
4044
+ const thresholdCompare = compareBigInts(endEpochNano, moveRelativeMarkerToEpochNano(relativeOps, baseDurationFields));
3966
4045
  if (thresholdCompare && thresholdCompare !== sign) {
3967
4046
  break;
3968
4047
  }
@@ -3973,55 +4052,60 @@ function roundRelativeDuration(durationFields, endEpochNano, largestUnit, smalle
3973
4052
  roundedDurationFields;
3974
4053
  }
3975
4054
 
3976
- function roundBigNanoToInc(bigNano, bigNanoInc, roundingMode) {
3977
- return roundBigNanoToIncWithTail(bigNano, bigNanoInc, roundingMode, bigNano / bigNanoInc % 2n);
4055
+ function roundDayTimeDurationByInc(durationFields, nanoInc, roundingMode) {
4056
+ const maxUnit = Math.min(getMaxDurationUnit(durationFields), 6);
4057
+ return nanoToDurationDayTimeFields(roundBigNanoToInc(durationDayTimeToBigNano(durationFields), BigInt(nanoInc), roundingMode), maxUnit);
3978
4058
  }
3979
4059
 
3980
- function roundBigNanoToDayOriginInc(bigNano, bigNanoInc, roundingMode) {
3981
- const [day, timeNano] = divModFloorBigInt(bigNano, bigNanoInUtcDay);
3982
- const dayOriginNano = day * bigNanoInUtcDay;
3983
- return dayOriginNano + roundBigNanoToIncWithTail(timeNano, bigNanoInc, roundingMode, (dayOriginNano / bigNanoInc + timeNano / bigNanoInc) % 2n);
4060
+ function roundZonedEpochToDay(slots, roundingMode) {
4061
+ const [epochNano0, epochNano1] = computeZonedDayEpochInterval(slots);
4062
+ return roundZonedEpochToBounds(slots.epochNanoseconds, epochNano0, epochNano1, roundingMode);
3984
4063
  }
3985
4064
 
3986
- function roundBigNanoToIncWithTail(bigNano, bigNanoInc, roundingMode, quotientTail) {
3987
- const quotient = bigNano / bigNanoInc;
3988
- const remainder = bigNano % bigNanoInc;
3989
- let fraction = 0;
3990
- remainder && (fraction = fabricateNearHalfFraction(compareBigInts(2n * (remainder < 0n ? -remainder : remainder), bigNanoInc), Math.sign(Number(remainder))));
3991
- const roundedTail = roundWithMode(Number(quotientTail) + fraction, roundingMode);
3992
- return (quotient - quotientTail + BigInt(roundedTail)) * bigNanoInc;
4065
+ function roundZonedEpochToTime(slots, smallestUnit, roundingInc, roundingMode) {
4066
+ if (0 === smallestUnit && 1 === roundingInc) {
4067
+ return slots.epochNanoseconds;
4068
+ }
4069
+ const isoDateTime = zonedEpochSlotsToIso(slots);
4070
+ return getMatchingInstantFor(slots.timeZone, roundDateTimeToInc(isoDateTime, computeNanoInc(smallestUnit, roundingInc), roundingMode), isoDateTime.offsetNanoseconds, 2, 0, 1);
3993
4071
  }
3994
4072
 
3995
- function roundNumberToInc(num, roundingInc, roundingMode) {
3996
- return roundWithMode(num / roundingInc, roundingMode) * roundingInc;
4073
+ function roundDateTimeToInc(isoDateTime, nanoInc, roundingMode) {
4074
+ const [roundedTimeFields, dayDelta] = roundTimeToInc(isoDateTime, nanoInc, roundingMode);
4075
+ const roundedIsoDateTime = combineDateAndTime(moveDateByDays(isoDateTime, dayDelta), roundedTimeFields);
4076
+ return checkIsoDateTimeInBounds(roundedIsoDateTime), roundedIsoDateTime;
3997
4077
  }
3998
4078
 
3999
- function roundWithMode(num, roundingMode) {
4000
- return roundingModeFuncs[roundingMode](num);
4079
+ function roundTimeToInc(timeFields, nanoInc, roundingMode) {
4080
+ return nanoToTimeAndDay(roundNumberToInc(timeFieldsToNano(timeFields), nanoInc, roundingMode));
4001
4081
  }
4002
4082
 
4003
- function nudgeDayTimeDuration(sign, durationFields, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode) {
4004
- const bigNano = durationDayTimeToBigNano(durationFields);
4005
- const roundedBigNano = roundBigNanoToInc(bigNano, computeBigNanoInc(smallestUnit, roundingInc), roundingMode);
4006
- const nanoDiff = roundedBigNano - bigNano;
4007
- const expandedBigUnit = Math.sign(Number(roundedBigNano / bigNanoInUtcDay) - Number(bigNano / bigNanoInUtcDay)) === sign;
4008
- const roundedDayTimeFields = nanoToDurationDayTimeFields(roundedBigNano, Math.min(largestUnit, 6));
4009
- return [ {
4083
+ function nudgeRelativeDuration(sign, durationFields, endEpochNano, _largestUnit, smallestUnit, roundingInc, roundingMode, relativeOps) {
4084
+ const smallestUnitFieldName = durationFieldNamesAsc[smallestUnit];
4085
+ const baseDurationFields = clearDurationFields(smallestUnit, durationFields);
4086
+ 7 === smallestUnit && (durationFields = {
4010
4087
  ...durationFields,
4011
- ...roundedDayTimeFields
4012
- }, endEpochNano + nanoDiff, expandedBigUnit ];
4088
+ weeks: durationFields.weeks + Math.trunc(durationFields.days / 7)
4089
+ });
4090
+ const truncedVal = divTrunc(durationFields[smallestUnitFieldName], roundingInc) * roundingInc;
4091
+ const nudgeWindow = clampRelativeUnitValue(truncedVal, roundingInc * sign, value => (baseDurationFields[smallestUnitFieldName] = value,
4092
+ moveRelativeMarkerToEpochNano(relativeOps, baseDurationFields)), endEpochNano);
4093
+ const roundedVal = roundRelativeUnitWindow(nudgeWindow, endEpochNano, roundingInc, roundingMode);
4094
+ return baseDurationFields[smallestUnitFieldName] = roundedVal, [ baseDurationFields, roundedVal === nudgeWindow.qe ? nudgeWindow.O : nudgeWindow.I, roundedVal !== truncedVal ];
4013
4095
  }
4014
4096
 
4015
4097
  function nudgeZonedTimeDuration(sign, durationFields, endEpochNano, _largestUnit, smallestUnit, roundingInc, roundingMode, relativeOps) {
4016
4098
  const timeNano = Number(durationTimeToBigNano(durationFields));
4017
4099
  const nanoInc = computeNanoInc(smallestUnit, roundingInc);
4018
4100
  let roundedTimeNano = roundNumberToInc(timeNano, nanoInc, roundingMode);
4019
- const dayWindow = clampRelativeDuration({
4101
+ const dateDurationFields = {
4020
4102
  ...durationFields,
4021
4103
  ...durationTimeFieldDefaults
4022
- }, 6, sign, relativeOps, endEpochNano);
4023
- const dayEpochNano0 = dayWindow.ee;
4024
- const dayEpochNano1 = dayWindow.te;
4104
+ };
4105
+ const dayWindow = clampRelativeUnitValue(dateDurationFields.days, sign, days => (dateDurationFields.days = days,
4106
+ moveRelativeMarkerToEpochNano(relativeOps, dateDurationFields)), endEpochNano);
4107
+ const dayEpochNano0 = dayWindow.I;
4108
+ const dayEpochNano1 = dayWindow.O;
4025
4109
  const beyondDayNano = roundedTimeNano - Number(dayEpochNano1 - dayEpochNano0);
4026
4110
  let dayDelta = 0;
4027
4111
  beyondDayNano && Math.sign(beyondDayNano) !== sign ? endEpochNano = dayEpochNano0 + BigInt(roundedTimeNano) : (dayDelta += sign,
@@ -4034,32 +4118,58 @@ function nudgeZonedTimeDuration(sign, durationFields, endEpochNano, _largestUnit
4034
4118
  }, endEpochNano, Boolean(dayDelta) ];
4035
4119
  }
4036
4120
 
4037
- function nudgeRelativeDuration(sign, durationFields, endEpochNano, _largestUnit, smallestUnit, roundingInc, roundingMode, relativeOps) {
4038
- const smallestUnitFieldName = durationFieldNamesAsc[smallestUnit];
4039
- const baseDurationFields = clearDurationFields(smallestUnit, durationFields);
4040
- 7 === smallestUnit && (durationFields = {
4121
+ function nudgeDayTimeDuration(sign, durationFields, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode) {
4122
+ const bigNano = durationDayTimeToBigNano(durationFields);
4123
+ const roundedBigNano = roundBigNanoToInc(bigNano, computeBigNanoInc(smallestUnit, roundingInc), roundingMode);
4124
+ const nanoDiff = roundedBigNano - bigNano;
4125
+ const expandedBigUnit = Math.sign(Number(roundedBigNano / bigNanoInUtcDay) - Number(bigNano / bigNanoInUtcDay)) === sign;
4126
+ const roundedDayTimeFields = nanoToDurationDayTimeFields(roundedBigNano, Math.min(largestUnit, 6));
4127
+ return [ {
4041
4128
  ...durationFields,
4042
- weeks: durationFields.weeks + Math.trunc(durationFields.days / 7)
4043
- });
4044
- const truncedVal = divTrunc(durationFields[smallestUnitFieldName], roundingInc) * roundingInc;
4045
- baseDurationFields[smallestUnitFieldName] = truncedVal;
4046
- const nudgeWindow = clampRelativeDuration(baseDurationFields, smallestUnit, roundingInc * sign, relativeOps, endEpochNano);
4047
- const epochNano0 = nudgeWindow.ee;
4048
- const epochNano1 = nudgeWindow.te;
4049
- const frac = computeEpochNanoFrac(endEpochNano, epochNano0, epochNano1);
4050
- const windowStartVal = nudgeWindow.pe[smallestUnitFieldName];
4051
- const windowEndVal = nudgeWindow.se[smallestUnitFieldName];
4052
- const roundedVal = roundNumberToInc(windowStartVal + frac * sign * roundingInc, roundingInc, roundingMode);
4053
- const roundedToEnd = roundedVal === windowEndVal;
4054
- return baseDurationFields[smallestUnitFieldName] = roundedVal, [ baseDurationFields, roundedToEnd ? epochNano1 : epochNano0, nudgeWindow.Ae || roundedToEnd ];
4055
- }
4056
-
4057
- function getTimeZoneTransitionEpochNanoseconds(slots, options) {
4058
- return slots.timeZone.O(slots.epochNanoseconds, (options => {
4059
- const normalizedOptions = normalizeOptionsOrString(options, "direction");
4060
- const res = coerceDirection(normalizedOptions, 0);
4061
- return res || throwRangeError(invalidEntity("direction", res)), res;
4062
- })(options));
4129
+ ...roundedDayTimeFields
4130
+ }, endEpochNano + nanoDiff, expandedBigUnit ];
4131
+ }
4132
+
4133
+ function computeZonedDayEpochInterval(slots) {
4134
+ const {timeZone: timeZone} = slots;
4135
+ const isoDateTime0 = combineDateAndTime(zonedEpochSlotsToIso(slots), timeFieldDefaults);
4136
+ const isoDateTime1 = combineDateAndTime(moveDateByDays(isoDateTime0, 1), timeFieldDefaults);
4137
+ return [ getStartOfDayInstantFor(timeZone, isoDateTime0), getStartOfDayInstantFor(timeZone, isoDateTime1) ];
4138
+ }
4139
+
4140
+ function roundZonedEpochToBounds(epochNano, epochNano0, epochNano1, roundingMode) {
4141
+ return roundWithMode(computeEpochNanoFrac(epochNano < epochNano1 ? epochNano : epochNano1 - 1n, epochNano0, epochNano1), roundingMode) ? epochNano1 : epochNano0;
4142
+ }
4143
+
4144
+ function roundToMinute(offsetNano) {
4145
+ return roundNumberToInc(offsetNano, nanoInMinute, 7);
4146
+ }
4147
+
4148
+ function roundBigNanoToInc(bigNano, bigNanoInc, roundingMode) {
4149
+ return roundBigNanoToIncWithTail(bigNano, bigNanoInc, roundingMode, bigNano / bigNanoInc % 2n);
4150
+ }
4151
+
4152
+ function roundBigNanoToDayOriginInc(bigNano, bigNanoInc, roundingMode) {
4153
+ const [day, timeNano] = divModFloorBigInt(bigNano, bigNanoInUtcDay);
4154
+ const dayOriginNano = day * bigNanoInUtcDay;
4155
+ return dayOriginNano + roundBigNanoToIncWithTail(timeNano, bigNanoInc, roundingMode, (dayOriginNano / bigNanoInc + timeNano / bigNanoInc) % 2n);
4156
+ }
4157
+
4158
+ function roundBigNanoToIncWithTail(bigNano, bigNanoInc, roundingMode, quotientTail) {
4159
+ const quotient = bigNano / bigNanoInc;
4160
+ const remainder = bigNano % bigNanoInc;
4161
+ let fraction = 0;
4162
+ remainder && (fraction = fabricateNearHalfFraction(compareBigInts(2n * (remainder < 0n ? -remainder : remainder), bigNanoInc), Math.sign(Number(remainder))));
4163
+ const roundedTail = roundWithMode(Number(quotientTail) + fraction, roundingMode);
4164
+ return (quotient - quotientTail + BigInt(roundedTail)) * bigNanoInc;
4165
+ }
4166
+
4167
+ function computeNanoInc(smallestUnit, roundingInc) {
4168
+ return unitNanoMap[smallestUnit] * roundingInc;
4169
+ }
4170
+
4171
+ function computeBigNanoInc(smallestUnit, roundingInc) {
4172
+ return BigInt(unitNanoMap[smallestUnit]) * BigInt(roundingInc);
4063
4173
  }
4064
4174
 
4065
4175
  const zonedEpochSlotsToIso = /*@__PURE__*/ memoize(_zonedEpochSlotsToIso, WeakMap);
@@ -4078,7 +4188,7 @@ function getMatchingInstantFor(timeZone, isoDateTime, offsetNano, offsetDisambig
4078
4188
  return isoDateTimeAndOffsetToEpochNano(isoDateTime, offsetNano);
4079
4189
  }
4080
4190
  2 !== offsetDisambig && 0 !== offsetDisambig || checkIsoDateInBounds(isoDateTime, 0);
4081
- const possibleEpochNanos = timeZone.N(isoDateTime);
4191
+ const possibleEpochNanos = timeZone.R(isoDateTime);
4082
4192
  if (void 0 !== offsetNano && 3 !== offsetDisambig) {
4083
4193
  const matchingEpochNano = ((possibleEpochNanos, isoDateTime, offsetNano, fuzzy) => {
4084
4194
  const zonedEpochNano = isoDateTimeToEpochNano(isoDateTime);
@@ -4098,7 +4208,7 @@ function getMatchingInstantFor(timeZone, isoDateTime, offsetNano, offsetDisambig
4098
4208
  return hasZ ? isoDateTimeToEpochNano(isoDateTime) : getSingleInstantFor(timeZone, isoDateTime, epochDisambig, possibleEpochNanos);
4099
4209
  }
4100
4210
 
4101
- function getSingleInstantFor(timeZone, isoDateTime, disambig = 0, possibleEpochNanos = timeZone.N(isoDateTime)) {
4211
+ function getSingleInstantFor(timeZone, isoDateTime, disambig = 0, possibleEpochNanos = timeZone.R(isoDateTime)) {
4102
4212
  if (1 === possibleEpochNanos.length) {
4103
4213
  return possibleEpochNanos[0];
4104
4214
  }
@@ -4112,32 +4222,25 @@ function getSingleInstantFor(timeZone, isoDateTime, disambig = 0, possibleEpochN
4112
4222
  gapNano))(timeZone.B(zonedEpochNano + bigNanoInUtcDay) - startOffsetNano);
4113
4223
  })(timeZone, zonedEpochNano);
4114
4224
  const shiftedIsoDateTime = epochNanoToIsoDateTime(zonedEpochNano + BigInt(gapNano * (2 === disambig ? -1 : 1)));
4115
- return (possibleEpochNanos = timeZone.N(shiftedIsoDateTime))[2 === disambig ? 0 : possibleEpochNanos.length - 1];
4225
+ return (possibleEpochNanos = timeZone.R(shiftedIsoDateTime))[2 === disambig ? 0 : possibleEpochNanos.length - 1];
4116
4226
  }
4117
4227
 
4118
4228
  function getStartOfDayInstantFor(timeZone, isoDateTime) {
4119
- const possibleEpochNanos = timeZone.N(isoDateTime);
4229
+ const possibleEpochNanos = timeZone.R(isoDateTime);
4120
4230
  if (possibleEpochNanos.length) {
4121
4231
  return possibleEpochNanos[0];
4122
4232
  }
4123
4233
  const zonedEpochNanoDayBefore = isoDateTimeToEpochNano(isoDateTime) - bigNanoInUtcDay;
4124
- return timeZone.O(zonedEpochNanoDayBefore, 1);
4234
+ return timeZone.C(zonedEpochNanoDayBefore, 1);
4125
4235
  }
4126
4236
 
4127
- function moveYearMonth(doSubtract, calendar, isoDateFields, durationSlots, options) {
4128
- const overflow = refineOverflowOptions(options);
4129
- durationSlots.sign && getMaxDurationUnit(durationSlots) < 8 && throwRangeError("Cannot use small units");
4130
- const startOfMonthFields = checkIsoDateInBounds(moveToStartOfMonth(calendar, isoDateFields));
4131
- return moveToStartOfMonth(calendar, dateAddWithOverflow(calendar, startOfMonthFields, doSubtract ? negateDurationFields(durationSlots) : durationSlots, overflow));
4132
- }
4133
-
4134
- function moveEpochNano(epochNano, durationFields) {
4135
- return checkEpochNanoInBounds(epochNano + (durationHasDateParts(fields = durationFields) && throwRangeError("Cannot use large units"),
4136
- durationTimeToBigNano(fields)));
4137
- var fields;
4237
+ function moveYearMonth(calendar, isoDate, durationSlots, overflow = 0) {
4238
+ computeDurationSign(durationSlots) && getMaxDurationUnit(durationSlots) < 8 && throwRangeError("Cannot use small units");
4239
+ const first = checkIsoDateInBounds(moveToStartOfMonth(calendar, isoDate));
4240
+ return moveToStartOfMonth(calendar, moveDate(calendar, first, durationSlots, overflow));
4138
4241
  }
4139
4242
 
4140
- function moveZonedEpochSlots(slots, durationFields, options) {
4243
+ function moveZonedEpochSlots(slots, durationFields, overflow = 0) {
4141
4244
  const {calendar: calendar, epochNanoseconds: epochNano, timeZone: timeZone} = slots;
4142
4245
  const timeOnlyNano = durationTimeToBigNano(durationFields);
4143
4246
  let movedEpochNano = epochNano;
@@ -4146,9 +4249,9 @@ function moveZonedEpochSlots(slots, durationFields, options) {
4146
4249
  movedEpochNano = getSingleInstantFor(timeZone, combineDateAndTime(moveDate(calendar, isoDateTime, {
4147
4250
  ...durationFields,
4148
4251
  ...durationTimeFieldDefaults
4149
- }, options), isoDateTime)) + timeOnlyNano;
4252
+ }, overflow), isoDateTime)) + timeOnlyNano;
4150
4253
  } else {
4151
- movedEpochNano += timeOnlyNano, refineOverflowOptions(options);
4254
+ movedEpochNano += timeOnlyNano;
4152
4255
  }
4153
4256
  return {
4154
4257
  ...slots,
@@ -4156,77 +4259,86 @@ function moveZonedEpochSlots(slots, durationFields, options) {
4156
4259
  };
4157
4260
  }
4158
4261
 
4159
- function moveDateTime(calendar, isoDateTimeFields, durationFields, options) {
4160
- const [movedTimeFields, dayDelta] = moveTime(isoDateTimeFields, durationFields);
4161
- return checkIsoDateTimeInBounds(combineDateAndTime(moveDate(calendar, isoDateTimeFields, {
4262
+ function moveDateTime(calendar, isoDateTime, durationFields, overflow = 0) {
4263
+ const [movedTimeFields, dayDelta] = moveTime(isoDateTime, durationFields);
4264
+ return checkIsoDateTimeInBounds(combineDateAndTime(moveDate(calendar, isoDateTime, {
4162
4265
  ...durationFields,
4163
4266
  ...durationTimeFieldDefaults,
4164
4267
  days: durationFields.days + dayDelta
4165
- }, options), movedTimeFields));
4166
- }
4167
-
4168
- function moveDate(calendar, isoDateFields, durationFields, options) {
4169
- if (durationFields.years || durationFields.months || durationFields.weeks) {
4170
- return dateAddWithOverflow(calendar, isoDateFields, durationFields, refineOverflowOptions(options));
4171
- }
4172
- refineOverflowOptions(options);
4173
- const days = durationFields.days + Number(durationTimeToBigNano(durationFields) / bigNanoInUtcDay);
4174
- return days ? checkIsoDateInBounds(moveByDays(isoDateFields, days)) : isoDateFields;
4175
- }
4176
-
4177
- function moveToStartOfMonth(calendar, isoDateFields) {
4178
- return moveByDays(isoDateFields, 1 - computeCalendarDateFields(calendar, isoDateFields).day);
4268
+ }, overflow), movedTimeFields));
4179
4269
  }
4180
4270
 
4181
4271
  function moveTime(timeFields, durationFields) {
4182
- const durationBigNano = durationTimeToBigNano(durationFields);
4183
- const durDays = Number(durationBigNano / bigNanoInUtcDay);
4184
- const durTimeNano = Number(durationBigNano % bigNanoInUtcDay);
4185
- const [newTimeFields, overflowDays] = nanoToTimeAndDay(timeFieldsToNano(timeFields) + durTimeNano);
4186
- return [ newTimeFields, durDays + overflowDays ];
4272
+ return moveTimeByNano(timeFields, durationTimeToBigNano(durationFields));
4187
4273
  }
4188
4274
 
4189
- function moveByDays(isoDate, days) {
4190
- return days ? epochDaysToIsoDate(isoDateToEpochDays(isoDate) + days) : isoDate;
4275
+ function moveEpochNano(epochNano, durationFields) {
4276
+ return moveEpochNanoByNano(epochNano, (durationHasDateParts(fields = durationFields) && throwRangeError("Cannot use large units"),
4277
+ durationTimeToBigNano(fields)));
4278
+ var fields;
4191
4279
  }
4192
4280
 
4193
- function dateAddWithOverflow(calendar, isoDateFields, durationFields, overflow) {
4281
+ function moveDate(calendar, isoDate, durationFields, overflow = 0) {
4194
4282
  let {years: years, months: months, weeks: weeks, days: days} = durationFields;
4195
- let isoDate;
4283
+ let movedIsoDate;
4196
4284
  if (days += Number(durationTimeToBigNano(durationFields) / bigNanoInUtcDay), years || months) {
4197
- isoDate = addDateMonths(calendar, isoDateFields, years, months, overflow);
4285
+ movedIsoDate = moveDateByCalendarUnits(calendar, isoDate, years, months, overflow);
4198
4286
  } else {
4199
4287
  if (!weeks && !days) {
4200
- return isoDateFields;
4288
+ return isoDate;
4201
4289
  }
4202
- isoDate = isoDateFields;
4290
+ movedIsoDate = isoDate;
4203
4291
  }
4204
- return (weeks || days) && (isoDate = moveByDays(isoDate, 7 * weeks + days)), checkIsoDateInBounds(isoDate);
4292
+ return (weeks || days) && (movedIsoDate = moveDateByDays(movedIsoDate, 7 * weeks + days)),
4293
+ checkIsoDateInBounds(movedIsoDate);
4205
4294
  }
4206
4295
 
4207
- function addDateMonths(calendar, isoDateFields, years, months, overflow) {
4208
- const dateParts = computeCalendarDateFields(calendar, isoDateFields);
4296
+ function moveToStartOfMonth(calendar, isoDate) {
4297
+ return moveDateByDays(isoDate, 1 - computeCalendarDateFields(calendar, isoDate).day);
4298
+ }
4299
+
4300
+ function moveDateByCalendarUnits(calendar, isoDate, years, months, overflow) {
4301
+ const dateParts = computeCalendarDateFields(calendar, isoDate);
4209
4302
  let {year: year, month: month, day: day} = dateParts;
4210
4303
  if (years) {
4211
4304
  const [monthCodeNumber, isLeapMonth] = computeCalendarMonthCodeParts(calendar, year, month);
4212
- year += years, month = computeYearMovedMonth(calendar, monthCodeNumber, isLeapMonth, calendar ? calendar.p(year) : void 0, overflow),
4305
+ year += years, month = resolveMonthInMovedYear(calendar, monthCodeNumber, isLeapMonth, calendar ? calendar.p(year) : void 0, overflow),
4213
4306
  month = clampEntity("month", month, 1, computeCalendarMonthsInYearForYear(calendar, year), overflow);
4214
4307
  }
4215
4308
  if (months) {
4216
- const yearMonthParts = calendar ? calendar.K(year, month, months) : addIsoMonths(year, month, months);
4309
+ const yearMonthParts = addCalendarMonths(calendar, year, month, months);
4217
4310
  ({year: year, month: month} = yearMonthParts);
4218
4311
  }
4219
4312
  return day = clampEntity("day", day, 1, computeCalendarDaysInMonthForYearMonth(calendar, year, month), overflow),
4220
4313
  computeCalendarIsoFieldsFromParts(calendar, year, month, day);
4221
4314
  }
4222
4315
 
4223
- function computeYearMovedMonth(calendar, monthCodeNumber, isLeapMonth, targetLeapMonth, overflow) {
4224
- if (isLeapMonth) {
4225
- const leapMonthMeta = calendar ? calendar.l : void 0;
4226
- return void 0 !== targetLeapMonth && (leapMonthMeta < 0 || targetLeapMonth === monthCodeNumber + 1) ? targetLeapMonth : (1 === overflow && throwRangeError(invalidLeapMonth),
4227
- leapMonthMeta < 0 ? -leapMonthMeta : monthCodeNumber);
4228
- }
4229
- return monthCodeNumberToMonth(monthCodeNumber, 0, targetLeapMonth);
4316
+ function addCalendarMonths(calendar, year, month, monthDelta) {
4317
+ return calendar ? calendar.ae(year, month, monthDelta) : addIsoMonths(year, month, monthDelta);
4318
+ }
4319
+
4320
+ function resolveMonthInMovedYear(calendar, monthCodeNumber, isLeapMonth, targetLeapMonth, overflow) {
4321
+ if (isLeapMonth) {
4322
+ const leapMonthMeta = calendar ? calendar.l : void 0;
4323
+ return void 0 !== targetLeapMonth && (leapMonthMeta < 0 || targetLeapMonth === monthCodeNumber + 1) ? targetLeapMonth : (1 === overflow && throwRangeError(invalidLeapMonth),
4324
+ leapMonthMeta < 0 ? -leapMonthMeta : monthCodeNumber);
4325
+ }
4326
+ return monthCodeNumberToMonth(monthCodeNumber, 0, targetLeapMonth);
4327
+ }
4328
+
4329
+ function moveTimeByNano(timeFields, durationBigNano) {
4330
+ const durDays = Number(durationBigNano / bigNanoInUtcDay);
4331
+ const durTimeNano = Number(durationBigNano % bigNanoInUtcDay);
4332
+ const [newTimeFields, overflowDays] = nanoToTimeAndDay(timeFieldsToNano(timeFields) + durTimeNano);
4333
+ return [ newTimeFields, durDays + overflowDays ];
4334
+ }
4335
+
4336
+ function moveEpochNanoByNano(epochNano, deltaNano) {
4337
+ return checkEpochNanoInBounds(epochNano + deltaNano);
4338
+ }
4339
+
4340
+ function moveDateByDays(isoDate, days) {
4341
+ return days ? epochDaysToIsoDate(isoDateToEpochDays(isoDate) + days) : isoDate;
4230
4342
  }
4231
4343
 
4232
4344
  function getCommonCalendar(a, b) {
@@ -4243,98 +4355,94 @@ function getZonedTimeZoneId(slots) {
4243
4355
  return slots.timeZone.id;
4244
4356
  }
4245
4357
 
4246
- function diffInstants(invert, instantSlots0, instantSlots1, options) {
4247
- const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 3, 5);
4248
- const durationFields = diffEpochNanos(instantSlots0.epochNanoseconds, instantSlots1.epochNanoseconds, largestUnit, smallestUnit, roundingInc, roundingMode);
4249
- return createDurationSlots(invert ? negateDurationFields(durationFields) : durationFields);
4358
+ function diffZonedDateTimesRounded(calendar, startZoned, endZoned, largestUnit, smallestUnit, roundingInc, roundingMode) {
4359
+ return largestUnit < 6 ? diffEpochNanosRounded(startZoned.epochNanoseconds, endZoned.epochNanoseconds, largestUnit, smallestUnit, roundingInc, roundingMode) : ((calendar, startZoned, endZoned, largestUnit, smallestUnit, roundingInc, roundingMode) => {
4360
+ const endEpochNano = endZoned.epochNanoseconds;
4361
+ if (endEpochNano === startZoned.epochNanoseconds) {
4362
+ return durationFieldDefaults;
4363
+ }
4364
+ let durationFields;
4365
+ const timeZone = getCommonTimeZone(startZoned.timeZone, endZoned.timeZone);
4366
+ return durationFields = diffZonedEpochsExact(timeZone, calendar, startZoned, endZoned, largestUnit),
4367
+ durationFields = roundRelativeDuration(durationFields, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode, createZonedRelativeOps(calendar, timeZone, startZoned), 1),
4368
+ durationFields;
4369
+ })(calendar, startZoned, endZoned, largestUnit, smallestUnit, roundingInc, roundingMode);
4250
4370
  }
4251
4371
 
4252
- function diffZonedDateTimes(invert, calendar, slots0, slots1, options) {
4253
- const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 5);
4254
- const epochNano0 = slots0.epochNanoseconds;
4255
- const epochNano1 = slots1.epochNanoseconds;
4256
- let durationFields;
4257
- if (compareBigInts(epochNano1, epochNano0)) {
4258
- if (largestUnit < 6) {
4259
- durationFields = diffEpochNanos(epochNano0, epochNano1, largestUnit, smallestUnit, roundingInc, roundingMode);
4260
- } else {
4261
- const timeZone = getCommonTimeZone(slots0.timeZone, slots1.timeZone);
4262
- durationFields = diffZonedEpochsExact(timeZone, calendar, slots0, slots1, largestUnit),
4263
- durationFields = roundRelativeDuration(durationFields, epochNano1, largestUnit, smallestUnit, roundingInc, roundingMode, createZonedRelativeOps(calendar, timeZone, slots0), 1);
4372
+ function diffDateTimesRounded(calendar, startIsoDateTime, endIsoDateTime, largestUnit, smallestUnit, roundingInc, roundingMode) {
4373
+ return largestUnit <= 6 ? diffEpochNanosRounded(isoDateTimeToEpochNano(startIsoDateTime), isoDateTimeToEpochNano(endIsoDateTime), largestUnit, smallestUnit, roundingInc, roundingMode) : ((calendar, startIsoDateTime, endIsoDateTime, largestUnit, smallestUnit, roundingInc, roundingMode) => {
4374
+ const endEpochNano = isoDateTimeToEpochNano(endIsoDateTime);
4375
+ const sign = compareBigInts(endEpochNano, isoDateTimeToEpochNano(startIsoDateTime));
4376
+ if (!sign) {
4377
+ return durationFieldDefaults;
4264
4378
  }
4265
- } else {
4266
- durationFields = durationFieldDefaults;
4267
- }
4268
- return createDurationSlots(invert ? negateDurationFields(durationFields) : durationFields);
4379
+ let durationFields;
4380
+ return durationFields = diffDateTimesBig(calendar, startIsoDateTime, endIsoDateTime, sign, largestUnit),
4381
+ durationFields = roundRelativeDuration(durationFields, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode, ((calendar, origin) => ({
4382
+ ne: isoDateTimeToEpochNano(origin),
4383
+ ke: duration => isoDateTimeToEpochNano(combineDateAndTime(moveDate(calendar, origin, duration), origin))
4384
+ }))(calendar, startIsoDateTime)), durationFields;
4385
+ })(calendar, startIsoDateTime, endIsoDateTime, largestUnit, smallestUnit, roundingInc, roundingMode);
4269
4386
  }
4270
4387
 
4271
- function diffPlainDateTimes(invert, calendar, plainDateTimeSlots0, plainDateTimeSlots1, options) {
4272
- const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 6);
4273
- const startEpochNano = isoDateTimeToEpochNano(plainDateTimeSlots0);
4274
- const endEpochNano = isoDateTimeToEpochNano(plainDateTimeSlots1);
4275
- const sign = compareBigInts(endEpochNano, startEpochNano);
4276
- let durationFields;
4277
- return sign ? largestUnit <= 6 ? durationFields = diffEpochNanos(startEpochNano, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode) : (durationFields = diffDateTimesBig(calendar, plainDateTimeSlots0, plainDateTimeSlots1, sign, largestUnit),
4278
- durationFields = roundRelativeDuration(durationFields, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode, createDateTimeRelativeOps(calendar, plainDateTimeSlots0))) : durationFields = durationFieldDefaults,
4279
- createDurationSlots(invert ? negateDurationFields(durationFields) : durationFields);
4388
+ function diffYearMonthsRounded(calendar, startIsoDate, endIsoDate, largestUnit, smallestUnit, roundingInc, roundingMode) {
4389
+ const firstOfMonth0 = moveToStartOfMonth(calendar, startIsoDate);
4390
+ const firstOfMonth1 = moveToStartOfMonth(calendar, endIsoDate);
4391
+ return compareIsoDates(firstOfMonth0, firstOfMonth1) ? diffDateCalendarUnitsRounded(calendar, checkIsoDateInBounds(firstOfMonth0), checkIsoDateInBounds(firstOfMonth1), largestUnit, smallestUnit, roundingInc, roundingMode, 8) : durationFieldDefaults;
4280
4392
  }
4281
4393
 
4282
- function diffPlainDates(invert, calendar, plainDateSlots0, plainDateSlots1, options) {
4283
- const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 6, 9, 6);
4284
- return diffDateLike(invert, calendar, plainDateSlots0, plainDateSlots1, largestUnit, smallestUnit, roundingInc, roundingMode);
4394
+ function diffDatesRounded(calendar, startIsoDate, endIsoDate, largestUnit, smallestUnit, roundingInc, roundingMode, smallestPrecision = 6) {
4395
+ return 6 === largestUnit ? diffEpochNanosRounded(isoDateToEpochNano(startIsoDate), isoDateToEpochNano(endIsoDate), largestUnit, smallestUnit, roundingInc, roundingMode) : diffDateCalendarUnitsRounded(calendar, startIsoDate, endIsoDate, largestUnit, smallestUnit, roundingInc, roundingMode, smallestPrecision);
4285
4396
  }
4286
4397
 
4287
- function diffPlainYearMonth(invert, calendar, plainYearMonthSlots0, plainYearMonthSlots1, options) {
4288
- const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 9, 9, 8);
4289
- const firstOfMonth0 = moveToStartOfMonth(calendar, plainYearMonthSlots0);
4290
- const firstOfMonth1 = moveToStartOfMonth(calendar, plainYearMonthSlots1);
4291
- return compareIsoDate(firstOfMonth0, firstOfMonth1) ? diffDateLike(invert, calendar, checkIsoDateInBounds(firstOfMonth0), checkIsoDateInBounds(firstOfMonth1), largestUnit, smallestUnit, roundingInc, roundingMode, 8) : createDurationSlots(durationFieldDefaults);
4398
+ function diffTimesRounded(plainTimeSlots0, plainTimeSlots1, largestUnit, smallestUnit, roundingInc, roundingMode) {
4399
+ const timeDiffNano = roundNumberToInc(timeFieldsToNano(plainTimeSlots1) - timeFieldsToNano(plainTimeSlots0), computeNanoInc(smallestUnit, roundingInc), roundingMode);
4400
+ return {
4401
+ ...durationFieldDefaults,
4402
+ ...nanoToDurationTimeFields(timeDiffNano, largestUnit)
4403
+ };
4292
4404
  }
4293
4405
 
4294
- function diffDateLike(invert, calendar, startIsoDate, endIsoDate, largestUnit, smallestUnit, roundingInc, roundingMode, smallestPrecision = 6) {
4295
- const startEpochNano = isoDateToEpochNano(startIsoDate);
4406
+ function diffDateCalendarUnitsRounded(calendar, startIsoDate, endIsoDate, largestUnit, smallestUnit, roundingInc, roundingMode, smallestPrecision = 6) {
4296
4407
  const endEpochNano = isoDateToEpochNano(endIsoDate);
4408
+ if (!compareIsoDates(startIsoDate, endIsoDate)) {
4409
+ return durationFieldDefaults;
4410
+ }
4297
4411
  let durationFields;
4298
- return compareBigInts(endEpochNano, startEpochNano) ? 6 === largestUnit ? durationFields = diffEpochNanos(startEpochNano, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode) : (durationFields = diffCalendarDates(calendar, startIsoDate, endIsoDate, largestUnit),
4299
- smallestUnit === smallestPrecision && 1 === roundingInc || (durationFields = roundRelativeDuration(durationFields, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode, createDateRelativeOps(calendar, startIsoDate)))) : durationFields = durationFieldDefaults,
4300
- createDurationSlots(invert ? negateDurationFields(durationFields) : durationFields);
4412
+ return durationFields = diffCalendarDates(calendar, startIsoDate, endIsoDate, largestUnit),
4413
+ smallestUnit === smallestPrecision && 1 === roundingInc || (durationFields = roundRelativeDuration(durationFields, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode, createDateRelativeOps(calendar, startIsoDate))),
4414
+ durationFields;
4301
4415
  }
4302
4416
 
4303
- function diffPlainTimes(invert, plainTimeSlots0, plainTimeSlots1, options) {
4304
- const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 5, 5);
4305
- const timeDiffNano = roundNumberToInc(timeFieldsToNano(plainTimeSlots1) - timeFieldsToNano(plainTimeSlots0), computeNanoInc(smallestUnit, roundingInc), roundingMode);
4306
- const durationFields = {
4417
+ function diffEpochNanosRounded(startEpochNano, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode) {
4418
+ return {
4307
4419
  ...durationFieldDefaults,
4308
- ...nanoToDurationTimeFields(timeDiffNano, largestUnit)
4420
+ ...nanoToDurationDayTimeFields(roundBigNanoToInc(endEpochNano - startEpochNano, computeBigNanoInc(smallestUnit, roundingInc), roundingMode), largestUnit)
4309
4421
  };
4310
- return createDurationSlots(invert ? negateDurationFields(durationFields) : durationFields);
4311
4422
  }
4312
4423
 
4313
- function diffZonedEpochsExact(timeZone, calendar, slots0, slots1, largestUnit) {
4314
- const sign = compareBigInts(slots1.epochNanoseconds, slots0.epochNanoseconds);
4315
- if (!sign) {
4316
- return durationFieldDefaults;
4317
- }
4318
- if (largestUnit < 6) {
4319
- return {
4320
- ...durationFieldDefaults,
4321
- ...nanoToDurationDayTimeFields(slots1.epochNanoseconds - slots0.epochNanoseconds, largestUnit)
4322
- };
4323
- }
4324
- if (!compareIsoDate(zonedEpochSlotsToIso(slots0), zonedEpochSlotsToIso(slots1))) {
4424
+ function diffZonedEpochsExact(timeZone, calendar, startZoned, endZoned, largestUnit) {
4425
+ return largestUnit < 6 ? {
4426
+ ...durationFieldDefaults,
4427
+ ...nanoToDurationDayTimeFields(endZoned.epochNanoseconds - startZoned.epochNanoseconds, largestUnit)
4428
+ } : ((timeZone, startZoned, endZoned) => {
4429
+ const sign = compareBigInts(endZoned.epochNanoseconds, startZoned.epochNanoseconds);
4430
+ if (!sign) {
4431
+ return durationFieldDefaults;
4432
+ }
4433
+ if (!compareIsoDates(zonedEpochSlotsToIso(startZoned), zonedEpochSlotsToIso(endZoned))) {
4434
+ return {
4435
+ ...durationFieldDefaults,
4436
+ ...nanoToDurationDayTimeFields(endZoned.epochNanoseconds - startZoned.epochNanoseconds, 5)
4437
+ };
4438
+ }
4439
+ const [startIsoDateTime, endIsoDate, remainderNano] = prepareZonedEpochDiff(timeZone, startZoned, endZoned, sign);
4325
4440
  return {
4326
- ...durationFieldDefaults,
4327
- ...nanoToDurationDayTimeFields(slots1.epochNanoseconds - slots0.epochNanoseconds, 5)
4441
+ ...(start = startIsoDateTime, end = endIsoDate, diffCalendarDates(calendar, start, end, largestUnit)),
4442
+ ...nanoToDurationTimeFields(remainderNano)
4328
4443
  };
4329
- }
4330
- const [isoFields0, isoFields1, remainderNano] = prepareZonedEpochDiff(timeZone, slots0, slots1, sign);
4331
- return {
4332
- ...6 === largestUnit ? {
4333
- ...durationFieldDefaults,
4334
- days: diffDays(isoFields0, isoFields1)
4335
- } : diffCalendarDates(calendar, isoFields0, isoFields1, largestUnit),
4336
- ...nanoToDurationTimeFields(remainderNano)
4337
- };
4444
+ var start, end;
4445
+ })(timeZone, startZoned, endZoned);
4338
4446
  }
4339
4447
 
4340
4448
  function diffDateTimesExact(calendar, startIsoDateTime, endIsoDateTime, largestUnit) {
@@ -4350,38 +4458,57 @@ function diffDateTimesExact(calendar, startIsoDateTime, endIsoDateTime, largestU
4350
4458
  function diffDateTimesBig(calendar, startIsoDateTime, endIsoDateTime, sign, largestUnit) {
4351
4459
  let diffEndDate = endIsoDateTime;
4352
4460
  let timeNano = timeFieldsToNano(endIsoDateTime) - timeFieldsToNano(startIsoDateTime);
4353
- return Math.sign(timeNano) === -sign && (diffEndDate = moveByDays(endIsoDateTime, -sign),
4461
+ return Math.sign(timeNano) === -sign && (diffEndDate = moveDateByDays(endIsoDateTime, -sign),
4354
4462
  timeNano += nanoInUtcDay * sign), {
4355
4463
  ...diffCalendarDates(calendar, startIsoDateTime, diffEndDate, largestUnit),
4356
4464
  ...nanoToDurationTimeFields(timeNano)
4357
4465
  };
4358
4466
  }
4359
4467
 
4468
+ function prepareZonedEpochDiff(timeZone, startZoned, endZoned, sign) {
4469
+ const startIsoDate = zonedEpochSlotsToIso(startZoned);
4470
+ const endIsoDate = zonedEpochSlotsToIso(endZoned);
4471
+ const endEpochNano = endZoned.epochNanoseconds;
4472
+ let dayCorrection = 0;
4473
+ const timeDiffNano = timeFieldsToNano(endIsoDate) - timeFieldsToNano(startIsoDate);
4474
+ Math.sign(timeDiffNano) === -sign && dayCorrection++;
4475
+ const maxDayCorrection = dayCorrection + (sign > 0 ? 1 : 0);
4476
+ for (;;dayCorrection++) {
4477
+ const midIsoDate = moveDateByDays(endIsoDate, dayCorrection * -sign);
4478
+ const midEpochNano = getSingleInstantFor(timeZone, combineDateAndTime(midIsoDate, startIsoDate));
4479
+ if (dayCorrection === maxDayCorrection || compareBigInts(endEpochNano, midEpochNano) !== -sign) {
4480
+ return [ startIsoDate, midIsoDate, Number(endEpochNano - midEpochNano) ];
4481
+ }
4482
+ }
4483
+ }
4484
+
4360
4485
  function diffCalendarDates(calendar, startIsoDate, endIsoDate, largestUnit) {
4361
4486
  if (largestUnit <= 7) {
4362
- const days = diffDays(startIsoDate, endIsoDate);
4363
- return 7 === largestUnit ? {
4364
- ...durationFieldDefaults,
4365
- weeks: divTrunc(days, 7),
4366
- days: modTrunc(days, 7)
4367
- } : {
4368
- ...durationFieldDefaults,
4369
- days: days
4370
- };
4487
+ return ((asWeeks, start, end) => {
4488
+ const days = countIsoDays(start, end);
4489
+ return asWeeks ? {
4490
+ ...durationFieldDefaults,
4491
+ weeks: divTrunc(days, 7),
4492
+ days: modTrunc(days, 7)
4493
+ } : {
4494
+ ...durationFieldDefaults,
4495
+ days: days
4496
+ };
4497
+ })(7 === largestUnit, startIsoDate, endIsoDate);
4371
4498
  }
4372
4499
  const yearMonthDayStart = computeCalendarDateFields(calendar, startIsoDate);
4373
4500
  const yearMonthDayEnd = computeCalendarDateFields(calendar, endIsoDate);
4374
4501
  if (8 === largestUnit) {
4375
4502
  const {year: year0, month: month0, day: day0} = yearMonthDayStart;
4376
4503
  const {year: year1, month: month1, day: day1} = yearMonthDayEnd;
4377
- const sign = Math.sign(compareNumbers(year1, year0) || compareNumbers(month1, month0) || diffDays(startIsoDate, endIsoDate));
4504
+ const sign = Math.sign(compareNumbers(year1, year0) || compareNumbers(month1, month0) || countIsoDays(startIsoDate, endIsoDate));
4378
4505
  let months = 0;
4379
4506
  let days = 0;
4380
4507
  if (sign) {
4381
- months = calendar ? calendar._(year0, month0, year1, month1) : diffIsoMonthSlots(year0, month0, year1, month1);
4382
- let anchorIsoDate = addDateMonths(calendar, startIsoDate, 0, months, 0);
4383
- sign * compareNumbers(day0, day1) > 0 && (months -= sign, anchorIsoDate = addDateMonths(calendar, startIsoDate, 0, months, 0)),
4384
- days = diffDays(anchorIsoDate, endIsoDate);
4508
+ months = calendar ? calendar.ee(year0, month0, year1, month1) : diffIsoMonthSlots(year0, month0, year1, month1);
4509
+ let anchorIsoDate = moveDateByCalendarUnits(calendar, startIsoDate, 0, months, 0);
4510
+ sign * compareNumbers(day0, day1) > 0 && (months -= sign, anchorIsoDate = moveDateByCalendarUnits(calendar, startIsoDate, 0, months, 0)),
4511
+ days = countIsoDays(anchorIsoDate, endIsoDate);
4385
4512
  }
4386
4513
  return {
4387
4514
  ...durationFieldDefaults,
@@ -4400,7 +4527,7 @@ function diffCalendarDates(calendar, startIsoDate, endIsoDate, largestUnit) {
4400
4527
  let dayCorrect = 0;
4401
4528
  if (Math.sign(day1 - day0) === -sign) {
4402
4529
  const origDaysInMonth1 = daysInMonth1;
4403
- const yearMonthParts = calendar ? calendar.K(year1, month1, -sign) : addIsoMonths(year1, month1, -sign);
4530
+ const yearMonthParts = addCalendarMonths(calendar, year1, month1, -sign);
4404
4531
  (({year: year1, month: month1} = yearMonthParts)), yearDiff = year1 - year0, monthDiff = month1 - month0,
4405
4532
  daysInMonth1 = computeCalendarDaysInMonthForYearMonth(calendar, year1, month1),
4406
4533
  dayCorrect = sign < 0 ? -origDaysInMonth1 : daysInMonth1;
@@ -4412,10 +4539,10 @@ function diffCalendarDates(calendar, startIsoDate, endIsoDate, largestUnit) {
4412
4539
  if (monthDiff = void 0 !== leapMonthMeta && isLeapMonth0 && !isLeapMonth1 && (leapMonthMeta < 0 ? sign > 0 && monthCodeNumber1 === -leapMonthMeta : sign < 0 && monthCodeNumber1 === monthCodeNumber0) ? 0 : monthCodeNumber1 - monthCodeNumber0 || Number(isLeapMonth1) - Number(isLeapMonth0),
4413
4540
  Math.sign(monthDiff) === -sign) {
4414
4541
  const monthCorrect = sign < 0 && -computeCalendarMonthsInYearForYear(calendar, year1);
4415
- year1 -= sign, yearDiff = year1 - year0, monthDiff = month1 - computeYearMovedMonth(calendar, monthCodeNumber0, isLeapMonth0, calendar ? calendar.p(year1) : void 0, 0) + (monthCorrect || computeCalendarMonthsInYearForYear(calendar, year1));
4542
+ year1 -= sign, yearDiff = year1 - year0, monthDiff = month1 - resolveMonthInMovedYear(calendar, monthCodeNumber0, isLeapMonth0, calendar ? calendar.p(year1) : void 0, 0) + (monthCorrect || computeCalendarMonthsInYearForYear(calendar, year1));
4416
4543
  } else if (calendar) {
4417
- const month0Projected = computeYearMovedMonth(calendar, monthCodeNumber0, isLeapMonth0, calendar.p(year1), 0);
4418
- monthDiff = calendar._(year1, month0Projected, year1, month1);
4544
+ const month0Projected = resolveMonthInMovedYear(calendar, monthCodeNumber0, isLeapMonth0, calendar.p(year1), 0);
4545
+ monthDiff = calendar.ee(year1, month0Projected, year1, month1);
4419
4546
  }
4420
4547
  }
4421
4548
  }
@@ -4427,84 +4554,48 @@ function diffCalendarDates(calendar, startIsoDate, endIsoDate, largestUnit) {
4427
4554
  };
4428
4555
  }
4429
4556
 
4430
- function compareIsoDate(isoDate0, isoDate1) {
4557
+ function compareIsoDates(isoDate0, isoDate1) {
4431
4558
  return compareNumbers(isoDate0.year, isoDate1.year) || compareNumbers(isoDate0.month, isoDate1.month) || compareNumbers(isoDate0.day, isoDate1.day);
4432
4559
  }
4433
4560
 
4434
- function prepareZonedEpochDiff(timeZone, slots0, slots1, sign) {
4435
- const startIsoDate = zonedEpochSlotsToIso(slots0);
4436
- const endIsoDate = zonedEpochSlotsToIso(slots1);
4437
- const endEpochNano = slots1.epochNanoseconds;
4438
- let dayCorrection = 0;
4439
- const timeDiffNano = timeFieldsToNano(endIsoDate) - timeFieldsToNano(startIsoDate);
4440
- Math.sign(timeDiffNano) === -sign && dayCorrection++;
4441
- const maxDayCorrection = dayCorrection + (sign > 0 ? 1 : 0);
4442
- for (;dayCorrection <= maxDayCorrection; dayCorrection++) {
4443
- const midIsoDate = moveByDays(endIsoDate, dayCorrection * -sign);
4444
- const midEpochNano = getSingleInstantFor(timeZone, combineDateAndTime(midIsoDate, startIsoDate));
4445
- if (compareBigInts(endEpochNano, midEpochNano) !== -sign) {
4446
- return [ startIsoDate, midIsoDate, Number(endEpochNano - midEpochNano) ];
4447
- }
4448
- }
4449
- }
4450
-
4451
- function diffEpochNanos(startEpochNano, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode) {
4452
- return {
4453
- ...durationFieldDefaults,
4454
- ...nanoToDurationDayTimeFields(roundBigNanoToInc(endEpochNano - startEpochNano, computeBigNanoInc(smallestUnit, roundingInc), roundingMode), largestUnit)
4455
- };
4561
+ function countIsoDays(startIsoDate, endIsoDate) {
4562
+ return isoDateToEpochDays(endIsoDate) - isoDateToEpochDays(startIsoDate);
4456
4563
  }
4457
4564
 
4458
- function diffDays(startIsoDate, endIsoDate) {
4459
- return isoDateToEpochDays(endIsoDate) - isoDateToEpochDays(startIsoDate);
4565
+ function spanRelativeDuration(relativeToSlots, durationFields, largestUnit) {
4566
+ return isZonedEpochSlots(relativeToSlots) ? ((relativeToSlots, durationFields, largestUnit) => {
4567
+ const {calendar: calendar, timeZone: timeZone} = relativeToSlots;
4568
+ const endSlots = moveZonedEpochSlots(relativeToSlots, durationFields);
4569
+ return [ diffZonedEpochsExact(timeZone, calendar, relativeToSlots, endSlots, largestUnit), endSlots.epochNanoseconds, createZonedRelativeOps(calendar, timeZone, relativeToSlots) ];
4570
+ })(relativeToSlots, durationFields, largestUnit) : ((relativeToSlots, durationFields, largestUnit) => {
4571
+ const {calendar: calendar} = relativeToSlots;
4572
+ const origin = checkIsoDateTimeInBounds(combineDateAndTime(relativeToSlots, timeFieldDefaults));
4573
+ const end = moveDateTime(calendar, origin, durationFields);
4574
+ return [ diffDateTimesExact(calendar, origin, end, largestUnit), isoDateTimeToEpochNano(end), createDateRelativeOps(calendar, relativeToSlots) ];
4575
+ })(relativeToSlots, durationFields, largestUnit);
4460
4576
  }
4461
4577
 
4462
- function createDateRelativeOps(calendar, origin) {
4463
- return {
4464
- origin: origin,
4465
- ie: isoDateToEpochNano(origin),
4466
- calendar: calendar,
4467
- he: isoDateToEpochNano
4468
- };
4578
+ function moveRelativeEndpointToEpochNano(relativeToSlots, durationFields) {
4579
+ return isZonedEpochSlots(relativeToSlots) ? moveZonedEpochSlots(relativeToSlots, durationFields).epochNanoseconds : isoDateTimeToEpochNano(moveDateTime(relativeToSlots.calendar, combineDateAndTime(relativeToSlots, timeFieldDefaults), durationFields));
4469
4580
  }
4470
4581
 
4471
- function createDateTimeRelativeOps(calendar, origin) {
4472
- return {
4473
- origin: origin,
4474
- ie: isoDateTimeToEpochNano(origin),
4475
- calendar: calendar,
4476
- he: movedIsoDate => isoDateTimeToEpochNano(combineDateAndTime(movedIsoDate, origin))
4477
- };
4582
+ function moveRelativeMarkerToEpochNano(relativeOps, dateDuration) {
4583
+ return durationHasDateParts(dateDuration) ? relativeOps.ke(dateDuration) : relativeOps.ne;
4478
4584
  }
4479
4585
 
4480
4586
  function createZonedRelativeOps(calendar, timeZone, slots) {
4481
4587
  const origin = zonedEpochSlotsToIso(slots);
4482
4588
  return {
4483
- origin: origin,
4484
- ie: slots.epochNanoseconds,
4485
- calendar: calendar,
4486
- he: movedIsoDate => getSingleInstantFor(timeZone, combineDateAndTime(movedIsoDate, origin))
4589
+ ne: slots.epochNanoseconds,
4590
+ ke: duration => getSingleInstantFor(timeZone, combineDateAndTime(moveDate(calendar, origin, duration), origin))
4487
4591
  };
4488
4592
  }
4489
4593
 
4490
- function moveRelativeToEpochNano(relativeOps, dateDuration) {
4491
- return durationHasDateParts(dateDuration) ? relativeOps.he(moveDate(relativeOps.calendar, relativeOps.origin, dateDuration)) : relativeOps.ie;
4492
- }
4493
-
4494
- function spanRelativeDuration(relativeToSlots, durationFields, largestUnit) {
4495
- const {calendar: calendar} = relativeToSlots;
4496
- if (isZonedEpochSlots(relativeToSlots)) {
4497
- const {timeZone: timeZone} = relativeToSlots;
4498
- const endSlots = moveZonedEpochSlots(relativeToSlots, durationFields);
4499
- return [ diffZonedEpochsExact(timeZone, calendar, relativeToSlots, endSlots, largestUnit), endSlots.epochNanoseconds, createZonedRelativeOps(calendar, timeZone, relativeToSlots) ];
4500
- }
4501
- const origin = checkIsoDateTimeInBounds(combineDateAndTime(relativeToSlots, timeFieldDefaults));
4502
- const end = moveDateTime(calendar, origin, durationFields);
4503
- return [ diffDateTimesExact(calendar, origin, end, largestUnit), isoDateTimeToEpochNano(end), createDateRelativeOps(calendar, relativeToSlots) ];
4504
- }
4505
-
4506
- function moveRelativeEndpointToEpochNano(relativeToSlots, durationFields) {
4507
- return isZonedEpochSlots(relativeToSlots) ? moveZonedEpochSlots(relativeToSlots, durationFields).epochNanoseconds : isoDateTimeToEpochNano(moveDateTime(relativeToSlots.calendar, combineDateAndTime(relativeToSlots, timeFieldDefaults), durationFields));
4594
+ function createDateRelativeOps(calendar, origin) {
4595
+ return {
4596
+ ne: isoDateToEpochNano(origin),
4597
+ ke: duration => isoDateToEpochNano(moveDate(calendar, origin, duration))
4598
+ };
4508
4599
  }
4509
4600
 
4510
4601
  function isZonedEpochSlots(slots) {
@@ -4526,49 +4617,21 @@ function nanoToGivenFields(nano, largestUnit, fieldNames) {
4526
4617
 
4527
4618
  const maxDurationSeconds = 2 ** 53;
4528
4619
 
4529
- function addDurations(refineRelativeTo, doSubtract, slots, otherSlots, options) {
4530
- const relativeToSlots = refineRelativeTo(normalizeOptions(options).relativeTo);
4620
+ function addDurationsWithoutRelativeTo(doSubtract, slots, otherSlots) {
4531
4621
  const maxUnit = Math.max(getMaxDurationUnit(slots), getMaxDurationUnit(otherSlots));
4532
- return isUniformUnit(maxUnit, relativeToSlots && isZonedEpochSlots(relativeToSlots)) ? addDayTimeDurationsChecked(doSubtract, slots, otherSlots, maxUnit) : (relativeToSlots || throwRangeError("Missing relativeTo"),
4533
- doSubtract && (otherSlots = negateDurationFields(otherSlots)), createDurationSlots(((relativeToSlots, durationFields0, durationFields1, largestUnit) => {
4534
- const {calendar: calendar} = relativeToSlots;
4535
- if (isZonedEpochSlots(relativeToSlots)) {
4536
- const {timeZone: timeZone} = relativeToSlots;
4537
- const midSlots = moveZonedEpochSlots(relativeToSlots, durationFields0);
4538
- return diffZonedEpochsExact(timeZone, calendar, relativeToSlots, moveZonedEpochSlots(midSlots, durationFields1), largestUnit);
4539
- }
4540
- const origin = combineDateAndTime(relativeToSlots, timeFieldDefaults);
4541
- const mid = moveDateTime(calendar, origin, durationFields0);
4542
- return diffDateTimesExact(calendar, origin, moveDateTime(calendar, mid, durationFields1), largestUnit);
4543
- })(relativeToSlots, slots, otherSlots, maxUnit)));
4544
- }
4545
-
4546
- function addDayTimeDurationsChecked(doSubtract, slots, otherSlots, maxUnit) {
4547
- return createDurationSlots(validateDurationFields(((a, b, largestUnit, doSubtract) => {
4622
+ return maxUnit > 6 && throwRangeError("Cannot use large units"), ((doSubtract, slots, otherSlots, maxUnit) => createDurationSlots(validateDurationFields(((a, b, largestUnit, doSubtract) => {
4548
4623
  const combined = durationDayTimeToBigNano(a) + durationDayTimeToBigNano(b) * BigInt(doSubtract ? -1 : 1);
4549
4624
  return Number.isFinite(Number(combined / bigNanoInUtcDay)) || throwRangeError(outOfBoundsDate),
4550
4625
  {
4551
4626
  ...durationFieldDefaults,
4552
4627
  ...nanoToDurationDayTimeFields(combined, largestUnit)
4553
4628
  };
4554
- })(slots, otherSlots, maxUnit, doSubtract)));
4629
+ })(slots, otherSlots, maxUnit, doSubtract))))(doSubtract, slots, otherSlots, maxUnit);
4555
4630
  }
4556
4631
 
4557
4632
  function roundDuration(refineRelativeTo, slots, options) {
4558
4633
  const durationLargestUnit = getMaxDurationUnit(slots);
4559
- const [largestUnit, smallestUnit, roundingInc, roundingMode, relativeToSlots] = ((options, defaultLargestUnit, refineRelativeTo) => {
4560
- options = normalizeOptionsOrString(options, smallestUnitStr);
4561
- let largestUnit = coerceLargestUnit(options);
4562
- const relativeToInternals = refineRelativeTo(options.relativeTo);
4563
- let roundingInc = coerceRoundingIncInteger(options);
4564
- const roundingMode = coerceRoundingMode(options, 7);
4565
- let smallestUnit = coerceSmallestUnit(options);
4566
- return void 0 === largestUnit && void 0 === smallestUnit && throwRangeError("Required smallestUnit or largestUnit"),
4567
- null == smallestUnit && (smallestUnit = 0), null == largestUnit && (largestUnit = Math.max(smallestUnit, defaultLargestUnit)),
4568
- checkLargestSmallestUnit(largestUnit, smallestUnit), roundingInc = validateRoundingInc(roundingInc, smallestUnit, 1),
4569
- roundingInc > 1 && smallestUnit > 5 && largestUnit !== smallestUnit && throwRangeError("For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit"),
4570
- [ largestUnit, smallestUnit, roundingInc, roundingMode, relativeToInternals ];
4571
- })(options, durationLargestUnit, refineRelativeTo);
4634
+ const [largestUnit, smallestUnit, roundingInc, roundingMode, relativeToSlots] = refineDurationRoundOptions(options, durationLargestUnit, refineRelativeTo);
4572
4635
  if (!relativeToSlots && Math.max(durationLargestUnit, largestUnit) <= 6) {
4573
4636
  return createDurationSlots(validateDurationFields(((durationFields, largestUnit, smallestUnit, roundingInc, roundingMode) => {
4574
4637
  const roundedBigNano = roundBigNanoToInc(durationDayTimeToBigNano(durationFields), computeBigNanoInc(smallestUnit, roundingInc), roundingMode);
@@ -4578,12 +4641,11 @@ function roundDuration(refineRelativeTo, slots, options) {
4578
4641
  };
4579
4642
  })(slots, largestUnit, smallestUnit, roundingInc, roundingMode)));
4580
4643
  }
4581
- const isZoned = relativeToSlots && isZonedEpochSlots(relativeToSlots);
4582
- const needsZonedDayLength = isZoned && largestUnit >= 6 && smallestUnit < 6;
4583
- if (!slots.sign && !needsZonedDayLength) {
4644
+ relativeToSlots || throwRangeError("Missing relativeTo");
4645
+ const isZoned = isZonedEpochSlots(relativeToSlots);
4646
+ if (!slots.sign && (!isZoned || largestUnit < 6)) {
4584
4647
  return slots;
4585
4648
  }
4586
- relativeToSlots || throwRangeError("Missing relativeTo");
4587
4649
  const [balancedDuration, endEpochNano, relativeOps] = spanRelativeDuration(relativeToSlots, slots, largestUnit);
4588
4650
  return createDurationSlots(roundRelativeDuration(balancedDuration, endEpochNano, largestUnit, smallestUnit, roundingInc, roundingMode, relativeOps, isZoned));
4589
4651
  }
@@ -4616,12 +4678,16 @@ function computeDurationSign(fields, fieldNames = durationFieldNamesAsc) {
4616
4678
 
4617
4679
  function validateDurationFields(fields) {
4618
4680
  for (const calendarUnit of durationCalendarFieldNamesAsc) {
4619
- clampEntity(calendarUnit, fields[calendarUnit], -4294967295, 4294967295, 1);
4681
+ validateDurationCalendarUnit(calendarUnit, fields[calendarUnit]);
4620
4682
  }
4621
4683
  const bigNano = durationDayTimeToBigNano(fields);
4622
4684
  return validateDurationTimeUnit(Number(bigNano / bigNanoInSec)), fields;
4623
4685
  }
4624
4686
 
4687
+ function validateDurationCalendarUnit(unit, value) {
4688
+ return clampEntity(unit, value, -4294967295, 4294967295, 1);
4689
+ }
4690
+
4625
4691
  function validateDurationTimeUnit(n) {
4626
4692
  Number.isSafeInteger(n) || throwRangeError("Out-of-bounds duration");
4627
4693
  }
@@ -4677,12 +4743,12 @@ function compareIsoDateTimeFields(isoDateTime0, isoDateTime1) {
4677
4743
  return compareIsoDateFields(isoDateTime0, isoDateTime1) || compareTimeFields(isoDateTime0, isoDateTime1);
4678
4744
  }
4679
4745
 
4680
- function compareIsoDateFields(isoFields0, isoFields1) {
4681
- return compareNumbers(isoDateToEpochDays(isoFields0), isoDateToEpochDays(isoFields1));
4746
+ function compareIsoDateFields(isoDate0, isoDate1) {
4747
+ return compareNumbers(isoDateToEpochDays(isoDate0), isoDateToEpochDays(isoDate1));
4682
4748
  }
4683
4749
 
4684
- function compareTimeFields(isoFields0, isoFields1) {
4685
- return compareNumbers(timeFieldsToNano(isoFields0), timeFieldsToNano(isoFields1));
4750
+ function compareTimeFields(timeFields0, timeFields1) {
4751
+ return compareNumbers(timeFieldsToNano(timeFields0), timeFieldsToNano(timeFields1));
4686
4752
  }
4687
4753
 
4688
4754
  function instantsEqual(instantSlots0, instantSlots1) {
@@ -4721,7 +4787,7 @@ function getCalendarFieldNames(calendar, fieldNames, fieldNamesWithEra = fieldNa
4721
4787
  return getCalendarEraOrigins(calendar) ? fieldNamesWithEra : fieldNames;
4722
4788
  }
4723
4789
 
4724
- function resolveCalendarYear(calendar, fields) {
4790
+ function resolveCalendarYear(fields, calendar) {
4725
4791
  const exoticCalendar = calendar || void 0;
4726
4792
  const eraOrigins = getCalendarEraOrigins(calendar);
4727
4793
  let {era: era, eraYear: eraYear, year: year} = fields;
@@ -4732,7 +4798,7 @@ function resolveCalendarYear(calendar, fields) {
4732
4798
  const normalizedEra = normalizeEraName(era);
4733
4799
  const eraOrigin = eraOrigins[normalizedEra];
4734
4800
  void 0 === eraOrigin && throwRangeError((era => `Invalid era: ${era}`)(era));
4735
- const yearByEra = exoticCalendar?.$ ? exoticCalendar.$(eraYear, normalizedEra, eraOrigin) : eraYearToYear(eraYear, eraOrigin);
4801
+ const yearByEra = exoticCalendar?._ ? exoticCalendar._(eraYear, normalizedEra, eraOrigin) : eraYearToYear(eraYear, eraOrigin);
4736
4802
  void 0 !== year && year !== yearByEra && throwRangeError("Mismatching year/eraYear"),
4737
4803
  year = yearByEra;
4738
4804
  } else {
@@ -4741,7 +4807,7 @@ function resolveCalendarYear(calendar, fields) {
4741
4807
  return year;
4742
4808
  }
4743
4809
 
4744
- function resolveCalendarMonth(calendar, fields, year, overflow, monthCodeParts) {
4810
+ function resolveCalendarMonth(fields, calendar, year, monthCodeParts, overflow) {
4745
4811
  let {month: month, monthCode: monthCode} = fields;
4746
4812
  if (void 0 !== monthCode) {
4747
4813
  const monthByCode = ((calendar, monthCode, year, overflow, monthCodeParts = parseMonthCode(monthCode)) => {
@@ -4764,7 +4830,7 @@ function resolveCalendarMonth(calendar, fields, year, overflow, monthCodeParts)
4764
4830
  return clampEntity("month", month, 1, computeCalendarMonthsInYearForYear(calendar, year), overflow);
4765
4831
  }
4766
4832
 
4767
- function resolveCalendarDay(calendar, fields, month, year, overflow) {
4833
+ function resolveCalendarDay(fields, calendar, year, month, overflow) {
4768
4834
  return clampProp(fields, "day", 1, computeCalendarDaysInMonthForYearMonth(calendar, year, month), overflow);
4769
4835
  }
4770
4836
 
@@ -4807,19 +4873,10 @@ function parseOffsetNanoMaybe(s, onlyHourMinute) {
4807
4873
  }
4808
4874
 
4809
4875
  const dateFieldRefiners = {
4810
- era: toStringViaPrimitive,
4876
+ era: toString,
4811
4877
  month: toPositiveIntegerWithTruncation,
4812
- monthCode(monthCode, entityName) {
4813
- if ("string" == typeof monthCode) {
4814
- return monthCode;
4815
- }
4816
- if (monthCode && "object" == typeof monthCode) {
4817
- const monthCodeToString = monthCode.toString;
4818
- if ("function" == typeof monthCodeToString) {
4819
- return requireString(monthCodeToString.call(monthCode), entityName);
4820
- }
4821
- }
4822
- return requireString(monthCode, entityName);
4878
+ monthCode(monthCode, fieldName) {
4879
+ return requireString(toPrimitiveWithStringHint(monthCode), fieldName);
4823
4880
  },
4824
4881
  day: toPositiveIntegerWithTruncation
4825
4882
  };
@@ -4832,7 +4889,7 @@ const dateTimeFieldRefiners = /*@__PURE__*/ Object.assign({}, dateFieldRefiners,
4832
4889
 
4833
4890
  const zonedDateTimeFieldRefiners = {
4834
4891
  offset(offsetString) {
4835
- return parseOffsetNano(toStringViaPrimitive(offsetString));
4892
+ return parseOffsetNano(requireString(toPrimitiveWithStringHint(offsetString)));
4836
4893
  },
4837
4894
  ...dateTimeFieldRefiners
4838
4895
  };
@@ -4854,75 +4911,68 @@ function readAndRefineBagFields(bag, validFieldNames, fieldRefiners, requiredFie
4854
4911
  res;
4855
4912
  }
4856
4913
 
4857
- function createPlainDateTimeFromRefinedFields(isoDate, time = timeFieldDefaults, calendar) {
4858
- const isoDateTime = combineDateAndTime(isoDate, time);
4859
- return checkIsoDateTimeInBounds(isoDateTime), createDateTimeSlots(isoDateTime, calendar);
4860
- }
4861
-
4862
- function createPlainDateFromFields(calendar, fields, options) {
4863
- return createPlainDateFromPreparedFields(calendar, fields, prepareDateFields(calendar, fields), refineOverflowOptions(options));
4864
- }
4865
-
4866
- function createPlainDateFromFieldsWithOptionsRefiner(calendar, fields, refineOptions) {
4867
- const prepared = prepareDateFields(calendar, fields);
4868
- const refinedOptions = refineOptions();
4869
- return [ createPlainDateFromPreparedFields(calendar, fields, prepared, refinedOptions[0]), ...refinedOptions ];
4914
+ function refineCalendarDateFields(fields, calendar, allowMissingDay) {
4915
+ const eraOrigins = getCalendarEraOrigins(calendar);
4916
+ void 0 !== fields.year || void 0 !== fields.era && void 0 !== fields.eraYear || throwTypeError(missingYear(eraOrigins)),
4917
+ void 0 === fields.monthCode && void 0 === fields.month && throwTypeError("Missing month/monthCode"),
4918
+ allowMissingDay || void 0 !== fields.day || throwTypeError(missingField("day"));
4919
+ const monthCodeParts = parseMonthCodeField(fields);
4920
+ return [ resolveCalendarYear(fields, calendar), monthCodeParts ];
4870
4921
  }
4871
4922
 
4872
- function createPlainDateFromPreparedFields(calendar, fields, prepared, overflow) {
4873
- const year = prepared[1];
4874
- const month = resolveCalendarMonth(calendar, fields, year, overflow, prepared[0]);
4875
- return createDateSlots(checkIsoDateInBounds(computeCalendarIsoFieldsFromParts(calendar, year, month, resolveCalendarDay(calendar, fields, month, year, overflow))), calendar);
4923
+ function refineMonthDayFields(fields, calendar) {
4924
+ const isIso = calendar === isoCalendarImpl;
4925
+ const eraOrigins = getCalendarEraOrigins(calendar);
4926
+ void 0 === fields.day && throwTypeError(missingField("day")), isIso || void 0 === fields.month || void 0 !== fields.year || void 0 !== fields.era && void 0 !== fields.eraYear || throwTypeError(missingYear(eraOrigins));
4927
+ const monthCodeParts = parseMonthCodeField(fields);
4928
+ return [ void 0 !== fields.eraYear || void 0 !== fields.year ? resolveCalendarYear(fields, calendar) : void 0, monthCodeParts ];
4876
4929
  }
4877
4930
 
4878
- function parseMonthCodeField(fields) {
4879
- if (void 0 !== fields.monthCode) {
4880
- return parseMonthCode(fields.monthCode);
4881
- }
4931
+ function createDateTimeFromRefinedFields(isoDate, timeFields = timeFieldDefaults, calendar) {
4932
+ const isoDateTime = combineDateAndTime(isoDate, timeFields);
4933
+ return checkIsoDateTimeInBounds(isoDateTime), createDateTimeSlots(isoDateTime, calendar);
4882
4934
  }
4883
4935
 
4884
- function prepareDateFields(calendar, fields) {
4885
- const eraOrigins = getCalendarEraOrigins(calendar);
4886
- return void 0 !== fields.year || void 0 !== fields.era && void 0 !== fields.eraYear || throwTypeError(missingYear(eraOrigins)),
4887
- void 0 === fields.monthCode && void 0 === fields.month && throwTypeError("Missing month/monthCode"),
4888
- void 0 === fields.day && throwTypeError(missingField("day")), [ parseMonthCodeField(fields), resolveCalendarYear(calendar, fields) ];
4936
+ function createDateFromRefinedFields(fields, calendar, year, monthCodeParts, overflow) {
4937
+ const month = resolveCalendarMonth(fields, calendar, year, monthCodeParts, overflow);
4938
+ return createDateSlots(checkIsoDateInBounds(computeCalendarIsoFieldsFromParts(calendar, year, month, resolveCalendarDay(fields, calendar, year, month, overflow))), calendar);
4889
4939
  }
4890
4940
 
4891
- function createPlainYearMonthFromFields(calendar, fields, options) {
4892
- const eraOrigins = getCalendarEraOrigins(calendar);
4893
- void 0 !== fields.year || void 0 !== fields.era && void 0 !== fields.eraYear || throwTypeError(missingYear(eraOrigins)),
4894
- void 0 === fields.monthCode && void 0 === fields.month && throwTypeError("Missing month/monthCode");
4895
- const monthCodeParts = parseMonthCodeField(fields);
4896
- const year = resolveCalendarYear(calendar, fields);
4897
- return createDateSlots(checkIsoYearMonthInBounds(computeCalendarIsoFieldsFromParts(calendar, year, resolveCalendarMonth(calendar, fields, year, refineOverflowOptions(options), monthCodeParts), 1)), calendar);
4941
+ function createYearMonthFromRefinedFields(fields, calendar, year, monthCodeParts, overflow) {
4942
+ return createYearMonthFromCalendarParts(calendar, year, resolveCalendarMonth(fields, calendar, year, monthCodeParts, overflow));
4898
4943
  }
4899
4944
 
4900
- function createPlainMonthDayFromFields(calendar, fields, options) {
4945
+ function createMonthDayFromRefinedFields(fields, calendar, year, monthCodeParts, overflow) {
4901
4946
  const isIso = calendar === isoCalendarImpl;
4902
- const eraOrigins = getCalendarEraOrigins(calendar);
4903
- void 0 === fields.day && throwTypeError(missingField("day")), isIso || void 0 === fields.month || void 0 !== fields.year || void 0 !== fields.era && void 0 !== fields.eraYear || throwTypeError(missingYear(eraOrigins));
4904
- const monthCodeParts = parseMonthCodeField(fields);
4905
- let yearMaybe = void 0 !== fields.eraYear || void 0 !== fields.year ? resolveCalendarYear(calendar, fields) : void 0;
4906
- const overflow = refineOverflowOptions(options);
4947
+ let yearMaybe = year;
4907
4948
  let day;
4908
4949
  let monthCodeNumber;
4909
4950
  let isLeapMonth;
4910
4951
  if (void 0 === yearMaybe && isIso && (yearMaybe = 1972), void 0 !== yearMaybe) {
4911
4952
  isIso || checkIsoDateInBounds(computeCalendarIsoFieldsFromParts(calendar, yearMaybe, 1, 1));
4912
- const month = resolveCalendarMonth(calendar, fields, yearMaybe, overflow, monthCodeParts);
4913
- day = resolveCalendarDay(calendar, fields, month, yearMaybe, overflow), [monthCodeNumber, isLeapMonth] = computeCalendarMonthCodeParts(calendar, yearMaybe, month);
4953
+ const month = resolveCalendarMonth(fields, calendar, yearMaybe, monthCodeParts, overflow);
4954
+ day = resolveCalendarDay(fields, calendar, yearMaybe, month, overflow), [monthCodeNumber, isLeapMonth] = computeCalendarMonthCodeParts(calendar, yearMaybe, month);
4914
4955
  } else {
4915
4956
  void 0 === fields.monthCode && throwTypeError("Missing month/monthCode"), [monthCodeNumber, isLeapMonth] = monthCodeParts;
4916
- const referenceYear = calendar ? calendar.ne : 1972;
4957
+ const referenceYear = calendar ? calendar.re : 1972;
4917
4958
  if (void 0 !== referenceYear) {
4918
- day = resolveCalendarDay(calendar, fields, resolveCalendarMonth(calendar, fields, referenceYear, overflow, monthCodeParts), referenceYear, overflow);
4959
+ day = resolveCalendarDay(fields, calendar, referenceYear, resolveCalendarMonth(fields, calendar, referenceYear, monthCodeParts, overflow), overflow);
4919
4960
  } else {
4920
- const constrainedDay = 0 === overflow && calendar ? calendar.fe?.(monthCodeNumber, isLeapMonth, fields.day) : void 0;
4961
+ const constrainedDay = 0 === overflow && calendar ? calendar.ge?.(monthCodeNumber, isLeapMonth, fields.day) : void 0;
4921
4962
  day = void 0 !== constrainedDay ? constrainedDay : fields.day;
4922
4963
  }
4923
4964
  }
4924
- isLeapMonth && ((calendar && calendar.U?.[monthCodeNumber]) ?? 1 / 0) < fields.day && (1 === overflow && throwRangeError(invalidLeapMonth),
4925
- isLeapMonth = 0, day = constrainToRange(fields.day, 1, (calendar && calendar.R) ?? 1 / 0));
4965
+ return createMonthDayFromMonthCodeParts(calendar, monthCodeNumber, isLeapMonth, day, fields.day, overflow);
4966
+ }
4967
+
4968
+ function createYearMonthFromCalendarParts(calendar, year, month) {
4969
+ return createDateSlots(checkIsoYearMonthInBounds(computeCalendarIsoFieldsFromParts(calendar, year, month, 1)), calendar);
4970
+ }
4971
+
4972
+ function createMonthDayFromMonthCodeParts(calendar, monthCodeNumber, isLeapMonthArg, day, requestedDay, overflow) {
4973
+ let isLeapMonth = isLeapMonthArg;
4974
+ isLeapMonth && ((calendar && calendar.V?.[monthCodeNumber]) ?? 1 / 0) < requestedDay && (1 === overflow && throwRangeError(invalidLeapMonth),
4975
+ isLeapMonth = 0, day = constrainToRange(requestedDay, 1, (calendar && calendar.U) ?? 1 / 0));
4926
4976
  let res = calendar ? calendar.u(monthCodeNumber, Boolean(isLeapMonth), day) : computeIsoYearMonthFieldsForMonthDay(monthCodeNumber, Boolean(isLeapMonth));
4927
4977
  for (;!res && 0 === overflow && day > 1; ) {
4928
4978
  day--, res = calendar ? calendar.u(monthCodeNumber, Boolean(isLeapMonth), day) : computeIsoYearMonthFieldsForMonthDay(monthCodeNumber, Boolean(isLeapMonth));
@@ -4932,6 +4982,12 @@ function createPlainMonthDayFromFields(calendar, fields, options) {
4932
4982
  return createDateSlots(checkIsoDateInBounds(computeCalendarIsoFieldsFromParts(calendar, finalYear, finalMonth, day)), calendar);
4933
4983
  }
4934
4984
 
4985
+ function parseMonthCodeField(fields) {
4986
+ if (void 0 !== fields.monthCode) {
4987
+ return parseMonthCode(fields.monthCode);
4988
+ }
4989
+ }
4990
+
4935
4991
  const RawDateTimeFormat = Intl.DateTimeFormat;
4936
4992
 
4937
4993
  function formatEpochMilliToPartsRecord(intlFormat, epochMilli) {
@@ -4964,32 +5020,8 @@ const timeZonePeriodDaysByName = {
4964
5020
 
4965
5021
  const minPossibleTransitionSec = -388152e4;
4966
5022
 
4967
- function refineTimeDisplayTuple(options, maxSmallestUnit = 4) {
4968
- const subsecDigits = coerceFractionalSecondDigits(options);
4969
- const roundingMode = coerceRoundingMode(options, 4);
4970
- const smallestUnit = coerceSmallestUnit(options);
4971
- return [ roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, maxSmallestUnit), subsecDigits) ];
4972
- }
4973
-
4974
- function refineDateDisplayOptions(options) {
4975
- return coerceCalendarDisplay(normalizeOptions(options));
4976
- }
4977
-
4978
- function refineTimeDisplayOptions(options, maxSmallestUnit) {
4979
- return refineTimeDisplayTuple(normalizeOptions(options), maxSmallestUnit);
4980
- }
4981
-
4982
- function resolveSmallestUnitAndSubsecDigits(smallestUnit, subsecDigits) {
4983
- return null != smallestUnit ? [ unitNanoMap[smallestUnit], smallestUnit < 4 ? 9 - 3 * smallestUnit : -1 ] : [ void 0 === subsecDigits ? 1 : 10 ** (9 - subsecDigits), subsecDigits ];
4984
- }
4985
-
4986
5023
  function formatInstantIso(refineTimeZoneString, instantSlots, options) {
4987
- const [timeZoneArg, roundingMode, nanoInc, subsecDigits] = (options => {
4988
- const subsecDigits = coerceFractionalSecondDigits(options = normalizeOptions(options));
4989
- const roundingMode = coerceRoundingMode(options, 4);
4990
- const smallestUnit = coerceSmallestUnit(options);
4991
- return [ options.timeZone, roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, 4), subsecDigits) ];
4992
- })(options);
5024
+ const [timeZoneArg, roundingMode, nanoInc, subsecDigits] = refineInstantDisplayOptions(options);
4993
5025
  const providedTimeZone = void 0 !== timeZoneArg;
4994
5026
  return ((providedTimeZone, timeZone, epochNano, roundingMode, nanoInc, subsecDigits) => {
4995
5027
  epochNano = roundBigNanoToDayOriginInc(epochNano, BigInt(nanoInc), roundingMode);
@@ -4999,15 +5031,7 @@ function formatInstantIso(refineTimeZoneString, instantSlots, options) {
4999
5031
  }
5000
5032
 
5001
5033
  function formatZonedDateTimeIso(zonedDateTimeSlots0, options) {
5002
- const displayOptions = (options => {
5003
- options = normalizeOptions(options);
5004
- const calendarDisplay = coerceCalendarDisplay(options);
5005
- const subsecDigits = coerceFractionalSecondDigits(options);
5006
- const offsetDisplay = coerceOffsetDisplay(options);
5007
- const roundingMode = coerceRoundingMode(options, 4);
5008
- const smallestUnit = coerceSmallestUnit(options);
5009
- return [ calendarDisplay, coerceTimeZoneDisplay(options), offsetDisplay, roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, 4), subsecDigits) ];
5010
- })(options);
5034
+ const displayOptions = refineZonedDateTimeDisplayOptions(options);
5011
5035
  return ((calendar, timeZoneId, timeZone, epochNano, calendarDisplay, timeZoneDisplay, offsetDisplay, roundingMode, nanoInc, subsecDigits) => {
5012
5036
  epochNano = roundBigNanoToDayOriginInc(epochNano, BigInt(nanoInc), roundingMode);
5013
5037
  const offsetNano = timeZone.B(epochNano);
@@ -5016,8 +5040,8 @@ function formatZonedDateTimeIso(zonedDateTimeSlots0, options) {
5016
5040
  }
5017
5041
 
5018
5042
  function formatPlainDateTimeIso(plainDateTimeSlots0, options) {
5019
- const displayOptions = (options => (options = normalizeOptions(options), [ coerceCalendarDisplay(options), ...refineTimeDisplayTuple(options) ]))(options);
5020
- return ((calendar, isoDateTime, calendarDisplay, roundingMode, nanoInc, subsecDigits) => formatIsoDateTimeFields(roundDateTimeToNano(isoDateTime, nanoInc, roundingMode), subsecDigits) + formatCalendar(calendar, calendarDisplay))(plainDateTimeSlots0.calendar, plainDateTimeSlots0, ...displayOptions);
5043
+ const displayOptions = refineDateTimeDisplayOptions(options);
5044
+ return ((calendar, isoDateTime, calendarDisplay, roundingMode, nanoInc, subsecDigits) => formatIsoDateTimeFields(roundDateTimeToInc(isoDateTime, nanoInc, roundingMode), subsecDigits) + formatCalendar(calendar, calendarDisplay))(plainDateTimeSlots0.calendar, plainDateTimeSlots0, ...displayOptions);
5021
5045
  }
5022
5046
 
5023
5047
  function formatPlainDateIso(plainDateSlots, options) {
@@ -5040,7 +5064,7 @@ function formatDateLikeIso(calendar, formatSimple, isoDate, calendarDisplay) {
5040
5064
  }
5041
5065
 
5042
5066
  function formatPlainTimeIso(slots, options) {
5043
- return ((fields, roundingMode, nanoInc, subsecDigits) => formatTimeFields(roundTimeToNano(fields, nanoInc, roundingMode)[0], subsecDigits))(slots, ...refineTimeDisplayOptions(options));
5067
+ return ((fields, roundingMode, nanoInc, subsecDigits) => formatTimeFields(roundTimeToInc(fields, nanoInc, roundingMode)[0], subsecDigits))(slots, ...refineTimeDisplayOptions(options));
5044
5068
  }
5045
5069
 
5046
5070
  function formatDurationIso(slots, options) {
@@ -5094,17 +5118,17 @@ function formatIsoDateTimeFields(isoDateTime, subsecDigits) {
5094
5118
  return formatIsoDateFields(isoDateTime) + "T" + formatTimeFields(isoDateTime, subsecDigits);
5095
5119
  }
5096
5120
 
5097
- function formatIsoDateFields(isoDateFields) {
5098
- return formatIsoYearMonthFields(isoDateFields) + "-" + padNumber2(isoDateFields.day);
5121
+ function formatIsoDateFields(isoDate) {
5122
+ return formatIsoYearMonthFields(isoDate) + "-" + padNumber2(isoDate.day);
5099
5123
  }
5100
5124
 
5101
- function formatIsoYearMonthFields(isoDateFields) {
5102
- const {year: year} = isoDateFields;
5103
- return (year < 0 || year > 9999 ? getSignStr(year) + padNumber(6, Math.abs(year)) : padNumber(4, year)) + "-" + padNumber2(isoDateFields.month);
5125
+ function formatIsoYearMonthFields(isoDate) {
5126
+ const {year: year} = isoDate;
5127
+ return (year < 0 || year > 9999 ? getSignStr(year) + padNumber(6, Math.abs(year)) : padNumber(4, year)) + "-" + padNumber2(isoDate.month);
5104
5128
  }
5105
5129
 
5106
- function formatIsoMonthDayFields(isoDateFields) {
5107
- return padNumber2(isoDateFields.month) + "-" + padNumber2(isoDateFields.day);
5130
+ function formatIsoMonthDayFields(isoDate) {
5131
+ return padNumber2(isoDate.month) + "-" + padNumber2(isoDate.day);
5108
5132
  }
5109
5133
 
5110
5134
  function formatTimeFields(timeFields, subsecDigits) {
@@ -5166,7 +5190,7 @@ function resolveTimeZoneRecord(rawId) {
5166
5190
  if (void 0 !== offsetNano) {
5167
5191
  return {
5168
5192
  id: formatOffsetNano(offsetNano),
5169
- X: offsetNano,
5193
+ Z: offsetNano,
5170
5194
  m: offsetNano
5171
5195
  };
5172
5196
  }
@@ -5217,24 +5241,24 @@ function queryTimeZone(rawTimeZoneId) {
5217
5241
  return queryTimeZoneRecord(record.id, record);
5218
5242
  }
5219
5243
 
5220
- const queryTimeZoneRecord = /*@__PURE__*/ memoize((normTimeZoneId, record) => "named" === record.kind ? new IntlTimeZone(normTimeZoneId, record.m, record.format) : new FixedTimeZone(normTimeZoneId, record.m, "fixed" === record.kind ? record.X : 0));
5244
+ const queryTimeZoneRecord = /*@__PURE__*/ memoize((normTimeZoneId, record) => "named" === record.kind ? new IntlTimeZone(normTimeZoneId, record.m, record.format) : new FixedTimeZone(normTimeZoneId, record.m, "fixed" === record.kind ? record.Z : 0));
5221
5245
 
5222
5246
  class FixedTimeZone {
5223
5247
  constructor(id, compareKey, offsetNano) {
5224
- this.id = id, this.m = compareKey, this.X = offsetNano;
5248
+ this.id = id, this.m = compareKey, this.Z = offsetNano;
5225
5249
  }
5226
5250
  B() {
5227
- return this.X;
5251
+ return this.Z;
5228
5252
  }
5229
- N(isoDateTime) {
5230
- return [ isoDateTimeAndOffsetToEpochNano(isoDateTime, this.X) ];
5253
+ R(isoDateTime) {
5254
+ return [ isoDateTimeAndOffsetToEpochNano(isoDateTime, this.Z) ];
5231
5255
  }
5232
- O() {}
5256
+ C() {}
5233
5257
  }
5234
5258
 
5235
5259
  class IntlTimeZone {
5236
5260
  constructor(id, compareKey, format) {
5237
- this.id = id, this.m = compareKey, this.ke = ((computeOffsetSec, periodDays) => {
5261
+ this.id = id, this.m = compareKey, this.oe = ((computeOffsetSec, periodDays) => {
5238
5262
  const getSample = memoize(computeOffsetSec);
5239
5263
  const getSplit = memoize(createSplitTuple);
5240
5264
  const periodSec = 86400 * periodDays;
@@ -5256,7 +5280,7 @@ class IntlTimeZone {
5256
5280
  return offsetSec;
5257
5281
  }
5258
5282
  return {
5259
- xe(zonedEpochSec) {
5283
+ Ae(zonedEpochSec) {
5260
5284
  const wideOffsetSec0 = getOffsetSec(zonedEpochSec - 86400);
5261
5285
  const wideOffsetSec1 = getOffsetSec(zonedEpochSec + 86400);
5262
5286
  const wideUtcEpochSec0 = zonedEpochSec - wideOffsetSec0;
@@ -5267,8 +5291,8 @@ class IntlTimeZone {
5267
5291
  const narrowOffsetSec0 = getOffsetSec(wideUtcEpochSec0);
5268
5292
  return narrowOffsetSec0 === getOffsetSec(wideUtcEpochSec1) ? [ zonedEpochSec - narrowOffsetSec0 ] : wideOffsetSec0 > wideOffsetSec1 ? [ wideUtcEpochSec0, wideUtcEpochSec1 ] : [];
5269
5293
  },
5270
- we: getOffsetSec,
5271
- O: function getTransition(epochSec, direction) {
5294
+ ze: getOffsetSec,
5295
+ C: function getTransition(epochSec, direction) {
5272
5296
  if (direction > 0 && epochSec >= 864e10) {
5273
5297
  return;
5274
5298
  }
@@ -5305,7 +5329,7 @@ class IntlTimeZone {
5305
5329
  };
5306
5330
  })((format => epochSec => {
5307
5331
  const intlParts = formatEpochMilliToPartsRecord(format, 1e3 * epochSec);
5308
- return 86400 * isoArgsToEpochDays((intlParts => {
5332
+ return 86400 * isoPartsToEpochDays((intlParts => {
5309
5333
  const relatedYear = intlParts.relatedYear;
5310
5334
  if (void 0 !== relatedYear) {
5311
5335
  return parseInt(relatedYear);
@@ -5319,16 +5343,16 @@ class IntlTimeZone {
5319
5343
  })(id));
5320
5344
  }
5321
5345
  B(epochNano) {
5322
- return this.ke.we((epochNano => epochNanoToSecMod(epochNano)[0])(epochNano)) * nanoInSec;
5346
+ return this.oe.ze((epochNano => epochNanoToSecMod(epochNano)[0])(epochNano)) * nanoInSec;
5323
5347
  }
5324
- N(isoDateTime) {
5348
+ R(isoDateTime) {
5325
5349
  const zonedEpochSec = 86400 * isoDateToEpochDays(isoDateTime) + timeFieldsToSec(isoDateTime);
5326
5350
  const subsecNano = timeFieldsToSubsecNano(isoDateTime);
5327
- return this.ke.xe(zonedEpochSec).map(epochSec => checkEpochNanoInBounds(BigInt(epochSec) * bigNanoInSec + BigInt(subsecNano)));
5351
+ return this.oe.Ae(zonedEpochSec).map(epochSec => checkEpochNanoInBounds(BigInt(epochSec) * bigNanoInSec + BigInt(subsecNano)));
5328
5352
  }
5329
- O(epochNano, direction) {
5353
+ C(epochNano, direction) {
5330
5354
  const [epochSec, subsecNano] = epochNanoToSecMod(epochNano);
5331
- const resEpochSec = this.ke.O(epochSec + (direction > 0 || subsecNano ? 1 : 0), direction);
5355
+ const resEpochSec = this.oe.C(epochSec + (direction > 0 || subsecNano ? 1 : 0), direction);
5332
5356
  if (void 0 !== resEpochSec) {
5333
5357
  return BigInt(resEpochSec) * bigNanoInSec;
5334
5358
  }
@@ -5354,46 +5378,56 @@ function clampIntlSampleEpochSec(epochSec) {
5354
5378
 
5355
5379
  function refineMaybeZonedDateTimeObjectLike(refineTimeZoneString, calendar, bag) {
5356
5380
  const fields = readAndRefineBagFields(bag, getCalendarFieldNames(calendar, dateTimeAndZoneFieldNamesAlpha, dateTimeAndZoneFieldNamesWithEraAlpha), zonedDateTimeFieldRefiners, [], 0);
5357
- if (void 0 !== fields.timeZone) {
5358
- const isoDateFields = createPlainDateFromFields(calendar, fields);
5381
+ const isZoned = void 0 !== fields.timeZone;
5382
+ const [year, monthCodeParts] = refineCalendarDateFields(fields, calendar);
5383
+ const isoDate = createDateFromRefinedFields(fields, calendar, year, monthCodeParts, 0);
5384
+ if (isZoned) {
5359
5385
  const timeFields = resolveTimeFields(fields);
5360
5386
  const timeZone = queryTimeZone(refineTimeZoneString(fields.timeZone));
5361
5387
  return {
5362
- epochNanoseconds: getMatchingInstantFor(timeZone, combineDateAndTime(isoDateFields, timeFields), fields.offset),
5388
+ epochNanoseconds: getMatchingInstantFor(timeZone, combineDateAndTime(isoDate, timeFields), fields.offset),
5363
5389
  timeZone: timeZone,
5364
5390
  calendar: calendar
5365
5391
  };
5366
5392
  }
5367
- return createPlainDateFromFields(calendar, fields);
5393
+ return isoDate;
5368
5394
  }
5369
5395
 
5370
5396
  function refineZonedDateTimeObjectLike(refineTimeZoneString, calendar, bag, options) {
5371
5397
  const fields = readAndRefineBagFields(bag, getCalendarFieldNames(calendar, dateTimeAndZoneFieldNamesAlpha, dateTimeAndZoneFieldNamesWithEraAlpha), zonedDateTimeFieldRefiners, timeZoneFieldNames, 0);
5372
5398
  const timeZoneId = refineTimeZoneString(fields.timeZone);
5373
- const [isoDateFields, overflow, offsetDisambig, epochDisambig] = createPlainDateFromFieldsWithOptionsRefiner(calendar, fields, () => refineZonedFieldOptions(options));
5399
+ const [year, monthCodeParts] = refineCalendarDateFields(fields, calendar);
5400
+ const [overflow, offsetDisambig, epochDisambig] = refineZonedFieldOptions(options);
5401
+ const isoDate = createDateFromRefinedFields(fields, calendar, year, monthCodeParts, overflow);
5374
5402
  const timeFields = resolveTimeFields(fields, overflow);
5375
5403
  const timeZone = queryTimeZone(timeZoneId);
5376
- return createZonedEpochNanoSlots(getMatchingInstantFor(timeZone, combineDateAndTime(isoDateFields, timeFields), fields.offset, offsetDisambig, epochDisambig), timeZone, calendar);
5404
+ return createZonedEpochNanoSlots(getMatchingInstantFor(timeZone, combineDateAndTime(isoDate, timeFields), fields.offset, offsetDisambig, epochDisambig), timeZone, calendar);
5377
5405
  }
5378
5406
 
5379
5407
  function refinePlainDateTimeObjectLike(calendar, bag, options) {
5380
5408
  const fields = readAndRefineBagFields(bag, getCalendarFieldNames(calendar, dateTimeFieldNamesAlpha, dateTimeFieldNamesWithEraAlpha), dateTimeFieldRefiners, [], 0);
5381
- const [isoDateInternals, overflow] = createPlainDateFromFieldsWithOptionsRefiner(calendar, fields, () => [ refineOverflowOptions(options) ]);
5382
- return createPlainDateTimeFromRefinedFields(isoDateInternals, resolveTimeFields(fields, overflow), calendar);
5409
+ const [year, monthCodeParts] = refineCalendarDateFields(fields, calendar);
5410
+ const overflow = refineOverflowOptions(options);
5411
+ return createDateTimeFromRefinedFields(createDateFromRefinedFields(fields, calendar, year, monthCodeParts, overflow), resolveTimeFields(fields, overflow), calendar);
5383
5412
  }
5384
5413
 
5385
5414
  function refinePlainDateObjectLike(calendar, bag, options, requireFields = []) {
5386
- return createPlainDateFromFields(calendar, readAndRefineBagFields(bag, getCalendarFieldNames(calendar, dateFieldNamesAlpha, dateFieldNamesWithEraAlpha), dateFieldRefiners, requireFields), options);
5415
+ const fields = readAndRefineBagFields(bag, getCalendarFieldNames(calendar, dateFieldNamesAlpha, dateFieldNamesWithEraAlpha), dateFieldRefiners, requireFields);
5416
+ const [year, monthCodeParts] = refineCalendarDateFields(fields, calendar);
5417
+ return createDateFromRefinedFields(fields, calendar, year, monthCodeParts, refineOverflowOptions(options));
5387
5418
  }
5388
5419
 
5389
5420
  function refinePlainYearMonthObjectLike(calendar, bag, options, requireFields) {
5390
- return createPlainYearMonthFromFields(calendar, readAndRefineBagFields(bag, getCalendarFieldNames(calendar, yearMonthFieldNamesAlpha, yearMonthFieldNamesWithEraAlpha), dateFieldRefiners, requireFields), options);
5421
+ const fields = readAndRefineBagFields(bag, getCalendarFieldNames(calendar, yearMonthFieldNamesAlpha, yearMonthFieldNamesWithEraAlpha), dateFieldRefiners, requireFields);
5422
+ const [year, monthCodeParts] = refineCalendarDateFields(fields, calendar, 1);
5423
+ return createYearMonthFromRefinedFields(fields, calendar, year, monthCodeParts, refineOverflowOptions(options));
5391
5424
  }
5392
5425
 
5393
5426
  function refinePlainMonthDayObjectLike(calendar, calendarAbsent, bag, options) {
5394
5427
  const fields = readAndRefineBagFields(bag, getCalendarFieldNames(calendar, dateFieldNamesAlpha, dateFieldNamesWithEraAlpha), dateFieldRefiners, dayFieldNamesAsc, 0);
5395
- return calendarAbsent && void 0 !== fields.month && void 0 === fields.monthCode && void 0 === fields.year && (fields.year = 1972),
5396
- createPlainMonthDayFromFields(calendar, fields, options);
5428
+ calendarAbsent && void 0 !== fields.month && void 0 === fields.monthCode && void 0 === fields.year && (fields.year = 1972);
5429
+ const [year, monthCodeParts] = refineMonthDayFields(fields, calendar);
5430
+ return createMonthDayFromRefinedFields(fields, calendar, year, monthCodeParts, refineOverflowOptions(options));
5397
5431
  }
5398
5432
 
5399
5433
  function refinePlainTimeObjectLike(bag, options) {
@@ -5413,16 +5447,16 @@ function throwFailedParse(s) {
5413
5447
  }
5414
5448
 
5415
5449
  function parseInstant(s) {
5416
- const organized = parseDateTimeLike(s = toStringViaPrimitive(s));
5450
+ const organized = parseDateTimeLike(s = requireString(toPrimitiveWithStringHint(s)));
5417
5451
  let offsetNano;
5418
- return organized || throwFailedParse(s), organized.C ? offsetNano = 0 : organized.offset ? offsetNano = parseOffsetNano(organized.offset) : throwFailedParse(s),
5452
+ return organized || throwFailedParse(s), organized.F ? offsetNano = 0 : organized.offset ? offsetNano = parseOffsetNano(organized.offset) : throwFailedParse(s),
5419
5453
  organized.timeZoneId && parseOffsetNanoMaybe(organized.timeZoneId, 1), validateIsoDateTimeFields(organized),
5420
5454
  createEpochNanoSlots(isoDateTimeAndOffsetToEpochNano(organized, offsetNano));
5421
5455
  }
5422
5456
 
5423
5457
  function parseRelativeToSlots(s, resolveCalendar) {
5424
5458
  const organized = parseDateTimeLike(requireString(s));
5425
- return organized || throwFailedParse(s), organized.timeZoneId ? finalizeZonedDateTime(organized, resolveCalendar, void 0) : (organized.C && throwFailedParse(s),
5459
+ return organized || throwFailedParse(s), organized.timeZoneId ? finalizeZonedDateTime(organized, resolveCalendar, void 0) : (organized.F && throwFailedParse(s),
5426
5460
  finalizeDate(organized, resolveCalendar));
5427
5461
  }
5428
5462
 
@@ -5433,7 +5467,7 @@ function parseZonedDateTime(s, resolveCalendar, options) {
5433
5467
 
5434
5468
  function parsePlainDateTime(s, resolveCalendar) {
5435
5469
  const organized = parseDateTimeLike(requireString(s));
5436
- return organized && !organized.C || throwFailedParse(s), finalizeDateTime(organized, resolveCalendar);
5470
+ return organized && !organized.F || throwFailedParse(s), finalizeDateTime(organized, resolveCalendar);
5437
5471
  }
5438
5472
 
5439
5473
  function parsePlainDate(s, resolveCalendar) {
@@ -5478,7 +5512,7 @@ function parsePlainTime(s) {
5478
5512
  })(s = requireString(s));
5479
5513
  if (!organized) {
5480
5514
  const dateTime = parseDateTimeLike(s);
5481
- dateTime && dateTime.re || throwFailedParse(s), dateTime.C && throwRangeError(invalidSubstring("Z")),
5515
+ dateTime && dateTime.te || throwFailedParse(s), dateTime.F && throwRangeError(invalidSubstring("Z")),
5482
5516
  requireIsoCalendar(dateTime), organized = dateTime;
5483
5517
  }
5484
5518
  let altParsed;
@@ -5530,17 +5564,17 @@ function parseCalendarId(s) {
5530
5564
 
5531
5565
  function parseTimeZoneId(s) {
5532
5566
  const parsed = parseDateTimeLike(s);
5533
- return parsed && (parsed.timeZoneId || parsed.C && "UTC" || parsed.offset) || s;
5567
+ return parsed && (parsed.timeZoneId || parsed.F && "UTC" || parsed.offset) || s;
5534
5568
  }
5535
5569
 
5536
5570
  function parsePlainDateLike(s) {
5537
5571
  const organized = parseDateTimeLike(s);
5538
- return organized && !organized.C || throwFailedParse(s), organized;
5572
+ return organized && !organized.F || throwFailedParse(s), organized;
5539
5573
  }
5540
5574
 
5541
5575
  function finalizeDateLike(organized, isoDateProjector, resolveCalendar) {
5542
5576
  return isoDateProjector && "iso8601" === organized.calendarId ? (validateIsoDateFields(organized),
5543
- organized.re && validateTimeFields(organized), finalizeDate(isoDateProjector(organized), resolveCalendar)) : organized.re ? finalizeDateTime(organized, resolveCalendar) : finalizeDate(organized, resolveCalendar);
5577
+ organized.te && validateTimeFields(organized), finalizeDate(isoDateProjector(organized), resolveCalendar)) : organized.te ? finalizeDateTime(organized, resolveCalendar) : finalizeDate(organized, resolveCalendar);
5544
5578
  }
5545
5579
 
5546
5580
  function projectIsoYearMonthDate(organized) {
@@ -5561,11 +5595,11 @@ function projectIsoMonthDayDate(organized) {
5561
5595
  function finalizeZonedDateTime(organized, resolveCalendar, options) {
5562
5596
  const timeZone = queryTimeZone(resolveTimeZoneId(organized.timeZoneId));
5563
5597
  let epochNano;
5564
- if (validateIsoDateTimeFields(organized), organized.re) {
5598
+ if (validateIsoDateTimeFields(organized), organized.te) {
5565
5599
  const offsetNano = organized.offset ? parseOffsetNano(organized.offset) : void 0;
5566
5600
  const [, offsetDisambig, epochDisambig] = refineZonedFieldOptions(options);
5567
- epochNano = getMatchingInstantFor(timeZone, organized, offsetNano, offsetDisambig, epochDisambig, !(timeZone.X || void 0 === organized.offset || (offset = organized.offset,
5568
- offset.replace(/\D/g, "").length > 4)), organized.C);
5601
+ epochNano = getMatchingInstantFor(timeZone, organized, offsetNano, offsetDisambig, epochDisambig, !(timeZone.Z || void 0 === organized.offset || (offset = organized.offset,
5602
+ offset.replace(/\D/g, "").length > 4)), organized.F);
5569
5603
  } else {
5570
5604
  refineZonedFieldOptions(options), epochNano = getStartOfDayInstantFor(timeZone, organized);
5571
5605
  }
@@ -5619,8 +5653,8 @@ function parseDateTimeLike(s) {
5619
5653
  day: parseInt(parts[6]),
5620
5654
  ...organizeTimeParts(parts, 7),
5621
5655
  ...organizeAnnotationParts(parts[19]),
5622
- re: Boolean(parts[7]),
5623
- C: hasZ,
5656
+ te: Boolean(parts[7]),
5657
+ F: hasZ,
5624
5658
  offset: hasZ ? void 0 : zOrOffset
5625
5659
  };
5626
5660
  })(parts) : void 0;
@@ -5690,7 +5724,7 @@ function organizeAnnotationParts(s) {
5690
5724
  function mergeCalendarFields(calendar, baseFields, additionalFields) {
5691
5725
  const merged = Object.assign(Object.create(null), baseFields);
5692
5726
  return spliceFields(merged, additionalFields, monthFieldNames), getCalendarEraOrigins(calendar) && (spliceFields(merged, additionalFields, allYearFieldNames),
5693
- calendar && calendar.ge && spliceFields(merged, additionalFields, monthDayFieldNames, eraYearFieldNames)),
5727
+ calendar && calendar.je && spliceFields(merged, additionalFields, monthDayFieldNames, eraYearFieldNames)),
5694
5728
  merged;
5695
5729
  }
5696
5730
 
@@ -5707,8 +5741,7 @@ function spliceFields(dest, additional, allPropNames, deletablePropNames) {
5707
5741
  }
5708
5742
  }
5709
5743
 
5710
- function mergeZonedDateTimeFields(zonedDateTimeSlots, modFields, options) {
5711
- const {calendar: calendar, timeZone: timeZone} = zonedDateTimeSlots;
5744
+ function mergeZonedDateTimeFields(calendar, zonedDateTimeSlots, modFields) {
5712
5745
  const validFieldNames = getCalendarFieldNames(calendar, dateTimeAndOffsetFieldNamesAlpha, dateTimeAndOffsetFieldNamesWithEraAlpha);
5713
5746
  const zonedSlots = zonedEpochSlotsToIso(zonedDateTimeSlots);
5714
5747
  const {year: year, month: month, day: day} = computeCalendarDateFields(calendar, zonedSlots);
@@ -5726,16 +5759,13 @@ function mergeZonedDateTimeFields(zonedDateTimeSlots, modFields, options) {
5726
5759
  };
5727
5760
  const partialFields = readAndRefineBagFields(modFields, validFieldNames, zonedDateTimeFieldRefiners);
5728
5761
  const mergedCalendarFields = mergeCalendarFields(calendar, origFields, partialFields);
5729
- const mergedAllFields = {
5762
+ return [ {
5730
5763
  ...origFields,
5731
5764
  ...partialFields
5732
- };
5733
- const [isoDateFields, overflow, offsetDisambig, epochDisambig] = createPlainDateFromFieldsWithOptionsRefiner(calendar, mergedCalendarFields, () => refineZonedFieldOptions(options, 2));
5734
- return createZonedEpochNanoSlots(getMatchingInstantFor(timeZone, combineDateAndTime(isoDateFields, constrainTimeFields(mergedAllFields, overflow)), mergedAllFields.offset, offsetDisambig, epochDisambig), timeZone, calendar);
5765
+ }, mergedCalendarFields ];
5735
5766
  }
5736
5767
 
5737
- function mergePlainDateTimeFields(plainDateTimeSlots, modFields, options) {
5738
- const {calendar: calendar} = plainDateTimeSlots;
5768
+ function mergeDateTimeFields(calendar, plainDateTimeSlots, modFields) {
5739
5769
  const validFieldNames = getCalendarFieldNames(calendar, dateTimeFieldNamesAlpha, dateTimeFieldNamesWithEraAlpha);
5740
5770
  const {year: year, month: month, day: day} = computeCalendarDateFields(calendar, plainDateTimeSlots);
5741
5771
  const origFields = {
@@ -5751,50 +5781,54 @@ function mergePlainDateTimeFields(plainDateTimeSlots, modFields, options) {
5751
5781
  };
5752
5782
  const partialFields = readAndRefineBagFields(modFields, validFieldNames, dateTimeFieldRefiners);
5753
5783
  const mergedCalendarFields = mergeCalendarFields(calendar, origFields, partialFields);
5754
- const mergedAllFields = {
5784
+ return [ {
5755
5785
  ...origFields,
5756
5786
  ...partialFields
5757
- };
5758
- const [plainDateSlots, overflow] = createPlainDateFromFieldsWithOptionsRefiner(calendar, mergedCalendarFields, () => [ refineOverflowOptions(options) ]);
5759
- return createPlainDateTimeFromRefinedFields(plainDateSlots, constrainTimeFields(mergedAllFields, overflow), calendar);
5787
+ }, mergedCalendarFields ];
5760
5788
  }
5761
5789
 
5762
- function mergePlainDateFields(plainDateSlots, modFields, options) {
5763
- const {calendar: calendar} = plainDateSlots;
5790
+ function mergeDateFields(calendar, plainDateSlots, modFields) {
5764
5791
  const validFieldNames = getCalendarFieldNames(calendar, dateFieldNamesAlpha, dateFieldNamesWithEraAlpha);
5765
5792
  const {year: year, month: month, day: day} = computeCalendarDateFields(calendar, plainDateSlots);
5766
- return createPlainDateFromFields(calendar, mergeCalendarFields(calendar, {
5793
+ return mergeCalendarFields(calendar, {
5767
5794
  year: year,
5768
5795
  monthCode: computeMonthCode(calendar, year, month),
5769
5796
  day: day
5770
- }, readAndRefineBagFields(modFields, validFieldNames, dateFieldRefiners)), options);
5797
+ }, readAndRefineBagFields(modFields, validFieldNames, dateFieldRefiners));
5771
5798
  }
5772
5799
 
5773
- function mergePlainYearMonthFields(plainYearMonthSlots, modFields, options) {
5774
- const {calendar: calendar} = plainYearMonthSlots;
5800
+ function mergeYearMonthFields(calendar, plainYearMonthSlots, modFields) {
5775
5801
  const validFieldNames = getCalendarFieldNames(calendar, yearMonthFieldNamesAlpha, yearMonthFieldNamesWithEraAlpha);
5776
5802
  const {year: year, month: month} = computeCalendarDateFields(calendar, plainYearMonthSlots);
5777
- return createPlainYearMonthFromFields(calendar, mergeCalendarFields(calendar, {
5803
+ return mergeCalendarFields(calendar, {
5778
5804
  year: year,
5779
5805
  monthCode: computeMonthCode(calendar, year, month)
5780
- }, readAndRefineBagFields(modFields, validFieldNames, dateFieldRefiners)), options);
5806
+ }, readAndRefineBagFields(modFields, validFieldNames, dateFieldRefiners));
5781
5807
  }
5782
5808
 
5783
- function mergePlainMonthDayFields(plainMonthDaySlots, modFields, options) {
5784
- const {calendar: calendar} = plainMonthDaySlots;
5809
+ function mergeMonthDayFields(calendar, plainMonthDaySlots, modFields) {
5785
5810
  const validFieldNames = getCalendarFieldNames(calendar, dateFieldNamesAlpha, dateFieldNamesWithEraAlpha);
5786
5811
  const {year: year, month: month, day: day} = computeCalendarDateFields(calendar, plainMonthDaySlots);
5787
- return createPlainMonthDayFromFields(calendar, mergeCalendarFields(calendar, {
5812
+ return mergeCalendarFields(calendar, {
5788
5813
  monthCode: computeMonthCode(calendar, year, month),
5789
5814
  day: day
5790
- }, readAndRefineBagFields(modFields, validFieldNames, dateFieldRefiners)), options);
5815
+ }, readAndRefineBagFields(modFields, validFieldNames, dateFieldRefiners));
5816
+ }
5817
+
5818
+ function createZonedDateTimeFromMergedFields(zonedDateTimeSlots, mergedAllFields, calendarFields, year, monthCodeParts, overflow, offsetDisambig, epochDisambig) {
5819
+ const {calendar: calendar, timeZone: timeZone} = zonedDateTimeSlots;
5820
+ return createZonedEpochNanoSlots(getMatchingInstantFor(timeZone, combineDateAndTime(createDateFromRefinedFields(calendarFields, calendar, year, monthCodeParts, overflow), constrainTimeFields(mergedAllFields, overflow)), mergedAllFields.offset, offsetDisambig, epochDisambig), timeZone, calendar);
5791
5821
  }
5792
5822
 
5793
- function mergePlainTimeFields(initialFields, mod, options) {
5794
- return ((initialFields, modFields, options) => resolveTimeFields({
5823
+ function createDateTimeFromMergedFields(mergedAllFields, calendarFields, calendar, year, monthCodeParts, overflow) {
5824
+ return createDateTimeFromRefinedFields(createDateFromRefinedFields(calendarFields, calendar, year, monthCodeParts, overflow), constrainTimeFields(mergedAllFields, overflow), calendar);
5825
+ }
5826
+
5827
+ function mergeTimeFields(initialFields, modFields) {
5828
+ return {
5795
5829
  ...pluckProps(timeFieldNamesAlpha, initialFields),
5796
5830
  ...readAndRefineBagFields(modFields, timeFieldNamesAlpha, timeFieldRefiners)
5797
- }, refineOverflowOptions(options)))(initialFields, mod, options);
5831
+ };
5798
5832
  }
5799
5833
 
5800
5834
  function mergeDurationFields(slots, fields) {
@@ -5810,6 +5844,30 @@ function computeMonthCode(calendar, year, month) {
5810
5844
  return formatMonthCode(monthCodeNumber, isLeapMonth);
5811
5845
  }
5812
5846
 
5847
+ function totalDuration(refineRelativeTo, slots, options) {
5848
+ const [totalUnit, relativeToSlots] = refineTotalOptions(options, refineRelativeTo);
5849
+ const maxDurationUnit = getMaxDurationUnit(slots);
5850
+ const maxUnit = Math.max(totalUnit, maxDurationUnit);
5851
+ const isZoned = relativeToSlots && isZonedEpochSlots(relativeToSlots);
5852
+ if (!relativeToSlots && isUniformUnit(maxUnit, isZoned)) {
5853
+ return totalDayTimeDuration(slots, totalUnit);
5854
+ }
5855
+ if (relativeToSlots || throwRangeError("Missing relativeTo"), !slots.sign && (!isZoned || totalUnit < 6)) {
5856
+ return 0;
5857
+ }
5858
+ const [balancedDuration, endEpochNano, relativeOps] = spanRelativeDuration(relativeToSlots, slots, totalUnit);
5859
+ return isUniformUnit(totalUnit, isZoned) ? totalDayTimeDuration(balancedDuration, totalUnit) : ((durationFields, endEpochNano, totalUnit, relativeOps) => {
5860
+ const fieldName = durationFieldNamesAsc[totalUnit];
5861
+ const baseDurationFields = clearDurationFields(totalUnit, durationFields);
5862
+ return totalRelativeUnit(durationFields[fieldName], computeDurationSign(durationFields) || 1, endEpochNano, value => (baseDurationFields[fieldName] = value,
5863
+ moveRelativeMarkerToEpochNano(relativeOps, baseDurationFields)));
5864
+ })(balancedDuration, endEpochNano, totalUnit, relativeOps);
5865
+ }
5866
+
5867
+ function totalDayTimeDuration(durationFields, totalUnit) {
5868
+ return divideBigNanoToExactNumber(durationDayTimeToBigNano(durationFields), unitNanoMap[totalUnit]);
5869
+ }
5870
+
5813
5871
  function instantToZonedDateTime(instantSlots, timeZone, calendar) {
5814
5872
  return createZonedEpochNanoSlots(instantSlots.epochNanoseconds, timeZone, calendar);
5815
5873
  }
@@ -5818,55 +5876,55 @@ function zonedDateTimeToInstant(zonedDateTimeSlots0) {
5818
5876
  return createEpochNanoSlots(zonedDateTimeSlots0.epochNanoseconds);
5819
5877
  }
5820
5878
 
5821
- function zonedDateTimeToPlainDateTime(zonedDateTimeSlots0) {
5879
+ function zonedDateTimeToDateTime(zonedDateTimeSlots0) {
5822
5880
  return createDateTimeSlots(zonedEpochSlotsToIso(zonedDateTimeSlots0), zonedDateTimeSlots0.calendar);
5823
5881
  }
5824
5882
 
5825
- function zonedDateTimeToPlainDate(zonedDateTimeSlots0) {
5883
+ function zonedDateTimeToDate(zonedDateTimeSlots0) {
5826
5884
  return createDateSlots(zonedEpochSlotsToIso(zonedDateTimeSlots0), zonedDateTimeSlots0.calendar);
5827
5885
  }
5828
5886
 
5829
- function zonedDateTimeToPlainTime(zonedDateTimeSlots0) {
5887
+ function zonedDateTimeToTime(zonedDateTimeSlots0) {
5830
5888
  return createTimeSlots(zonedEpochSlotsToIso(zonedDateTimeSlots0));
5831
5889
  }
5832
5890
 
5833
- function plainDateTimeToZonedDateTime(plainDateTimeSlots, timeZone, options) {
5834
- const epochNano = getSingleInstantFor(timeZone, plainDateTimeSlots, (options => coerceEpochDisambig(normalizeOptions(options)))(options));
5835
- return createZonedEpochNanoSlots(checkEpochNanoInBounds(epochNano), timeZone, plainDateTimeSlots.calendar);
5891
+ function dateTimeToZonedDateTime(plainDateTimeSlots, timeZone, epochDisambig) {
5892
+ return createZonedEpochNanoSlots(checkEpochNanoInBounds(getSingleInstantFor(timeZone, plainDateTimeSlots, epochDisambig)), timeZone, plainDateTimeSlots.calendar);
5836
5893
  }
5837
5894
 
5838
- function plainDateToZonedDateTime(refineTimeZoneString, refinePlainTimeArg, plainDateSlots, options) {
5839
- const timeZoneId = refineTimeZoneString(options.timeZone);
5840
- const plainTimeArg = options.plainTime;
5841
- const timeFields = void 0 !== plainTimeArg ? refinePlainTimeArg(plainTimeArg) : void 0;
5842
- const timeZone = queryTimeZone(timeZoneId);
5895
+ function dateToZonedDateTime(plainDateSlots, timeZone, timeFields) {
5843
5896
  let epochNano;
5844
5897
  return epochNano = timeFields ? getSingleInstantFor(timeZone, combineDateAndTime(plainDateSlots, timeFields)) : getStartOfDayInstantFor(timeZone, combineDateAndTime(plainDateSlots, timeFieldDefaults)),
5845
5898
  createZonedEpochNanoSlots(epochNano, timeZone, plainDateSlots.calendar);
5846
5899
  }
5847
5900
 
5848
- function convertPlainYearMonthToDate(calendar, input, bag) {
5849
- return createPlainDateFromMergedFields(calendar, pluckProps(getCalendarFieldNames(calendar, yearMonthCodeFieldNamesAlpha, yearMonthCodeFieldNamesWithEraAlpha), input), readAndRefineBagFields(requireObjectLike(bag), dayFieldNamesAsc, dateFieldRefiners, []));
5901
+ function yearMonthToDate(calendar, input, bag) {
5902
+ return mergeFieldsIntoDate(calendar, pluckProps(getCalendarFieldNames(calendar, yearMonthCodeFieldNamesAlpha, yearMonthCodeFieldNamesWithEraAlpha), input), readAndRefineBagFields(requireObjectLike(bag), dayFieldNamesAsc, dateFieldRefiners, []));
5850
5903
  }
5851
5904
 
5852
- function convertPlainMonthDayToDate(calendar, input, bag) {
5905
+ function monthDayToDate(calendar, input, bag) {
5853
5906
  const extraFieldNames = getCalendarFieldNames(calendar, yearFieldNamesAsc, yearFieldNamesWithEraAlpha);
5854
- return createPlainDateFromMergedFields(calendar, pluckProps(monthCodeDayFieldNamesAlpha, input), readAndRefineBagFields(requireObjectLike(bag), extraFieldNames, dateFieldRefiners, []));
5907
+ return mergeFieldsIntoDate(calendar, pluckProps(monthCodeDayFieldNamesAlpha, input), readAndRefineBagFields(requireObjectLike(bag), extraFieldNames, dateFieldRefiners, []));
5855
5908
  }
5856
5909
 
5857
- function convertToPlainMonthDay(calendar, input) {
5858
- return createPlainMonthDayFromFields(calendar, readAndRefineBagFields(input, monthCodeDayFieldNamesAlpha, dateFieldRefiners));
5910
+ function fieldsToMonthDay(calendar, input) {
5911
+ const refinedFields = readAndRefineBagFields(input, monthCodeDayFieldNamesAlpha, dateFieldRefiners);
5912
+ const [year, monthCodeParts] = refineMonthDayFields(refinedFields, calendar);
5913
+ return createMonthDayFromRefinedFields(refinedFields, calendar, year, monthCodeParts, 0);
5859
5914
  }
5860
5915
 
5861
- function convertToPlainYearMonth(calendar, input, options) {
5862
- return createPlainYearMonthFromFields(calendar, readAndRefineBagFields(input, getCalendarFieldNames(calendar, yearMonthCodeFieldNamesAlpha, yearMonthCodeFieldNamesWithEraAlpha), dateFieldRefiners), options);
5916
+ function fieldsToYearMonth(calendar, input) {
5917
+ const refinedFields = readAndRefineBagFields(input, getCalendarFieldNames(calendar, yearMonthCodeFieldNamesAlpha, yearMonthCodeFieldNamesWithEraAlpha), dateFieldRefiners);
5918
+ const [year, monthCodeParts] = refineCalendarDateFields(refinedFields, calendar, 1);
5919
+ return createYearMonthFromRefinedFields(refinedFields, calendar, year, monthCodeParts, 0);
5863
5920
  }
5864
5921
 
5865
- function createPlainDateFromMergedFields(calendar, inputFields, extraFields) {
5922
+ function mergeFieldsIntoDate(calendar, inputFields, extraFields) {
5866
5923
  const mergedFieldNames = getCalendarFieldNames(calendar, yearMonthCodeDayFieldNamesAlpha, yearMonthCodeDayFieldNamesWithEraAlpha);
5867
5924
  let mergedFields = mergeCalendarFields(calendar, inputFields, extraFields);
5868
- return mergedFields = readAndRefineBagFields(mergedFields, mergedFieldNames, dateFieldRefiners, []),
5869
- createPlainDateFromFields(calendar, mergedFields);
5925
+ mergedFields = readAndRefineBagFields(mergedFields, mergedFieldNames, dateFieldRefiners, []);
5926
+ const [year, monthCodeParts] = refineCalendarDateFields(mergedFields, calendar);
5927
+ return createDateFromRefinedFields(mergedFields, calendar, year, monthCodeParts, 0);
5870
5928
  }
5871
5929
 
5872
5930
  function epochMilliToInstant(epochMilli) {
@@ -6049,24 +6107,24 @@ function createDateTimeFormatShell(createArgsProvider, transformOptions = identi
6049
6107
  const resolvedOptions = baseFormat.resolvedOptions();
6050
6108
  const copiedOptions = pluckProps(observedOptionNames, resolvedOptions);
6051
6109
  internalsMap.set(this, {
6052
- Z: createArgsProvider({
6110
+ $: createArgsProvider({
6053
6111
  t: baseFormat,
6054
- ze: resolvedOptions.locale,
6055
- F: copiedOptions,
6056
- Ce: transformedOptions
6112
+ Ce: resolvedOptions.locale,
6113
+ G: copiedOptions,
6114
+ Ee: transformedOptions
6057
6115
  }),
6058
6116
  t: baseFormat
6059
6117
  });
6060
6118
  }
6061
6119
  get format() {
6062
6120
  const internals = getInternals(this);
6063
- return internals.qe || (internals.qe = record => {
6064
- const [format, ...rest] = internals.Z.A(record);
6121
+ return internals.we || (internals.we = record => {
6122
+ const [format, ...rest] = internals.$.A(record);
6065
6123
  return format.format(...rest);
6066
6124
  });
6067
6125
  }
6068
6126
  formatToParts(record) {
6069
- const {Z: argsProvider} = getInternals(this);
6127
+ const {$: argsProvider} = getInternals(this);
6070
6128
  const [format, ...rest] = argsProvider.A(record);
6071
6129
  return format.formatToParts(...rest);
6072
6130
  }
@@ -6080,12 +6138,12 @@ function createDateTimeFormatShell(createArgsProvider, transformOptions = identi
6080
6138
  }
6081
6139
  RawDateTimeFormat.prototype.formatRange && Object.defineProperties(prototype, createPropDescriptors({
6082
6140
  formatRange(record0, record1) {
6083
- const {Z: argsProvider} = getInternals(this);
6141
+ const {$: argsProvider} = getInternals(this);
6084
6142
  const [format, epochMilli0, epochMilli1] = argsProvider.v(record0, record1);
6085
6143
  return format.formatRange(epochMilli0, epochMilli1);
6086
6144
  },
6087
6145
  formatRangeToParts(record0, record1) {
6088
- const {Z: argsProvider} = getInternals(this);
6146
+ const {$: argsProvider} = getInternals(this);
6089
6147
  const [format, epochMilli0, epochMilli1] = argsProvider.v(record0, record1);
6090
6148
  return format.formatRangeToParts(epochMilli0, epochMilli1);
6091
6149
  }
@@ -6231,11 +6289,89 @@ const dateDerivedGetters = {
6231
6289
  }
6232
6290
  };
6233
6291
 
6234
- function createNativeGetters(shimGetters) {
6235
- return createPropGetters(Object.keys(shimGetters));
6292
+ function diffInstants(invert, instantSlots0, instantSlots1, options) {
6293
+ const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 3, 5);
6294
+ return createDiffDurationSlots(invert, diffEpochNanosRounded(instantSlots0.epochNanoseconds, instantSlots1.epochNanoseconds, largestUnit, smallestUnit, roundingInc, roundingMode));
6295
+ }
6296
+
6297
+ function diffZonedDateTimes(invert, slots0, slots1, options) {
6298
+ const calendar = getCommonCalendar(slots0.calendar, slots1.calendar);
6299
+ const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 5);
6300
+ return createDiffDurationSlots(invert, diffZonedDateTimesRounded(calendar, slots0, slots1, largestUnit, smallestUnit, roundingInc, roundingMode));
6301
+ }
6302
+
6303
+ function diffDateTimes(invert, plainDateTimeSlots0, plainDateTimeSlots1, options) {
6304
+ const calendar = getCommonCalendar(plainDateTimeSlots0.calendar, plainDateTimeSlots1.calendar);
6305
+ const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 6);
6306
+ return createDiffDurationSlots(invert, diffDateTimesRounded(calendar, plainDateTimeSlots0, plainDateTimeSlots1, largestUnit, smallestUnit, roundingInc, roundingMode));
6307
+ }
6308
+
6309
+ function diffDates(invert, plainDateSlots0, plainDateSlots1, options) {
6310
+ const calendar = getCommonCalendar(plainDateSlots0.calendar, plainDateSlots1.calendar);
6311
+ const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 6, 9, 6);
6312
+ return createDiffDurationSlots(invert, diffDatesRounded(calendar, plainDateSlots0, plainDateSlots1, largestUnit, smallestUnit, roundingInc, roundingMode));
6313
+ }
6314
+
6315
+ function diffYearMonths(invert, plainYearMonthSlots0, plainYearMonthSlots1, options) {
6316
+ const calendar = getCommonCalendar(plainYearMonthSlots0.calendar, plainYearMonthSlots1.calendar);
6317
+ const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 9, 9, 8);
6318
+ return createDiffDurationSlots(invert, diffYearMonthsRounded(calendar, plainYearMonthSlots0, plainYearMonthSlots1, largestUnit, smallestUnit, roundingInc, roundingMode));
6319
+ }
6320
+
6321
+ function diffTimes(invert, plainTimeSlots0, plainTimeSlots1, options) {
6322
+ const [largestUnit, smallestUnit, roundingInc, roundingMode] = refineDiffOptions(invert, options, 5, 5);
6323
+ return createDiffDurationSlots(invert, diffTimesRounded(plainTimeSlots0, plainTimeSlots1, largestUnit, smallestUnit, roundingInc, roundingMode));
6324
+ }
6325
+
6326
+ function createDiffDurationSlots(invert, durationFields) {
6327
+ return createDurationSlots(invert ? negateDurationFields(durationFields) : durationFields);
6328
+ }
6329
+
6330
+ function withDateFields(slots, modFields, options) {
6331
+ const {calendar: calendar} = slots;
6332
+ const fields = mergeDateFields(calendar, slots, modFields);
6333
+ const [year, monthCodeParts] = refineCalendarDateFields(fields, calendar);
6334
+ const overflow = refineOverflowOptions(options);
6335
+ return createDateFromRefinedFields(fields, calendar, year, monthCodeParts, overflow);
6336
+ }
6337
+
6338
+ function withDateTimeFields(slots, modFields, options) {
6339
+ const {calendar: calendar} = slots;
6340
+ const [mergedFields, calendarFields] = mergeDateTimeFields(calendar, slots, modFields);
6341
+ const [year, monthCodeParts] = refineCalendarDateFields(calendarFields, calendar);
6342
+ const overflow = refineOverflowOptions(options);
6343
+ return createDateTimeFromMergedFields(mergedFields, calendarFields, calendar, year, monthCodeParts, overflow);
6344
+ }
6345
+
6346
+ function withYearMonthFields(slots, modFields, options) {
6347
+ const {calendar: calendar} = slots;
6348
+ const fields = mergeYearMonthFields(calendar, slots, modFields);
6349
+ const [year, monthCodeParts] = refineCalendarDateFields(fields, calendar, 1);
6350
+ const overflow = refineOverflowOptions(options);
6351
+ return createYearMonthFromRefinedFields(fields, calendar, year, monthCodeParts, overflow);
6352
+ }
6353
+
6354
+ function withMonthDayFields(slots, modFields, options) {
6355
+ const {calendar: calendar} = slots;
6356
+ const fields = mergeMonthDayFields(calendar, slots, modFields);
6357
+ const [year, monthCodeParts] = refineMonthDayFields(fields, calendar);
6358
+ const overflow = refineOverflowOptions(options);
6359
+ return createMonthDayFromRefinedFields(fields, calendar, year, monthCodeParts, overflow);
6360
+ }
6361
+
6362
+ function withTimeFields(slots, modFields, options) {
6363
+ const refinedFields = mergeTimeFields(slots, modFields);
6364
+ const overflow = refineOverflowOptions(options);
6365
+ return resolveTimeFields(refinedFields, overflow);
6236
6366
  }
6237
6367
 
6238
- createNativeGetters(yearMonthDerivedGetters), createNativeGetters(dateDerivedGetters);
6368
+ function withZonedDateTimeFields(slots, modFields, options) {
6369
+ const {calendar: calendar} = slots;
6370
+ const [mergedFields, calendarFields] = mergeZonedDateTimeFields(calendar, slots, modFields);
6371
+ const [year, monthCodeParts] = refineCalendarDateFields(calendarFields, calendar);
6372
+ const [overflow, offsetDisambig, epochDisambig] = refineZonedFieldOptions(options, 2);
6373
+ return createZonedDateTimeFromMergedFields(slots, mergedFields, calendarFields, year, monthCodeParts, overflow, offsetDisambig, epochDisambig);
6374
+ }
6239
6375
 
6240
6376
  function createDateTimeFormatClass(getTemporalBrandingAndSlots) {
6241
6377
  return createDateTimeFormatShell(internals => {
@@ -6243,33 +6379,33 @@ function createDateTimeFormatClass(getTemporalBrandingAndSlots) {
6243
6379
  let options;
6244
6380
  switch (branding) {
6245
6381
  case InstantBranding:
6246
- options = transformInstantOptions(internals.F, 1);
6382
+ options = transformInstantOptions(internals.G, 1);
6247
6383
  break;
6248
6384
 
6249
6385
  case PlainDateTimeBranding:
6250
- options = applyPlainFormatTimeZone(transformDateTimeOptions(internals.F, 1));
6386
+ options = applyPlainFormatTimeZone(transformDateTimeOptions(internals.G, 1));
6251
6387
  break;
6252
6388
 
6253
6389
  case PlainDateBranding:
6254
- options = applyPlainFormatTimeZone(transformDateOptions(internals.F, 1));
6390
+ options = applyPlainFormatTimeZone(transformDateOptions(internals.G, 1));
6255
6391
  break;
6256
6392
 
6257
6393
  case PlainTimeBranding:
6258
- options = applyPlainFormatTimeZone(transformTimeOptions(internals.F, 1));
6394
+ options = applyPlainFormatTimeZone(transformTimeOptions(internals.G, 1));
6259
6395
  break;
6260
6396
 
6261
6397
  case PlainYearMonthBranding:
6262
- options = applyPlainFormatTimeZone(transformYearMonthOptions(internals.F, 1));
6398
+ options = applyPlainFormatTimeZone(transformYearMonthOptions(internals.G, 1));
6263
6399
  break;
6264
6400
 
6265
6401
  case PlainMonthDayBranding:
6266
- options = applyPlainFormatTimeZone(transformMonthDayOptions(internals.F, 1));
6402
+ options = applyPlainFormatTimeZone(transformMonthDayOptions(internals.G, 1));
6267
6403
  break;
6268
6404
 
6269
6405
  default:
6270
6406
  throwTypeError(invalidFormatType(branding));
6271
6407
  }
6272
- return new RawDateTimeFormat(internals.ze, options);
6408
+ return new RawDateTimeFormat(internals.Ce, options);
6273
6409
  });
6274
6410
  return {
6275
6411
  A(formattable) {
@@ -6327,7 +6463,7 @@ function checkTemporalDateTimeFormatCompatible(format, branding, slots) {
6327
6463
  function temporalDateTimeToEpochMilli(branding, slots) {
6328
6464
  switch (branding) {
6329
6465
  case InstantBranding:
6330
- return getEpochMilli(slots);
6466
+ return epochNanoToMilli(slots.epochNanoseconds);
6331
6467
 
6332
6468
  case PlainDateTimeBranding:
6333
6469
  return isoDateTimeToEpochMilli(slots);
@@ -6376,10 +6512,10 @@ const ZonedDateTime = /*@__PURE__*/ defineTemporalClass(ZonedDateTimeBranding, c
6376
6512
  return getZonedDateTimeSlots(this).timeZone.id;
6377
6513
  }
6378
6514
  get epochMilliseconds() {
6379
- return getEpochMilli(getZonedDateTimeSlots(this));
6515
+ return epochNanoToMilli(getZonedDateTimeSlots(this).epochNanoseconds);
6380
6516
  }
6381
6517
  get epochNanoseconds() {
6382
- return getEpochNano(getZonedDateTimeSlots(this));
6518
+ return getZonedDateTimeSlots(this).epochNanoseconds;
6383
6519
  }
6384
6520
  get offset() {
6385
6521
  return formatOffsetNano(zonedEpochSlotsToIso(getZonedDateTimeSlots(this)).offsetNanoseconds);
@@ -6391,7 +6527,7 @@ const ZonedDateTime = /*@__PURE__*/ defineTemporalClass(ZonedDateTimeBranding, c
6391
6527
  return computeZonedHoursInDay(getZonedDateTimeSlots(this));
6392
6528
  }
6393
6529
  with(mod, options = void 0) {
6394
- return createZonedDateTime(mergeZonedDateTimeFields(getZonedDateTimeSlots(this), validateBag(mod), options));
6530
+ return createZonedDateTime(withZonedDateTimeFields(getZonedDateTimeSlots(this), validateBag(mod), options));
6395
6531
  }
6396
6532
  withCalendar(calendarArg) {
6397
6533
  return createZonedDateTime({
@@ -6410,23 +6546,21 @@ const ZonedDateTime = /*@__PURE__*/ defineTemporalClass(ZonedDateTimeBranding, c
6410
6546
  }
6411
6547
  add(durationArg, options = void 0) {
6412
6548
  const slots = getZonedDateTimeSlots(this);
6413
- return createZonedDateTime(moveZonedEpochSlots(slots, toDurationSlots(durationArg), options));
6549
+ return createZonedDateTime(moveZonedEpochSlots(slots, toDurationSlots(durationArg), refineOverflowOptions(options)));
6414
6550
  }
6415
6551
  subtract(durationArg, options = void 0) {
6416
6552
  const slots = getZonedDateTimeSlots(this);
6417
- return createZonedDateTime(moveZonedEpochSlots(slots, negateDurationFields(toDurationSlots(durationArg)), options));
6553
+ return createZonedDateTime(moveZonedEpochSlots(slots, negateDurationFields(toDurationSlots(durationArg)), refineOverflowOptions(options)));
6418
6554
  }
6419
6555
  until(otherArg, options = void 0) {
6420
6556
  const slots = getZonedDateTimeSlots(this);
6421
6557
  const other = toZonedDateTimeSlots(otherArg);
6422
- const calendar = getCommonCalendar(slots.calendar, other.calendar);
6423
- return createDuration(createDurationSlots(diffZonedDateTimes(0, calendar, slots, other, options)));
6558
+ return createDuration(diffZonedDateTimes(0, slots, other, options));
6424
6559
  }
6425
6560
  since(otherArg, options = void 0) {
6426
6561
  const slots = getZonedDateTimeSlots(this);
6427
6562
  const other = toZonedDateTimeSlots(otherArg);
6428
- const calendar = getCommonCalendar(slots.calendar, other.calendar);
6429
- return createDuration(createDurationSlots(diffZonedDateTimes(1, calendar, slots, other, options)));
6563
+ return createDuration(diffZonedDateTimes(1, slots, other, options));
6430
6564
  }
6431
6565
  round(options) {
6432
6566
  const slots = getZonedDateTimeSlots(this);
@@ -6443,18 +6577,18 @@ const ZonedDateTime = /*@__PURE__*/ defineTemporalClass(ZonedDateTimeBranding, c
6443
6577
  return createInstant(zonedDateTimeToInstant(getZonedDateTimeSlots(this)));
6444
6578
  }
6445
6579
  toPlainDateTime() {
6446
- return createPlainDateTime(zonedDateTimeToPlainDateTime(getZonedDateTimeSlots(this)));
6580
+ return createPlainDateTime(zonedDateTimeToDateTime(getZonedDateTimeSlots(this)));
6447
6581
  }
6448
6582
  toPlainDate() {
6449
- return createPlainDate(zonedDateTimeToPlainDate(getZonedDateTimeSlots(this)));
6583
+ return createPlainDate(zonedDateTimeToDate(getZonedDateTimeSlots(this)));
6450
6584
  }
6451
6585
  toPlainTime() {
6452
- return createPlainTime(zonedDateTimeToPlainTime(getZonedDateTimeSlots(this)));
6586
+ return createPlainTime(zonedDateTimeToTime(getZonedDateTimeSlots(this)));
6453
6587
  }
6454
6588
  toLocaleString(locales = void 0, options = {}) {
6455
6589
  const slots = getZonedDateTimeSlots(this);
6456
6590
  const format = new RawDateTimeFormat(locales, applyZonedFormatTimeZone(transformZonedOptions(options), getZonedTimeZoneId(slots)));
6457
- return checkResolvedCalendarCompatible(format, slots), format.format(getEpochMilli(slots));
6591
+ return checkResolvedCalendarCompatible(format, slots), format.format(epochNanoToMilli(slots.epochNanoseconds));
6458
6592
  }
6459
6593
  toString(options = void 0) {
6460
6594
  return formatZonedDateTimeIso(getZonedDateTimeSlots(this), options);
@@ -6464,8 +6598,8 @@ const ZonedDateTime = /*@__PURE__*/ defineTemporalClass(ZonedDateTimeBranding, c
6464
6598
  }
6465
6599
  getTimeZoneTransition(options) {
6466
6600
  const slots = getZonedDateTimeSlots(this);
6467
- const newEpochNano = getTimeZoneTransitionEpochNanoseconds(slots, options);
6468
- return newEpochNano ? createZonedDateTime({
6601
+ const newEpochNano = slots.timeZone.C(slots.epochNanoseconds, refineDirectionOptions(options));
6602
+ return void 0 !== newEpochNano ? createZonedDateTime({
6469
6603
  ...slots,
6470
6604
  epochNanoseconds: newEpochNano
6471
6605
  }) : null;
@@ -6540,10 +6674,10 @@ const Instant = /*@__PURE__*/ defineTemporalClass(InstantBranding, class {
6540
6674
  return compareZonedEpochSlots(toInstantSlots(a), toInstantSlots(b));
6541
6675
  }
6542
6676
  get epochMilliseconds() {
6543
- return getEpochMilli(getInstantSlots(this));
6677
+ return epochNanoToMilli(getInstantSlots(this).epochNanoseconds);
6544
6678
  }
6545
6679
  get epochNanoseconds() {
6546
- return getEpochNano(getInstantSlots(this));
6680
+ return getInstantSlots(this).epochNanoseconds;
6547
6681
  }
6548
6682
  add(durationArg) {
6549
6683
  const slots = getInstantSlots(this);
@@ -6572,7 +6706,7 @@ const Instant = /*@__PURE__*/ defineTemporalClass(InstantBranding, class {
6572
6706
  }
6573
6707
  toLocaleString(locales = void 0, options = {}) {
6574
6708
  const slots = getInstantSlots(this);
6575
- return new RawDateTimeFormat(locales, transformInstantOptions(options)).format(getEpochMilli(slots));
6709
+ return new RawDateTimeFormat(locales, transformInstantOptions(options)).format(epochNanoToMilli(slots.epochNanoseconds));
6576
6710
  }
6577
6711
  toString(options = void 0) {
6578
6712
  return formatInstantIso(refineTimeZoneArg, getInstantSlots(this), options);
@@ -6644,14 +6778,14 @@ const PlainMonthDay = /*@__PURE__*/ defineTemporalClass(PlainMonthDayBranding, c
6644
6778
  return getCalendarSlotId(getPlainMonthDaySlots(this).calendar);
6645
6779
  }
6646
6780
  with(mod, options = void 0) {
6647
- return createPlainMonthDay(mergePlainMonthDayFields(getPlainMonthDaySlots(this), validateBag(mod), options));
6781
+ return createPlainMonthDay(withMonthDayFields(getPlainMonthDaySlots(this), validateBag(mod), options));
6648
6782
  }
6649
6783
  equals(otherArg) {
6650
6784
  return plainMonthDaysEqual(getPlainMonthDaySlots(this), toPlainMonthDaySlots(otherArg));
6651
6785
  }
6652
6786
  toPlainDate(bag) {
6653
6787
  const slots = getPlainMonthDaySlots(this);
6654
- return createPlainDate(convertPlainMonthDayToDate(slots.calendar, this, bag));
6788
+ return createPlainDate(monthDayToDate(slots.calendar, this, bag));
6655
6789
  }
6656
6790
  toLocaleString(locales = void 0, options = {}) {
6657
6791
  const slots = getPlainMonthDaySlots(this);
@@ -6724,34 +6858,32 @@ const PlainYearMonth = /*@__PURE__*/ defineTemporalClass(PlainYearMonthBranding,
6724
6858
  return getCalendarSlotId(getPlainYearMonthSlots(this).calendar);
6725
6859
  }
6726
6860
  with(mod, options = void 0) {
6727
- return createPlainYearMonth(mergePlainYearMonthFields(getPlainYearMonthSlots(this), validateBag(mod), options));
6861
+ return createPlainYearMonth(withYearMonthFields(getPlainYearMonthSlots(this), validateBag(mod), options));
6728
6862
  }
6729
6863
  add(durationArg, options = void 0) {
6730
6864
  const slots = getPlainYearMonthSlots(this);
6731
- return createPlainYearMonth(createDateSlots(moveYearMonth(0, slots.calendar, slots, toDurationSlots(durationArg), options), slots.calendar));
6865
+ return createPlainYearMonth(createDateSlots(moveYearMonth(slots.calendar, slots, toDurationSlots(durationArg), refineOverflowOptions(options)), slots.calendar));
6732
6866
  }
6733
6867
  subtract(durationArg, options = void 0) {
6734
6868
  const slots = getPlainYearMonthSlots(this);
6735
- return createPlainYearMonth(createDateSlots(moveYearMonth(1, slots.calendar, slots, toDurationSlots(durationArg), options), slots.calendar));
6869
+ return createPlainYearMonth(createDateSlots(moveYearMonth(slots.calendar, slots, negateDurationFields(toDurationSlots(durationArg)), refineOverflowOptions(options)), slots.calendar));
6736
6870
  }
6737
6871
  until(otherArg, options = void 0) {
6738
6872
  const slots = getPlainYearMonthSlots(this);
6739
6873
  const other = toPlainYearMonthSlots(otherArg);
6740
- const calendar = getCommonCalendar(slots.calendar, other.calendar);
6741
- return createDuration(diffPlainYearMonth(0, calendar, slots, other, options));
6874
+ return createDuration(diffYearMonths(0, slots, other, options));
6742
6875
  }
6743
6876
  since(otherArg, options = void 0) {
6744
6877
  const slots = getPlainYearMonthSlots(this);
6745
6878
  const other = toPlainYearMonthSlots(otherArg);
6746
- const calendar = getCommonCalendar(slots.calendar, other.calendar);
6747
- return createDuration(diffPlainYearMonth(1, calendar, slots, other, options));
6879
+ return createDuration(diffYearMonths(1, slots, other, options));
6748
6880
  }
6749
6881
  equals(otherArg) {
6750
6882
  return plainYearMonthsEqual(getPlainYearMonthSlots(this), toPlainYearMonthSlots(otherArg));
6751
6883
  }
6752
6884
  toPlainDate(bag) {
6753
6885
  const slots = getPlainYearMonthSlots(this);
6754
- return createPlainDate(convertPlainYearMonthToDate(slots.calendar, this, bag));
6886
+ return createPlainDate(yearMonthToDate(slots.calendar, this, bag));
6755
6887
  }
6756
6888
  toLocaleString(locales = void 0, options = {}) {
6757
6889
  const slots = getPlainYearMonthSlots(this);
@@ -6840,7 +6972,7 @@ const PlainTime = /*@__PURE__*/ defineTemporalClass(PlainTimeBranding, class {
6840
6972
  return compareTimeFields(toPlainTimeSlots(arg0), toPlainTimeSlots(arg1));
6841
6973
  }
6842
6974
  with(mod, options = void 0) {
6843
- return createPlainTime(mergePlainTimeFields(getPlainTimeSlots(this), validateBag(mod), options));
6975
+ return createPlainTime(withTimeFields(getPlainTimeSlots(this), validateBag(mod), options));
6844
6976
  }
6845
6977
  add(durationArg) {
6846
6978
  const slots = getPlainTimeSlots(this);
@@ -6851,15 +6983,15 @@ const PlainTime = /*@__PURE__*/ defineTemporalClass(PlainTimeBranding, class {
6851
6983
  return createPlainTime(moveTime(slots, negateDurationFields(toDurationSlots(durationArg)))[0]);
6852
6984
  }
6853
6985
  until(otherArg, options = void 0) {
6854
- return createDuration(diffPlainTimes(0, getPlainTimeSlots(this), toPlainTimeSlots(otherArg), options));
6986
+ return createDuration(diffTimes(0, getPlainTimeSlots(this), toPlainTimeSlots(otherArg), options));
6855
6987
  }
6856
6988
  since(otherArg, options = void 0) {
6857
- return createDuration(diffPlainTimes(1, getPlainTimeSlots(this), toPlainTimeSlots(otherArg), options));
6989
+ return createDuration(diffTimes(1, getPlainTimeSlots(this), toPlainTimeSlots(otherArg), options));
6858
6990
  }
6859
6991
  round(options) {
6860
6992
  const slots = getPlainTimeSlots(this);
6861
6993
  const [smallestUnit, roundingInc, roundingMode] = refineRoundingOptions(options, 5);
6862
- return createPlainTime(roundTimeToNano(slots, computeNanoInc(smallestUnit, roundingInc), roundingMode)[0]);
6994
+ return createPlainTime(roundTimeToInc(slots, computeNanoInc(smallestUnit, roundingInc), roundingMode)[0]);
6863
6995
  }
6864
6996
  equals(other) {
6865
6997
  return plainTimesEqual(getPlainTimeSlots(this), toPlainTimeSlots(other));
@@ -6902,7 +7034,7 @@ function toPlainTimeSlots(arg, options) {
6902
7034
  return refineOverflowOptions(options), createTimeSlots(dateTimeSlots);
6903
7035
  }
6904
7036
  const zonedDateTimeSlots = getZonedDateTimeSlotsIfPresent(arg);
6905
- return zonedDateTimeSlots ? (refineOverflowOptions(options), zonedDateTimeToPlainTime(zonedDateTimeSlots)) : refinePlainTimeObjectLike(arg, options);
7037
+ return zonedDateTimeSlots ? (refineOverflowOptions(options), zonedDateTimeToTime(zonedDateTimeSlots)) : refinePlainTimeObjectLike(arg, options);
6906
7038
  }
6907
7039
  const timeSlots = parsePlainTime(arg);
6908
7040
  return refineOverflowOptions(options), timeSlots;
@@ -6946,7 +7078,7 @@ const PlainDateTime = /*@__PURE__*/ defineTemporalClass(PlainDateTimeBranding, c
6946
7078
  return getCalendarSlotId(getPlainDateTimeSlots(this).calendar);
6947
7079
  }
6948
7080
  with(mod, options = void 0) {
6949
- return createPlainDateTime(mergePlainDateTimeFields(getPlainDateTimeSlots(this), validateBag(mod), options));
7081
+ return createPlainDateTime(withDateTimeFields(getPlainDateTimeSlots(this), validateBag(mod), options));
6950
7082
  }
6951
7083
  withCalendar(calendarArg) {
6952
7084
  const slots = getPlainDateTimeSlots(this);
@@ -6954,38 +7086,36 @@ const PlainDateTime = /*@__PURE__*/ defineTemporalClass(PlainDateTimeBranding, c
6954
7086
  }
6955
7087
  withPlainTime(plainTimeArg = void 0) {
6956
7088
  const slots = getPlainDateTimeSlots(this);
6957
- return createPlainDateTime(createPlainDateTimeFromRefinedFields(slots, optionalToPlainTimeFields(plainTimeArg), slots.calendar));
7089
+ return createPlainDateTime(createDateTimeFromRefinedFields(slots, optionalToPlainTimeFields(plainTimeArg), slots.calendar));
6958
7090
  }
6959
7091
  add(durationArg, options = void 0) {
6960
7092
  const slots = getPlainDateTimeSlots(this);
6961
- return createPlainDateTime(createDateTimeSlots(moveDateTime(slots.calendar, slots, toDurationSlots(durationArg), options), slots.calendar));
7093
+ return createPlainDateTime(createDateTimeSlots(moveDateTime(slots.calendar, slots, toDurationSlots(durationArg), refineOverflowOptions(options)), slots.calendar));
6962
7094
  }
6963
7095
  subtract(durationArg, options = void 0) {
6964
7096
  const slots = getPlainDateTimeSlots(this);
6965
- return createPlainDateTime(createDateTimeSlots(moveDateTime(slots.calendar, slots, negateDurationFields(toDurationSlots(durationArg)), options), slots.calendar));
7097
+ return createPlainDateTime(createDateTimeSlots(moveDateTime(slots.calendar, slots, negateDurationFields(toDurationSlots(durationArg)), refineOverflowOptions(options)), slots.calendar));
6966
7098
  }
6967
7099
  until(otherArg, options = void 0) {
6968
7100
  const slots = getPlainDateTimeSlots(this);
6969
7101
  const other = toPlainDateTimeSlots(otherArg);
6970
- const calendar = getCommonCalendar(slots.calendar, other.calendar);
6971
- return createDuration(diffPlainDateTimes(0, calendar, slots, other, options));
7102
+ return createDuration(diffDateTimes(0, slots, other, options));
6972
7103
  }
6973
7104
  since(otherArg, options = void 0) {
6974
7105
  const slots = getPlainDateTimeSlots(this);
6975
7106
  const other = toPlainDateTimeSlots(otherArg);
6976
- const calendar = getCommonCalendar(slots.calendar, other.calendar);
6977
- return createDuration(diffPlainDateTimes(1, calendar, slots, other, options));
7107
+ return createDuration(diffDateTimes(1, slots, other, options));
6978
7108
  }
6979
7109
  round(options) {
6980
7110
  const slots = getPlainDateTimeSlots(this);
6981
7111
  const [smallestUnit, roundingInc, roundingMode] = refineRoundingOptions(options);
6982
- return createPlainDateTime(createDateTimeSlots(roundDateTimeToNano(slots, computeNanoInc(smallestUnit, roundingInc), roundingMode), slots.calendar));
7112
+ return createPlainDateTime(createDateTimeSlots(roundDateTimeToInc(slots, computeNanoInc(smallestUnit, roundingInc), roundingMode), slots.calendar));
6983
7113
  }
6984
7114
  equals(otherArg) {
6985
7115
  return plainDateTimesEqual(getPlainDateTimeSlots(this), toPlainDateTimeSlots(otherArg));
6986
7116
  }
6987
7117
  toZonedDateTime(timeZoneArg, options = void 0) {
6988
- return createZonedDateTime(plainDateTimeToZonedDateTime(getPlainDateTimeSlots(this), queryTimeZone(refineTimeZoneArg(timeZoneArg)), options));
7118
+ return createZonedDateTime(dateTimeToZonedDateTime(getPlainDateTimeSlots(this), queryTimeZone(refineTimeZoneArg(timeZoneArg)), refineEpochDisambigOptions(options)));
6989
7119
  }
6990
7120
  toPlainDate() {
6991
7121
  const slots = getPlainDateTimeSlots(this);
@@ -7034,7 +7164,7 @@ function toPlainDateTimeSlots(arg, options) {
7034
7164
  }
7035
7165
  const zonedDateTimeSlots = getZonedDateTimeSlotsIfPresent(arg);
7036
7166
  if (zonedDateTimeSlots) {
7037
- return refineOverflowOptions(options), zonedDateTimeToPlainDateTime(zonedDateTimeSlots);
7167
+ return refineOverflowOptions(options), zonedDateTimeToDateTime(zonedDateTimeSlots);
7038
7168
  }
7039
7169
  const calendar = getCalendarFromBag(arg);
7040
7170
  return refinePlainDateTimeObjectLike(calendar, arg, options);
@@ -7070,8 +7200,7 @@ const PlainDate = /*@__PURE__*/ defineTemporalClass(PlainDateBranding, class {
7070
7200
  return getCalendarSlotId(getPlainDateSlots(this).calendar);
7071
7201
  }
7072
7202
  with(mod, options = void 0) {
7073
- const slots = getPlainDateSlots(this);
7074
- return createPlainDate(mergePlainDateFields(slots, validateBag(mod), options));
7203
+ return createPlainDate(withDateFields(getPlainDateSlots(this), validateBag(mod), options));
7075
7204
  }
7076
7205
  withCalendar(calendarArg) {
7077
7206
  const slots = getPlainDateSlots(this);
@@ -7079,23 +7208,21 @@ const PlainDate = /*@__PURE__*/ defineTemporalClass(PlainDateBranding, class {
7079
7208
  }
7080
7209
  add(durationArg, options = void 0) {
7081
7210
  const slots = getPlainDateSlots(this);
7082
- return createPlainDate(createDateSlots(moveDate(slots.calendar, slots, toDurationSlots(durationArg), options), slots.calendar));
7211
+ return createPlainDate(createDateSlots(moveDate(slots.calendar, slots, toDurationSlots(durationArg), refineOverflowOptions(options)), slots.calendar));
7083
7212
  }
7084
7213
  subtract(durationArg, options = void 0) {
7085
7214
  const slots = getPlainDateSlots(this);
7086
- return createPlainDate(createDateSlots(moveDate(slots.calendar, slots, negateDurationFields(toDurationSlots(durationArg)), options), slots.calendar));
7215
+ return createPlainDate(createDateSlots(moveDate(slots.calendar, slots, negateDurationFields(toDurationSlots(durationArg)), refineOverflowOptions(options)), slots.calendar));
7087
7216
  }
7088
7217
  until(otherArg, options = void 0) {
7089
7218
  const slots = getPlainDateSlots(this);
7090
7219
  const other = toPlainDateSlots(otherArg);
7091
- const calendar = getCommonCalendar(slots.calendar, other.calendar);
7092
- return createDuration(diffPlainDates(0, calendar, slots, other, options));
7220
+ return createDuration(diffDates(0, slots, other, options));
7093
7221
  }
7094
7222
  since(otherArg, options = void 0) {
7095
7223
  const slots = getPlainDateSlots(this);
7096
7224
  const other = toPlainDateSlots(otherArg);
7097
- const calendar = getCommonCalendar(slots.calendar, other.calendar);
7098
- return createDuration(diffPlainDates(1, calendar, slots, other, options));
7225
+ return createDuration(diffDates(1, slots, other, options));
7099
7226
  }
7100
7227
  equals(otherArg) {
7101
7228
  return plainDatesEqual(getPlainDateSlots(this), toPlainDateSlots(otherArg));
@@ -7107,19 +7234,23 @@ const PlainDate = /*@__PURE__*/ defineTemporalClass(PlainDateBranding, class {
7107
7234
  } : {
7108
7235
  timeZone: options
7109
7236
  };
7110
- return createZonedDateTime(plainDateToZonedDateTime(refineTimeZoneArg, toPlainTimeSlots, getPlainDateSlots(this), optionsObj));
7237
+ const slots = getPlainDateSlots(this);
7238
+ const timeZoneId = refineTimeZoneArg(optionsObj.timeZone);
7239
+ const plainTimeArg = optionsObj.plainTime;
7240
+ const timeFields = void 0 !== plainTimeArg ? toPlainTimeSlots(plainTimeArg) : void 0;
7241
+ return createZonedDateTime(dateToZonedDateTime(slots, queryTimeZone(timeZoneId), timeFields));
7111
7242
  }
7112
7243
  toPlainDateTime(plainTimeArg = void 0) {
7113
7244
  const slots = getPlainDateSlots(this);
7114
- return createPlainDateTime(createPlainDateTimeFromRefinedFields(slots, optionalToPlainTimeFields(plainTimeArg), slots.calendar));
7245
+ return createPlainDateTime(createDateTimeFromRefinedFields(slots, optionalToPlainTimeFields(plainTimeArg), slots.calendar));
7115
7246
  }
7116
7247
  toPlainYearMonth() {
7117
7248
  const slots = getPlainDateSlots(this);
7118
- return createPlainYearMonth(convertToPlainYearMonth(slots.calendar, this));
7249
+ return createPlainYearMonth(fieldsToYearMonth(slots.calendar, this));
7119
7250
  }
7120
7251
  toPlainMonthDay() {
7121
7252
  const slots = getPlainDateSlots(this);
7122
- return createPlainMonthDay(convertToPlainMonthDay(slots.calendar, this));
7253
+ return createPlainMonthDay(fieldsToMonthDay(slots.calendar, this));
7123
7254
  }
7124
7255
  toLocaleString(locales = void 0, options = {}) {
7125
7256
  const slots = getPlainDateSlots(this);
@@ -7161,7 +7292,7 @@ function toPlainDateSlots(arg, options) {
7161
7292
  }
7162
7293
  const zonedDateTimeSlots = getZonedDateTimeSlotsIfPresent(arg);
7163
7294
  if (zonedDateTimeSlots) {
7164
- return refineOverflowOptions(options), zonedDateTimeToPlainDate(zonedDateTimeSlots);
7295
+ return refineOverflowOptions(options), zonedDateTimeToDate(zonedDateTimeSlots);
7165
7296
  }
7166
7297
  const calendar = getCalendarFromBag(arg);
7167
7298
  return refinePlainDateObjectLike(calendar, arg, options);
@@ -7233,11 +7364,11 @@ const Duration = /*@__PURE__*/ defineTemporalClass(DurationBranding, class {
7233
7364
  abs() {
7234
7365
  return createDuration(absDuration(getDurationSlots(this)));
7235
7366
  }
7236
- add(otherArg, options = void 0) {
7237
- return createDuration(addDurations(refinePublicRelativeTo, 0, getDurationSlots(this), toDurationSlots(otherArg), options));
7367
+ add(otherArg) {
7368
+ return createDuration(addDurationsWithoutRelativeTo(0, getDurationSlots(this), toDurationSlots(otherArg)));
7238
7369
  }
7239
- subtract(otherArg, options = void 0) {
7240
- return createDuration(addDurations(refinePublicRelativeTo, 1, getDurationSlots(this), toDurationSlots(otherArg), options));
7370
+ subtract(otherArg) {
7371
+ return createDuration(addDurationsWithoutRelativeTo(1, getDurationSlots(this), toDurationSlots(otherArg)));
7241
7372
  }
7242
7373
  round(roundTo) {
7243
7374
  return createDuration(roundDuration(refinePublicRelativeTo, getDurationSlots(this), roundTo));
@@ -11520,14 +11651,14 @@ const Kislev = months.KISLEV;
11520
11651
  const Shvat = months.SHVAT;
11521
11652
  const Adar2 = months.ADAR_II;
11522
11653
  const CHAG$1 = flags.CHAG;
11523
- const LIGHT_CANDLES$3 = flags.LIGHT_CANDLES;
11654
+ const LIGHT_CANDLES$2 = flags.LIGHT_CANDLES;
11524
11655
  const YOM_TOV_ENDS$1 = flags.YOM_TOV_ENDS;
11525
11656
  const CHUL_ONLY$1 = flags.CHUL_ONLY;
11526
11657
  const IL_ONLY$2 = flags.IL_ONLY;
11527
11658
  const LIGHT_CANDLES_TZEIS$3 = flags.LIGHT_CANDLES_TZEIS;
11528
11659
  const MAJOR_FAST$2 = flags.MAJOR_FAST;
11529
11660
  const MINOR_HOLIDAY$2 = flags.MINOR_HOLIDAY;
11530
- const EREV$3 = flags.EREV;
11661
+ const EREV$2 = flags.EREV;
11531
11662
  const CHOL_HAMOED$1 = flags.CHOL_HAMOED;
11532
11663
  const emojiPesach = '🫓';
11533
11664
  const emojiSukkot = '🌿🍋';
@@ -11763,7 +11894,7 @@ const staticHolidays = [
11763
11894
  flags: CHAG$1 | YOM_TOV_ENDS$1,
11764
11895
  emoji: '🍏🍯',
11765
11896
  },
11766
- { mm: Tishrei, dd: 9, desc: EREV_YOM_KIPPUR, flags: EREV$3 | LIGHT_CANDLES$3 },
11897
+ { mm: Tishrei, dd: 9, desc: EREV_YOM_KIPPUR, flags: EREV$2 | LIGHT_CANDLES$2 },
11767
11898
  {
11768
11899
  mm: Tishrei,
11769
11900
  dd: 10,
@@ -11774,7 +11905,7 @@ const staticHolidays = [
11774
11905
  mm: Tishrei,
11775
11906
  dd: 14,
11776
11907
  desc: EREV_SUKKOT,
11777
- flags: CHUL_ONLY$1 | EREV$3 | LIGHT_CANDLES$3,
11908
+ flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$2,
11778
11909
  emoji: emojiSukkot,
11779
11910
  },
11780
11911
  {
@@ -11839,7 +11970,7 @@ const staticHolidays = [
11839
11970
  mm: Tishrei,
11840
11971
  dd: 14,
11841
11972
  desc: EREV_SUKKOT,
11842
- flags: IL_ONLY$2 | EREV$3 | LIGHT_CANDLES$3,
11973
+ flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$2,
11843
11974
  emoji: emojiSukkot,
11844
11975
  },
11845
11976
  {
@@ -11899,7 +12030,7 @@ const staticHolidays = [
11899
12030
  mm: Tishrei,
11900
12031
  dd: 21,
11901
12032
  desc: SUKKOT_VII_HOSHANA_RABA,
11902
- flags: LIGHT_CANDLES$3 | CHOL_HAMOED$1,
12033
+ flags: LIGHT_CANDLES$2 | CHOL_HAMOED$1,
11903
12034
  chmDay: -1,
11904
12035
  emoji: emojiSukkot,
11905
12036
  },
@@ -11908,7 +12039,7 @@ const staticHolidays = [
11908
12039
  mm: Adar2,
11909
12040
  dd: 13,
11910
12041
  desc: EREV_PURIM,
11911
- flags: EREV$3 | MINOR_HOLIDAY$2,
12042
+ flags: EREV$2 | MINOR_HOLIDAY$2,
11912
12043
  emoji: '🎭️📜',
11913
12044
  },
11914
12045
  { mm: Adar2, dd: 14, desc: PURIM, flags: MINOR_HOLIDAY$2, emoji: '🎭️📜' },
@@ -11924,7 +12055,7 @@ const staticHolidays = [
11924
12055
  mm: Nisan,
11925
12056
  dd: 14,
11926
12057
  desc: EREV_PESACH,
11927
- flags: IL_ONLY$2 | EREV$3 | LIGHT_CANDLES$3,
12058
+ flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$2,
11928
12059
  emoji: '🫓🍷',
11929
12060
  },
11930
12061
  {
@@ -11970,7 +12101,7 @@ const staticHolidays = [
11970
12101
  mm: Nisan,
11971
12102
  dd: 20,
11972
12103
  desc: PESACH_VI_CHM,
11973
- flags: IL_ONLY$2 | CHOL_HAMOED$1 | LIGHT_CANDLES$3,
12104
+ flags: IL_ONLY$2 | CHOL_HAMOED$1 | LIGHT_CANDLES$2,
11974
12105
  chmDay: 5,
11975
12106
  emoji: emojiPesach,
11976
12107
  },
@@ -11986,7 +12117,7 @@ const staticHolidays = [
11986
12117
  mm: Nisan,
11987
12118
  dd: 14,
11988
12119
  desc: EREV_PESACH,
11989
- flags: CHUL_ONLY$1 | EREV$3 | LIGHT_CANDLES$3,
12120
+ flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$2,
11990
12121
  emoji: '🫓🍷',
11991
12122
  },
11992
12123
  {
@@ -12031,7 +12162,7 @@ const staticHolidays = [
12031
12162
  mm: Nisan,
12032
12163
  dd: 20,
12033
12164
  desc: PESACH_VI_CHM,
12034
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1 | LIGHT_CANDLES$3,
12165
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1 | LIGHT_CANDLES$2,
12035
12166
  chmDay: 4,
12036
12167
  emoji: emojiPesach,
12037
12168
  },
@@ -12055,7 +12186,7 @@ const staticHolidays = [
12055
12186
  mm: Sivan,
12056
12187
  dd: 5,
12057
12188
  desc: EREV_SHAVUOT,
12058
- flags: EREV$3 | LIGHT_CANDLES$3,
12189
+ flags: EREV$2 | LIGHT_CANDLES$2,
12059
12190
  emoji: '⛰️🌸',
12060
12191
  },
12061
12192
  {
@@ -12091,7 +12222,7 @@ const staticHolidays = [
12091
12222
  mm: Elul,
12092
12223
  dd: 29,
12093
12224
  desc: EREV_ROSH_HASHANA,
12094
- flags: EREV$3 | LIGHT_CANDLES$3,
12225
+ flags: EREV$2 | LIGHT_CANDLES$2,
12095
12226
  emoji: '🍏🍯',
12096
12227
  },
12097
12228
  ];
@@ -12203,7 +12334,7 @@ class HolidayEvent extends Event {
12203
12334
  urlFriendly(this.basename()) +
12204
12335
  '-' +
12205
12336
  this.urlDateSuffix();
12206
- return this.getFlags() & flags.IL_ONLY ? url + '?i=on' : url;
12337
+ return this.hasFlag('IL_ONLY') ? url + '?i=on' : url;
12207
12338
  }
12208
12339
  /**
12209
12340
  * The date portion of {@link url}. For most holidays this is just the
@@ -12217,7 +12348,7 @@ class HolidayEvent extends Event {
12217
12348
  if (this.emoji) {
12218
12349
  return this.emoji;
12219
12350
  }
12220
- if (this.getFlags() & flags.SPECIAL_SHABBAT) {
12351
+ if (this.hasFlag('SPECIAL_SHABBAT')) {
12221
12352
  return '🕍';
12222
12353
  }
12223
12354
  return '✡️';
@@ -12460,7 +12591,7 @@ const SPECIAL_SHABBAT$1 = flags.SPECIAL_SHABBAT;
12460
12591
  const MODERN_HOLIDAY$1 = flags.MODERN_HOLIDAY;
12461
12592
  const MAJOR_FAST$1 = flags.MAJOR_FAST;
12462
12593
  const MINOR_HOLIDAY$1 = flags.MINOR_HOLIDAY;
12463
- const EREV$2 = flags.EREV;
12594
+ const EREV$1 = flags.EREV;
12464
12595
  const SUN = 0;
12465
12596
  const TUE = 2;
12466
12597
  const THU = 4;
@@ -12503,7 +12634,7 @@ function getHolidaysForYear_(year) {
12503
12634
  const key = ev.date.toString();
12504
12635
  const arr = map.get(key);
12505
12636
  if (typeof arr === 'object') {
12506
- if (arr[0].getFlags() & EREV$2) {
12637
+ if (arr[0].hasFlag('EREV')) {
12507
12638
  arr.unshift(ev);
12508
12639
  }
12509
12640
  else {
@@ -12536,7 +12667,7 @@ function getHolidaysForYear_(year) {
12536
12667
  ? new HDate(1, TEVET, year)
12537
12668
  : new HDate(30, KISLEV, year);
12538
12669
  add(new HolidayEvent(rchTevet, holidayDesc.CHAG_HABANOT, MINOR_HOLIDAY$1));
12539
- add(new ChanukahEvent(new HDate(24, KISLEV, year), holidayDesc.CHANUKAH_1_CANDLE, EREV$2 | MINOR_HOLIDAY$1 | CHANUKAH_CANDLES$1, undefined));
12670
+ add(new ChanukahEvent(new HDate(24, KISLEV, year), holidayDesc.CHANUKAH_1_CANDLE, EREV$1 | MINOR_HOLIDAY$1 | CHANUKAH_CANDLES$1, undefined));
12540
12671
  // yes, we know Kislev 30-32 are wrong
12541
12672
  // HDate() corrects the month automatically
12542
12673
  for (let candles = 2; candles <= 8; candles++) {
@@ -12606,7 +12737,7 @@ function getHolidaysForYear_(year) {
12606
12737
  av9title += ' (observed)';
12607
12738
  }
12608
12739
  const av9abs = av9dt.abs();
12609
- add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, av9abs)), holidayDesc.SHABBAT_CHAZON, SPECIAL_SHABBAT$1), new HolidayEvent(av9dt.prev(), holidayDesc.EREV_TISHA_BAV, EREV$2 | MAJOR_FAST$1, av9attrs), new HolidayEvent(av9dt, av9title, MAJOR_FAST$1, av9attrs), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, av9abs + 7)), holidayDesc.SHABBAT_NACHAMU, SPECIAL_SHABBAT$1));
12740
+ add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, av9abs)), holidayDesc.SHABBAT_CHAZON, SPECIAL_SHABBAT$1), new HolidayEvent(av9dt.prev(), holidayDesc.EREV_TISHA_BAV, EREV$1 | MAJOR_FAST$1, av9attrs), new HolidayEvent(av9dt, av9title, MAJOR_FAST$1, av9attrs), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, av9abs + 7)), holidayDesc.SHABBAT_NACHAMU, SPECIAL_SHABBAT$1));
12610
12741
  const monthsInYear = HDate.monthsInYear(year);
12611
12742
  for (let month = 1; month <= monthsInYear; month++) {
12612
12743
  const monthName = HDate.getMonthName(month, year);
@@ -12721,12 +12852,11 @@ function getHolidaysForYearArray(year, il) {
12721
12852
  return events;
12722
12853
  }
12723
12854
 
12724
- const LIGHT_CANDLES$2 = flags.LIGHT_CANDLES | flags.LIGHT_CANDLES_TZEIS;
12725
12855
  function isTomorrowShabbosOrYomTov(dow, events) {
12726
12856
  if (dow === 5) {
12727
12857
  return true;
12728
12858
  }
12729
- const erev = events.find(ev => ev.getFlags() & LIGHT_CANDLES$2);
12859
+ const erev = events.find(ev => ev.hasAnyFlag('LIGHT_CANDLES', 'LIGHT_CANDLES_TZEIS'));
12730
12860
  if (erev) {
12731
12861
  return true;
12732
12862
  }
@@ -12744,7 +12874,7 @@ function isTodayAssurBemelacha(dow, events) {
12744
12874
  if (dow === 6) {
12745
12875
  return true;
12746
12876
  }
12747
- const chag = events.find(ev => ev.getFlags() & flags.CHAG);
12877
+ const chag = events.find(ev => ev.hasFlag('CHAG'));
12748
12878
  if (chag) {
12749
12879
  return true;
12750
12880
  }
@@ -12859,8 +12989,6 @@ function isAveilut(date) {
12859
12989
  return isSefiratHaOmer(hd) || isBeinHaMetzarim(hd);
12860
12990
  }
12861
12991
 
12862
- const FAST_DAY = flags.MAJOR_FAST | flags.MINOR_FAST;
12863
- const EREV$1 = flags.EREV;
12864
12992
  /**
12865
12993
  * Returns `true` if the given date is observed as a major or minor fast day.
12866
12994
  *
@@ -12882,10 +13010,7 @@ const EREV$1 = flags.EREV;
12882
13010
  */
12883
13011
  function isFastDay(date, il) {
12884
13012
  const events = getHolidaysOnDate(date, il) || [];
12885
- const fastDay = events.find(ev => {
12886
- const mask = ev.getFlags();
12887
- return mask & FAST_DAY && !(mask & EREV$1);
12888
- });
13013
+ const fastDay = events.find(ev => ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST') && !ev.hasFlag('EREV'));
12889
13014
  return Boolean(fastDay);
12890
13015
  }
12891
13016
 
@@ -13023,14 +13148,14 @@ const LIGHT_CANDLES_TZEIS$1 = flags.LIGHT_CANDLES_TZEIS;
13023
13148
  function makeCandleEvent(ev, hd, options, isFriday, isSaturday) {
13024
13149
  let havdalahTitle = false;
13025
13150
  let useHavdalahOffset = isSaturday;
13026
- let mask = ev ? ev.getFlags() : LIGHT_CANDLES$1;
13151
+ let mask = ev ? ev.mask : LIGHT_CANDLES$1;
13027
13152
  if (ev !== undefined) {
13028
13153
  // if linked event && dow == FRI, use Candle lighting time & title
13029
13154
  if (!isFriday) {
13030
- if (mask & (LIGHT_CANDLES_TZEIS$1 | flags.CHANUKAH_CANDLES)) {
13155
+ if (ev.hasAnyFlag('LIGHT_CANDLES_TZEIS', 'CHANUKAH_CANDLES')) {
13031
13156
  useHavdalahOffset = true;
13032
13157
  }
13033
- else if (mask & flags.YOM_TOV_ENDS) {
13158
+ else if (ev.hasFlag('YOM_TOV_ENDS')) {
13034
13159
  havdalahTitle = true;
13035
13160
  useHavdalahOffset = true;
13036
13161
  }
@@ -13134,7 +13259,7 @@ function makeFastEndTime(zmanim, isTishaBav, options) {
13134
13259
  */
13135
13260
  class FastDayEvent extends HolidayEvent {
13136
13261
  constructor(linkedEvent, startEvent, endEvent) {
13137
- super(linkedEvent.getDate(), linkedEvent.getDesc(), linkedEvent.getFlags());
13262
+ super(linkedEvent.getDate(), linkedEvent.getDesc(), linkedEvent.mask);
13138
13263
  this.linkedEvent = linkedEvent;
13139
13264
  this.startEvent = startEvent;
13140
13265
  this.endEvent = endEvent;
@@ -13210,7 +13335,7 @@ function makeFastStartEnd(ev, options) {
13210
13335
  function makeTimedEvent(ev, time, desc, options) {
13211
13336
  const location = options.location;
13212
13337
  const hd = ev.getDate();
13213
- return new TimedEvent(hd, desc, ev.getFlags(), time, location, ev, options);
13338
+ return new TimedEvent(hd, desc, ev.mask, time, location, ev, options);
13214
13339
  }
13215
13340
  /**
13216
13341
  * A Chanukah candle-lighting event that carries a specific time of day.
@@ -13229,7 +13354,7 @@ class TimedChanukahEvent extends ChanukahEvent {
13229
13354
  * @param location location used to format the time
13230
13355
  */
13231
13356
  constructor(ev, eventTime, location) {
13232
- super(ev.getDate(), ev.getDesc(), ev.getFlags(), ev.chanukahDay);
13357
+ super(ev.getDate(), ev.getDesc(), ev.mask, ev.chanukahDay);
13233
13358
  this.eventTime = Zmanim.roundTime(eventTime);
13234
13359
  const timeFormat = location.getTimeFormatter();
13235
13360
  this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
@@ -14711,7 +14836,6 @@ function getMaskFromOptions(options) {
14711
14836
  }
14712
14837
  return mask;
14713
14838
  }
14714
- const MASK_LIGHT_CANDLES = LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | CHANUKAH_CANDLES | YOM_TOV_ENDS;
14715
14839
  const defaultLocation = new Location(0, 0, false, 'UTC');
14716
14840
  /**
14717
14841
  * @private
@@ -14765,10 +14889,12 @@ function appendHolidayAndRelated(candlesEv, events, ev, options, isFriday, isSat
14765
14889
  if (!ev.observedIn(il)) {
14766
14890
  return candlesEv; // holiday isn't observed here; bail out early
14767
14891
  }
14768
- const eFlags = ev.getFlags();
14769
- if ((!options.yomKippurKatan && eFlags & YOM_KIPPUR_KATAN) ||
14770
- (!options.behab && eFlags & BEHAB) ||
14771
- (options.noModern && eFlags & MODERN_HOLIDAY)) {
14892
+ const eFlags = ev.mask;
14893
+ const isYomKippurKatan = ev.hasFlag('YOM_KIPPUR_KATAN');
14894
+ const isBehab = ev.hasFlag('BEHAB');
14895
+ if ((!options.yomKippurKatan && isYomKippurKatan) ||
14896
+ (!options.behab && isBehab) ||
14897
+ (options.noModern && ev.hasFlag('MODERN_HOLIDAY'))) {
14772
14898
  return candlesEv; // bail out early
14773
14899
  }
14774
14900
  if (options.candlelighting && ev.getDesc() === holidayDesc.EREV_PESACH) {
@@ -14777,8 +14903,10 @@ function appendHolidayAndRelated(candlesEv, events, ev, options, isFriday, isSat
14777
14903
  events.push(...evts);
14778
14904
  }
14779
14905
  }
14780
- const isMajorFast = Boolean(eFlags & MAJOR_FAST);
14781
- const isMinorFast = Boolean(eFlags & MINOR_FAST);
14906
+ const isMajorFast = ev.hasFlag('MAJOR_FAST');
14907
+ const isMinorFast = ev.hasFlag('MINOR_FAST');
14908
+ const isChanukah = ev.hasFlag('CHANUKAH_CANDLES');
14909
+ const hasCandles = ev.hasAnyFlag('LIGHT_CANDLES', 'LIGHT_CANDLES_TZEIS', 'CHANUKAH_CANDLES', 'YOM_TOV_ENDS');
14782
14910
  let fastEv;
14783
14911
  if (options.candlelighting &&
14784
14912
  (isMajorFast || isMinorFast) &&
@@ -14790,10 +14918,10 @@ function appendHolidayAndRelated(candlesEv, events, ev, options, isFriday, isSat
14790
14918
  }
14791
14919
  }
14792
14920
  if (eFlags & Number(options.mask) || (!eFlags && !hasUserMask)) {
14793
- if (options.candlelighting && eFlags & MASK_LIGHT_CANDLES) {
14921
+ if (options.candlelighting && hasCandles) {
14794
14922
  const hd = ev.getDate();
14795
14923
  candlesEv = makeCandleEvent(ev, hd, options, isFriday, isSaturday);
14796
- if (eFlags & CHANUKAH_CANDLES && candlesEv && !options.noHolidays) {
14924
+ if (isChanukah && candlesEv && !options.noHolidays) {
14797
14925
  // Replace Chanukah event with a clone that includes candle lighting time.
14798
14926
  // For clarity, allow a "duplicate" candle lighting event to remain for Shabbat
14799
14927
  const chanukahEv = makeWeekdayChanukahCandleLighting(ev, options);
@@ -14808,8 +14936,8 @@ function appendHolidayAndRelated(candlesEv, events, ev, options, isFriday, isSat
14808
14936
  }
14809
14937
  }
14810
14938
  if (!options.noHolidays ||
14811
- (options.yomKippurKatan && eFlags & YOM_KIPPUR_KATAN) ||
14812
- (options.behab && eFlags & BEHAB)) {
14939
+ (options.yomKippurKatan && isYomKippurKatan) ||
14940
+ (options.behab && isBehab)) {
14813
14941
  events.push(ev); // the original event itself
14814
14942
  }
14815
14943
  }
@@ -14921,18 +15049,17 @@ function hallel_(events, hdate) {
14921
15049
  const desc = ev.getDesc();
14922
15050
  const month = hd.getMonth();
14923
15051
  const mday = hd.getDate();
14924
- const mask = ev.getFlags();
14925
15052
  if (desc.startsWith('Chanukah') ||
14926
15053
  desc.startsWith('Shavuot') ||
14927
15054
  desc.startsWith('Sukkot') ||
14928
15055
  (month === months.NISAN &&
14929
15056
  (mday === 15 || mday === 16) &&
14930
- mask & flags.CHAG) || // Pesach
15057
+ ev.hasFlag('CHAG')) || // Pesach
14931
15058
  desc === holidayDesc.YOM_HAATZMA_UT ||
14932
15059
  desc === holidayDesc.YOM_YERUSHALAYIM) {
14933
15060
  return WHOLE;
14934
15061
  }
14935
- if (mask & flags.ROSH_CHODESH ||
15062
+ if (ev.hasFlag('ROSH_CHODESH') ||
14936
15063
  (desc.startsWith('Pesach') &&
14937
15064
  desc !== holidayDesc.PESACH_I &&
14938
15065
  desc !== holidayDesc.PESACH_II)) {
@@ -15073,8 +15200,8 @@ class HebrewCalendar {
15073
15200
  }
15074
15201
  /**
15075
15202
  * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
15076
- * `HDate.toString()`. These events must be filtered for `flags.IL_ONLY`
15077
- * or `flags.CHUL_ONLY` depending on Israel vs. Diaspora holiday scheme.
15203
+ * `HDate.toString()`. These events are not filtered by Israel vs. Diaspora
15204
+ * holiday scheme; use {@link Event.observedIn} to do that.
15078
15205
  *
15079
15206
  * Includes Rosh Chodesh, fasts, Yom Kippur Katan, Special Shabbatot, etc.,
15080
15207
  * but does not generate candle-lighting times, Torah readings, or Omer days.
@@ -15269,7 +15396,7 @@ class HebrewCalendar {
15269
15396
  */
15270
15397
  function isChag(date, il) {
15271
15398
  const events = getHolidaysOnDate(date, il) || [];
15272
- const chag = events.filter(ev => ev.getFlags() & flags.CHAG);
15399
+ const chag = events.filter(ev => ev.hasFlag('CHAG'));
15273
15400
  return chag.length !== 0;
15274
15401
  }
15275
15402