@hebcal/core 6.14.1 → 6.14.3

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 (51) hide show
  1. package/dist/bundle.js +458 -381
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/bundle.min.js +3 -3
  4. package/dist/bundle.min.js.map +1 -1
  5. package/dist/esm/DailyLearning.js +1 -1
  6. package/dist/esm/HebrewDateEvent.js +1 -1
  7. package/dist/esm/HolidayEvent.js +1 -1
  8. package/dist/esm/KiddushLevanaEvent.js +1 -1
  9. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  10. package/dist/esm/ParshaEvent.js +1 -1
  11. package/dist/esm/TimedEvent.js +1 -1
  12. package/dist/esm/YomKippurKatanEvent.js +1 -1
  13. package/dist/esm/ashkenazi.po.js +1 -1
  14. package/dist/esm/calendar.js +48 -24
  15. package/dist/esm/calendar.js.map +1 -1
  16. package/dist/esm/candles.js +1 -1
  17. package/dist/esm/cities.json.js +1 -1
  18. package/dist/esm/event.js +1 -1
  19. package/dist/esm/getStartAndEnd.js +1 -1
  20. package/dist/esm/hallel.js +1 -1
  21. package/dist/esm/he-x-NoNikud.po.js +1 -1
  22. package/dist/esm/he.po.js +1 -1
  23. package/dist/esm/hebcal.js +1 -1
  24. package/dist/esm/holidays.d.ts +19 -0
  25. package/dist/esm/holidays.js +38 -9
  26. package/dist/esm/holidays.js.map +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/isAssurBemlacha.js +1 -1
  29. package/dist/esm/isAveilut.js +1 -1
  30. package/dist/esm/isFastDay.js +1 -1
  31. package/dist/esm/locale.js +1 -1
  32. package/dist/esm/location.js +1 -1
  33. package/dist/esm/modern.js +1 -1
  34. package/dist/esm/molad.js +1 -1
  35. package/dist/esm/moladBase.js +1 -1
  36. package/dist/esm/moladDate.js +1 -1
  37. package/dist/esm/omer.js +1 -1
  38. package/dist/esm/parshaName.js +1 -1
  39. package/dist/esm/parshaYear.js +1 -1
  40. package/dist/esm/pkgVersion.d.ts +1 -1
  41. package/dist/esm/pkgVersion.js +2 -2
  42. package/dist/esm/pkgVersion.js.map +1 -1
  43. package/dist/esm/reformatTimeStr.js +1 -1
  44. package/dist/esm/sedra.js +1 -1
  45. package/dist/esm/sefira.json.js +1 -1
  46. package/dist/esm/staticHolidays.js +1 -1
  47. package/dist/esm/string.js +1 -1
  48. package/dist/esm/tachanun.js +1 -1
  49. package/dist/esm/zenith.js +1 -1
  50. package/dist/esm/zmanim.js +1 -1
  51. package/package.json +9 -9
package/dist/bundle.js CHANGED
@@ -1,9 +1,9 @@
1
- /*! @hebcal/core v6.14.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.14.3, distributed under GPLv2 or later 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.14.1';
6
+ const version = '6.14.3';
7
7
 
8
8
  /*! @hebcal/hdate v0.23.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
9
9
  /**
@@ -2961,259 +2961,6 @@ function requireObjectLike(arg) {
2961
2961
  return arg;
2962
2962
  }
2963
2963
 
2964
- function normalizeOptionsOrString(options, optionName) {
2965
- return "string" == typeof options ? ((optionName, optionVal) => {
2966
- const res = Object.create(null);
2967
- return res[optionName] = optionVal, res;
2968
- })(optionName, options) : requireObjectLike(options);
2969
- }
2970
-
2971
- const smallestUnitStr = "smallestUnit";
2972
-
2973
- const overflowMap = {
2974
- constrain: 0,
2975
- reject: 1
2976
- };
2977
-
2978
- const epochDisambigMap = {
2979
- compatible: 0,
2980
- reject: 1,
2981
- earlier: 2,
2982
- later: 3
2983
- };
2984
-
2985
- const offsetDisambigMap = {
2986
- reject: 0,
2987
- use: 1,
2988
- prefer: 2,
2989
- ignore: 3
2990
- };
2991
-
2992
- const calendarDisplayMap = {
2993
- auto: 0,
2994
- never: 1,
2995
- critical: 2,
2996
- always: 3
2997
- };
2998
-
2999
- const timeZoneDisplayMap = {
3000
- auto: 0,
3001
- never: 1,
3002
- critical: 2
3003
- };
3004
-
3005
- const offsetDisplayMap = {
3006
- auto: 0,
3007
- never: 1
3008
- };
3009
-
3010
- const roundingModeMap = {
3011
- floor: 0,
3012
- halfFloor: 1,
3013
- ceil: 2,
3014
- halfCeil: 3,
3015
- trunc: 4,
3016
- halfTrunc: 5,
3017
- expand: 6,
3018
- halfExpand: 7,
3019
- halfEven: 8
3020
- };
3021
-
3022
- const roundingModeFuncs = [ Math.floor, roundHalfFloor, Math.ceil, roundHalfCeil, Math.trunc, roundHalfTrunc, roundExpand, roundHalfExpand, roundHalfEven ];
3023
-
3024
- const directionMap = {
3025
- previous: -1,
3026
- next: 1
3027
- };
3028
-
3029
- function coerceRoundingIncInteger(options) {
3030
- const roundingInc = options.roundingIncrement;
3031
- return void 0 === roundingInc ? 1 : toIntegerWithTrunc(roundingInc, "roundingIncrement");
3032
- }
3033
-
3034
- function coerceFractionalSecondDigits(options) {
3035
- let subsecDigits = options.fractionalSecondDigits;
3036
- if (void 0 !== subsecDigits) {
3037
- if ("number" != typeof subsecDigits) {
3038
- if ("auto" === toString(subsecDigits)) {
3039
- return;
3040
- }
3041
- throwRangeError(invalidEntity("fractionalSecondDigits", subsecDigits));
3042
- }
3043
- subsecDigits = clampEntity("fractionalSecondDigits", Math.floor(subsecDigits), 0, 9, 1);
3044
- }
3045
- return subsecDigits;
3046
- }
3047
-
3048
- function coerceUnitOption(optionName, options, minUnit = 0, ensureDefined) {
3049
- let unitStr = options[optionName];
3050
- if (void 0 === unitStr) {
3051
- return ensureDefined ? minUnit : void 0;
3052
- }
3053
- if (unitStr = toString(unitStr), "auto" === unitStr) {
3054
- return ensureDefined ? minUnit : null;
3055
- }
3056
- let unit = unitNameMap[unitStr];
3057
- return void 0 === unit && (unit = durationFieldNamesAsc.indexOf(unitStr)), unit < 0 && throwRangeError(invalidChoice(optionName, unitStr, unitNameMap)),
3058
- unit;
3059
- }
3060
-
3061
- function coerceChoiceOption(optionName, enumNameMap, options, defaultChoice = 0) {
3062
- const enumArg = options[optionName];
3063
- if (void 0 === enumArg) {
3064
- return defaultChoice;
3065
- }
3066
- const enumStr = toString(enumArg);
3067
- const enumNum = enumNameMap[enumStr];
3068
- return void 0 === enumNum && throwRangeError(invalidChoice(optionName, enumStr, enumNameMap)),
3069
- enumNum;
3070
- }
3071
-
3072
- const coerceSmallestUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, smallestUnitStr);
3073
-
3074
- const coerceLargestUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, "largestUnit");
3075
-
3076
- const coerceTotalUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, "unit");
3077
-
3078
- const coerceOverflow = /*@__PURE__*/ bindArgs(coerceChoiceOption, "overflow", overflowMap);
3079
-
3080
- const coerceEpochDisambig = /*@__PURE__*/ bindArgs(coerceChoiceOption, "disambiguation", epochDisambigMap);
3081
-
3082
- const coerceOffsetDisambig = /*@__PURE__*/ bindArgs(coerceChoiceOption, "offset", offsetDisambigMap);
3083
-
3084
- const coerceCalendarDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "calendarName", calendarDisplayMap);
3085
-
3086
- const coerceTimeZoneDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "timeZoneName", timeZoneDisplayMap);
3087
-
3088
- const coerceOffsetDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "offset", offsetDisplayMap);
3089
-
3090
- const coerceRoundingMode = /*@__PURE__*/ bindArgs(coerceChoiceOption, "roundingMode", roundingModeMap);
3091
-
3092
- const coerceDirection = /*@__PURE__*/ bindArgs(coerceChoiceOption, "direction", directionMap);
3093
-
3094
- function validateRoundingInc(roundingInc, smallestUnit, allowManyLargeUnits, solarMode) {
3095
- const upUnitNano = solarMode ? nanoInUtcDay : unitNanoMap[smallestUnit + 1];
3096
- if (upUnitNano) {
3097
- const unitNano = unitNanoMap[smallestUnit];
3098
- upUnitNano % ((roundingInc = clampEntity("roundingIncrement", roundingInc, 1, upUnitNano / unitNano - (solarMode ? 0 : 1), 1)) * unitNano) && throwRangeError(invalidEntity("roundingIncrement", roundingInc));
3099
- } else {
3100
- roundingInc = clampEntity("roundingIncrement", roundingInc, 1, allowManyLargeUnits ? 10 ** 9 : 1, 1);
3101
- }
3102
- return roundingInc;
3103
- }
3104
-
3105
- function validateUnitRange(optionName, unit, minUnit, maxUnit) {
3106
- return null != unit && clampEntity(optionName, unit, minUnit, maxUnit, 1, unitNamesAsc),
3107
- unit;
3108
- }
3109
-
3110
- function checkLargestSmallestUnit(largestUnit, smallestUnit) {
3111
- smallestUnit > largestUnit && throwRangeError(flippedSmallestLargestUnit);
3112
- }
3113
-
3114
- function refineDiffOptions(roundingModeInvert, options, defaultLargestUnit, maxUnit = 9, minUnit = 0, defaultRoundingMode = 4) {
3115
- options = normalizeOptions(options);
3116
- let largestUnit = coerceLargestUnit(options, minUnit);
3117
- let roundingInc = coerceRoundingIncInteger(options);
3118
- let roundingMode = coerceRoundingMode(options, defaultRoundingMode);
3119
- let smallestUnit = coerceSmallestUnit(options, minUnit, 1);
3120
- return largestUnit = validateUnitRange("largestUnit", largestUnit, minUnit, maxUnit),
3121
- smallestUnit = validateUnitRange(smallestUnitStr, smallestUnit, minUnit, maxUnit),
3122
- null == largestUnit ? largestUnit = Math.max(defaultLargestUnit, smallestUnit) : checkLargestSmallestUnit(largestUnit, smallestUnit),
3123
- roundingInc = validateRoundingInc(roundingInc, smallestUnit, 1), roundingModeInvert && (roundingMode = (roundingMode => roundingMode < 4 ? (roundingMode + 2) % 4 : roundingMode)(roundingMode)),
3124
- [ largestUnit, smallestUnit, roundingInc, roundingMode ];
3125
- }
3126
-
3127
- function refineDurationRoundOptions(options, defaultLargestUnit, refineRelativeTo) {
3128
- options = normalizeOptionsOrString(options, smallestUnitStr);
3129
- let largestUnit = coerceLargestUnit(options);
3130
- const relativeToInternals = refineRelativeTo(options.relativeTo);
3131
- let roundingInc = coerceRoundingIncInteger(options);
3132
- const roundingMode = coerceRoundingMode(options, 7);
3133
- let smallestUnit = coerceSmallestUnit(options);
3134
- return void 0 === largestUnit && void 0 === smallestUnit && throwRangeError(missingSmallestLargestUnit),
3135
- null == smallestUnit && (smallestUnit = 0), null == largestUnit && (largestUnit = Math.max(smallestUnit, defaultLargestUnit)),
3136
- checkLargestSmallestUnit(largestUnit, smallestUnit), roundingInc = validateRoundingInc(roundingInc, smallestUnit, 1),
3137
- roundingInc > 1 && smallestUnit > 5 && largestUnit !== smallestUnit && throwRangeError("For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit"),
3138
- [ largestUnit, smallestUnit, roundingInc, roundingMode, relativeToInternals ];
3139
- }
3140
-
3141
- function refineRoundingOptions(options, maxUnit = 6, solarMode) {
3142
- let roundingInc = coerceRoundingIncInteger(options = normalizeOptionsOrString(options, smallestUnitStr));
3143
- const roundingMode = coerceRoundingMode(options, 7);
3144
- let smallestUnit = coerceSmallestUnit(options);
3145
- return smallestUnit = requirePropDefined(smallestUnitStr, smallestUnit), smallestUnit = validateUnitRange(smallestUnitStr, smallestUnit, 0, maxUnit),
3146
- roundingInc = validateRoundingInc(roundingInc, smallestUnit, void 0, solarMode),
3147
- [ smallestUnit, roundingInc, roundingMode ];
3148
- }
3149
-
3150
- function refineTotalOptions(options, refineRelativeTo) {
3151
- const relativeToInternals = refineRelativeTo((options = normalizeOptionsOrString(options, "unit")).relativeTo);
3152
- let totalUnit = coerceTotalUnit(options);
3153
- return totalUnit = requirePropDefined("unit", totalUnit), [ totalUnit, relativeToInternals ];
3154
- }
3155
-
3156
- function refineOverflowOptions(options) {
3157
- return void 0 === options ? 0 : coerceOverflow(requireObjectLike(options));
3158
- }
3159
-
3160
- function refineZonedFieldOptions(options, defaultOffsetDisambig = 0) {
3161
- options = normalizeOptions(options);
3162
- const epochDisambig = coerceEpochDisambig(options);
3163
- const offsetDisambig = coerceOffsetDisambig(options, defaultOffsetDisambig);
3164
- return [ coerceOverflow(options), offsetDisambig, epochDisambig ];
3165
- }
3166
-
3167
- function refineEpochDisambigOptions(options) {
3168
- return coerceEpochDisambig(normalizeOptions(options));
3169
- }
3170
-
3171
- function refineTimeDisplayTuple(options, maxSmallestUnit = 4) {
3172
- const subsecDigits = coerceFractionalSecondDigits(options);
3173
- const roundingMode = coerceRoundingMode(options, 4);
3174
- const smallestUnit = coerceSmallestUnit(options);
3175
- return [ roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, maxSmallestUnit), subsecDigits) ];
3176
- }
3177
-
3178
- function refineDateTimeDisplayOptions(options) {
3179
- return options = normalizeOptions(options), [ coerceCalendarDisplay(options), ...refineTimeDisplayTuple(options) ];
3180
- }
3181
-
3182
- function refineDateDisplayOptions(options) {
3183
- return coerceCalendarDisplay(normalizeOptions(options));
3184
- }
3185
-
3186
- function refineTimeDisplayOptions(options, maxSmallestUnit) {
3187
- return refineTimeDisplayTuple(normalizeOptions(options), maxSmallestUnit);
3188
- }
3189
-
3190
- function refineZonedDateTimeDisplayOptions(options) {
3191
- options = normalizeOptions(options);
3192
- const calendarDisplay = coerceCalendarDisplay(options);
3193
- const subsecDigits = coerceFractionalSecondDigits(options);
3194
- const offsetDisplay = coerceOffsetDisplay(options);
3195
- const roundingMode = coerceRoundingMode(options, 4);
3196
- const smallestUnit = coerceSmallestUnit(options);
3197
- return [ calendarDisplay, coerceTimeZoneDisplay(options), offsetDisplay, roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, 4), subsecDigits) ];
3198
- }
3199
-
3200
- function refineInstantDisplayOptions(options) {
3201
- const subsecDigits = coerceFractionalSecondDigits(options = normalizeOptions(options));
3202
- const roundingMode = coerceRoundingMode(options, 4);
3203
- const smallestUnit = coerceSmallestUnit(options);
3204
- return [ options.timeZone, roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, 4), subsecDigits) ];
3205
- }
3206
-
3207
- function resolveSmallestUnitAndSubsecDigits(smallestUnit, subsecDigits) {
3208
- return null != smallestUnit ? [ unitNanoMap[smallestUnit], smallestUnit < 4 ? 9 - 3 * smallestUnit : -1 ] : [ void 0 === subsecDigits ? 1 : 10 ** (9 - subsecDigits), subsecDigits ];
3209
- }
3210
-
3211
- function refineDirectionOptions(options) {
3212
- const normalizedOptions = normalizeOptionsOrString(options, "direction");
3213
- const res = coerceDirection(normalizedOptions, 0);
3214
- return res || throwRangeError(invalidEntity("direction", res)), res;
3215
- }
3216
-
3217
2964
  const invalidEntity = invalidEntity$1;
3218
2965
 
3219
2966
  const missingField = fieldName => `Missing ${fieldName}`;
@@ -3240,10 +2987,6 @@ const invalidTimeZone = calendarId => invalidEntity$1("TimeZone", calendarId);
3240
2987
 
3241
2988
  const outOfBoundsDate = "Out-of-bounds date";
3242
2989
 
3243
- const missingSmallestLargestUnit = "Required smallestUnit or largestUnit";
3244
-
3245
- const flippedSmallestLargestUnit = "smallestUnit > largestUnit";
3246
-
3247
2990
  const failedParse = s => `Cannot parse: ${s}`;
3248
2991
 
3249
2992
  const invalidSubstring = substring => `Invalid substring: ${substring}`;
@@ -3429,34 +3172,10 @@ function modTrunc(num, divisor) {
3429
3172
  return num % divisor || 0;
3430
3173
  }
3431
3174
 
3432
- function roundExpand(num) {
3433
- return num < 0 ? Math.floor(num) : Math.ceil(num);
3434
- }
3435
-
3436
3175
  function fabricateNearHalfFraction(halfCompare, sign = 1) {
3437
3176
  return sign * (.5 + halfCompare / 5);
3438
3177
  }
3439
3178
 
3440
- function roundHalfExpand(num) {
3441
- return Math.sign(num) * Math.round(Math.abs(num)) || 0;
3442
- }
3443
-
3444
- function roundHalfFloor(num) {
3445
- return hasHalf(num) ? Math.floor(num) : Math.round(num);
3446
- }
3447
-
3448
- function roundHalfCeil(num) {
3449
- return hasHalf(num) ? Math.ceil(num) : Math.round(num);
3450
- }
3451
-
3452
- function roundHalfTrunc(num) {
3453
- return hasHalf(num) ? Math.trunc(num) || 0 : Math.round(num);
3454
- }
3455
-
3456
- function roundHalfEven(num) {
3457
- return hasHalf(num) ? (num = Math.trunc(num) || 0) + num % 2 : Math.round(num);
3458
- }
3459
-
3460
3179
  function hasHalf(num) {
3461
3180
  return .5 === Math.abs(num % 1);
3462
3181
  }
@@ -3868,97 +3587,269 @@ function computeCalendarInLeapYear(calendar, isoDate) {
3868
3587
  return calendar ? calendar.q(year) : computeIsoInLeapYear(year);
3869
3588
  }
3870
3589
 
3871
- function computeCalendarMonthsInYear(calendar, isoDate) {
3872
- const {year: year} = computeCalendarDateFields(calendar, isoDate);
3873
- return computeCalendarMonthsInYearForYear(calendar, year);
3874
- }
3590
+ function computeCalendarMonthsInYear(calendar, isoDate) {
3591
+ const {year: year} = computeCalendarDateFields(calendar, isoDate);
3592
+ return computeCalendarMonthsInYearForYear(calendar, year);
3593
+ }
3594
+
3595
+ function computeCalendarDaysInMonth(calendar, isoDate) {
3596
+ const {year: year, month: month} = computeCalendarDateFields(calendar, isoDate);
3597
+ return computeCalendarDaysInMonthForYearMonth(calendar, year, month);
3598
+ }
3599
+
3600
+ function computeCalendarDaysInYear(calendar, isoDate) {
3601
+ const {year: year} = computeCalendarDateFields(calendar, isoDate);
3602
+ return calendar ? calendar.i(year) : computeIsoDaysInYear(year);
3603
+ }
3604
+
3605
+ function computeCalendarDayOfYear(calendar, isoDate) {
3606
+ if (!calendar) {
3607
+ return computeIsoDayOfYear(isoDate);
3608
+ }
3609
+ const {year: year} = computeCalendarDateFields(calendar, isoDate);
3610
+ const yearStartIsoDate = computeCalendarIsoFieldsFromParts(calendar, year, 1, 1);
3611
+ return isoDateToEpochDays(isoDate) - isoDateToEpochDays(yearStartIsoDate) + 1;
3612
+ }
3613
+
3614
+ function computeCalendarWeekOfYear(calendar, isoDate) {
3615
+ return calendar === isoCalendarImpl ? computeIsoWeekFields(isoDate).weekOfYear : void 0;
3616
+ }
3617
+
3618
+ function computeCalendarYearOfWeek(calendar, isoDate) {
3619
+ return calendar === isoCalendarImpl ? computeIsoWeekFields(isoDate).yearOfWeek : void 0;
3620
+ }
3621
+
3622
+ const durationFieldNamesAsc = /*@__PURE__*/ unitNamesAsc.map(unitName => unitName + "s");
3623
+
3624
+ const durationGetters = /*@__PURE__*/ createPropGetters(durationFieldNamesAsc);
3625
+
3626
+ const durationFieldNamesAlpha = /*@__PURE__*/ sortStrings(durationFieldNamesAsc);
3627
+
3628
+ const durationTimeFieldNamesAsc = /*@__PURE__*/ durationFieldNamesAsc.slice(0, 6);
3629
+
3630
+ const durationDateFieldNamesAsc = /*@__PURE__*/ durationFieldNamesAsc.slice(6);
3631
+
3632
+ const durationCalendarFieldNamesAsc = /*@__PURE__*/ durationDateFieldNamesAsc.slice(1);
3633
+
3634
+ const durationFieldDefaults = /*@__PURE__*/ zipPropsConst(durationFieldNamesAsc, 0);
3635
+
3636
+ const durationTimeFieldDefaults = /*@__PURE__*/ zipPropsConst(durationTimeFieldNamesAsc, 0);
3637
+
3638
+ const clearDurationFields = /*@__PURE__*/ bindArgs(zeroOutProps, durationFieldNamesAsc);
3639
+
3640
+ function requirePropDefined(optionName, optionVal) {
3641
+ return null == optionVal && throwRangeError(missingField(optionName)), optionVal;
3642
+ }
3643
+
3644
+ const requireString = /*@__PURE__*/ bindArgs(requireType, "string");
3645
+
3646
+ function requireType(typeName, arg, entityName = typeName) {
3647
+ return typeof arg !== typeName && throwTypeError(invalidEntity(entityName, arg)),
3648
+ arg;
3649
+ }
3650
+
3651
+ function requireNumberIsInteger(num, entityName = "number") {
3652
+ return Number.isInteger(num) || throwRangeError(((entityName, num) => `Non-integer ${entityName}: ${num}`)(entityName, num)),
3653
+ num || 0;
3654
+ }
3655
+
3656
+ function toString(arg) {
3657
+ return "symbol" == typeof arg && throwTypeError("Cannot convert Symbol to string"),
3658
+ String(arg);
3659
+ }
3660
+
3661
+ function toPrimitiveWithStringHint(arg) {
3662
+ if (!isObjectLike$1(arg)) {
3663
+ return arg;
3664
+ }
3665
+ const exoticToPrimitive = arg[Symbol.toPrimitive];
3666
+ if (null != exoticToPrimitive) {
3667
+ "function" != typeof exoticToPrimitive && throwTypeError();
3668
+ const primitive = Reflect.apply(exoticToPrimitive, arg, [ "string" ]);
3669
+ return isObjectLike$1(primitive) && throwTypeError(), primitive;
3670
+ }
3671
+ return Date.prototype[Symbol.toPrimitive].call(arg, "string");
3672
+ }
3673
+
3674
+ function toBigInt(bi) {
3675
+ return "boolean" == typeof bi ? BigInt(bi ? 1 : 0) : "string" == typeof bi ? BigInt(bi) : ("bigint" != typeof bi && throwTypeError(`Invalid bigint: ${bi}`),
3676
+ bi);
3677
+ }
3678
+
3679
+ function toStrictInteger(arg, entityName) {
3680
+ return requireNumberIsInteger(toFiniteNumber(arg, entityName), entityName);
3681
+ }
3682
+
3683
+ const smallestUnitStr = "smallestUnit";
3684
+
3685
+ const overflowMap = {
3686
+ constrain: 0,
3687
+ reject: 1
3688
+ };
3689
+
3690
+ const epochDisambigMap = {
3691
+ compatible: 0,
3692
+ reject: 1,
3693
+ earlier: 2,
3694
+ later: 3
3695
+ };
3696
+
3697
+ const offsetDisambigMap = {
3698
+ reject: 0,
3699
+ use: 1,
3700
+ prefer: 2,
3701
+ ignore: 3
3702
+ };
3703
+
3704
+ const calendarDisplayMap = {
3705
+ auto: 0,
3706
+ never: 1,
3707
+ critical: 2,
3708
+ always: 3
3709
+ };
3710
+
3711
+ const timeZoneDisplayMap = {
3712
+ auto: 0,
3713
+ never: 1,
3714
+ critical: 2
3715
+ };
3716
+
3717
+ const offsetDisplayMap = {
3718
+ auto: 0,
3719
+ never: 1
3720
+ };
3721
+
3722
+ const roundingModeMap = {
3723
+ floor: 0,
3724
+ halfFloor: 1,
3725
+ ceil: 2,
3726
+ halfCeil: 3,
3727
+ trunc: 4,
3728
+ halfTrunc: 5,
3729
+ expand: 6,
3730
+ halfExpand: 7,
3731
+ halfEven: 8
3732
+ };
3733
+
3734
+ 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) ];
3875
3735
 
3876
- function computeCalendarDaysInMonth(calendar, isoDate) {
3877
- const {year: year, month: month} = computeCalendarDateFields(calendar, isoDate);
3878
- return computeCalendarDaysInMonthForYearMonth(calendar, year, month);
3879
- }
3736
+ const directionMap = {
3737
+ previous: -1,
3738
+ next: 1
3739
+ };
3880
3740
 
3881
- function computeCalendarDaysInYear(calendar, isoDate) {
3882
- const {year: year} = computeCalendarDateFields(calendar, isoDate);
3883
- return calendar ? calendar.i(year) : computeIsoDaysInYear(year);
3741
+ function coerceRoundingIncInteger(options) {
3742
+ const roundingInc = options.roundingIncrement;
3743
+ return void 0 === roundingInc ? 1 : toIntegerWithTrunc(roundingInc, "roundingIncrement");
3884
3744
  }
3885
3745
 
3886
- function computeCalendarDayOfYear(calendar, isoDate) {
3887
- if (!calendar) {
3888
- return computeIsoDayOfYear(isoDate);
3746
+ function coerceFractionalSecondDigits(options) {
3747
+ let subsecDigits = options.fractionalSecondDigits;
3748
+ if (void 0 !== subsecDigits) {
3749
+ if ("number" != typeof subsecDigits) {
3750
+ if ("auto" === toString(subsecDigits)) {
3751
+ return;
3752
+ }
3753
+ throwRangeError(invalidEntity("fractionalSecondDigits", subsecDigits));
3754
+ }
3755
+ subsecDigits = clampEntity("fractionalSecondDigits", Math.floor(subsecDigits), 0, 9, 1);
3889
3756
  }
3890
- const {year: year} = computeCalendarDateFields(calendar, isoDate);
3891
- const yearStartIsoDate = computeCalendarIsoFieldsFromParts(calendar, year, 1, 1);
3892
- return isoDateToEpochDays(isoDate) - isoDateToEpochDays(yearStartIsoDate) + 1;
3757
+ return subsecDigits;
3893
3758
  }
3894
3759
 
3895
- function computeCalendarWeekOfYear(calendar, isoDate) {
3896
- return calendar === isoCalendarImpl ? computeIsoWeekFields(isoDate).weekOfYear : void 0;
3760
+ function coerceUnitOption(optionName, options, minUnit = 0, ensureDefined) {
3761
+ let unitStr = options[optionName];
3762
+ if (void 0 === unitStr) {
3763
+ return ensureDefined ? minUnit : void 0;
3764
+ }
3765
+ if (unitStr = toString(unitStr), "auto" === unitStr) {
3766
+ return ensureDefined ? minUnit : null;
3767
+ }
3768
+ let unit = unitNameMap[unitStr];
3769
+ return void 0 === unit && (unit = durationFieldNamesAsc.indexOf(unitStr)), unit < 0 && throwRangeError(invalidChoice(optionName, unitStr, unitNameMap)),
3770
+ unit;
3897
3771
  }
3898
3772
 
3899
- function computeCalendarYearOfWeek(calendar, isoDate) {
3900
- return calendar === isoCalendarImpl ? computeIsoWeekFields(isoDate).yearOfWeek : void 0;
3773
+ function coerceChoiceOption(optionName, enumNameMap, options, defaultChoice = 0) {
3774
+ const enumArg = options[optionName];
3775
+ if (void 0 === enumArg) {
3776
+ return defaultChoice;
3777
+ }
3778
+ const enumStr = toString(enumArg);
3779
+ const enumNum = enumNameMap[enumStr];
3780
+ return void 0 === enumNum && throwRangeError(invalidChoice(optionName, enumStr, enumNameMap)),
3781
+ enumNum;
3901
3782
  }
3902
3783
 
3903
- const durationFieldNamesAsc = /*@__PURE__*/ unitNamesAsc.map(unitName => unitName + "s");
3784
+ const coerceSmallestUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, smallestUnitStr);
3904
3785
 
3905
- const durationGetters = /*@__PURE__*/ createPropGetters(durationFieldNamesAsc);
3786
+ const coerceLargestUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, "largestUnit");
3906
3787
 
3907
- const durationFieldNamesAlpha = /*@__PURE__*/ sortStrings(durationFieldNamesAsc);
3788
+ const coerceTotalUnit = /*@__PURE__*/ bindArgs(coerceUnitOption, "unit");
3908
3789
 
3909
- const durationTimeFieldNamesAsc = /*@__PURE__*/ durationFieldNamesAsc.slice(0, 6);
3790
+ const coerceOverflow = /*@__PURE__*/ bindArgs(coerceChoiceOption, "overflow", overflowMap);
3910
3791
 
3911
- const durationDateFieldNamesAsc = /*@__PURE__*/ durationFieldNamesAsc.slice(6);
3792
+ const coerceEpochDisambig = /*@__PURE__*/ bindArgs(coerceChoiceOption, "disambiguation", epochDisambigMap);
3912
3793
 
3913
- const durationCalendarFieldNamesAsc = /*@__PURE__*/ durationDateFieldNamesAsc.slice(1);
3794
+ const coerceOffsetDisambig = /*@__PURE__*/ bindArgs(coerceChoiceOption, "offset", offsetDisambigMap);
3914
3795
 
3915
- const durationFieldDefaults = /*@__PURE__*/ zipPropsConst(durationFieldNamesAsc, 0);
3796
+ const coerceCalendarDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "calendarName", calendarDisplayMap);
3916
3797
 
3917
- const durationTimeFieldDefaults = /*@__PURE__*/ zipPropsConst(durationTimeFieldNamesAsc, 0);
3798
+ const coerceTimeZoneDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "timeZoneName", timeZoneDisplayMap);
3918
3799
 
3919
- const clearDurationFields = /*@__PURE__*/ bindArgs(zeroOutProps, durationFieldNamesAsc);
3800
+ const coerceOffsetDisplay = /*@__PURE__*/ bindArgs(coerceChoiceOption, "offset", offsetDisplayMap);
3920
3801
 
3921
- function requirePropDefined(optionName, optionVal) {
3922
- return null == optionVal && throwRangeError(missingField(optionName)), optionVal;
3923
- }
3802
+ const coerceRoundingMode = /*@__PURE__*/ bindArgs(coerceChoiceOption, "roundingMode", roundingModeMap);
3924
3803
 
3925
- const requireString = /*@__PURE__*/ bindArgs(requireType, "string");
3804
+ const coerceDirection = /*@__PURE__*/ bindArgs(coerceChoiceOption, "direction", directionMap);
3926
3805
 
3927
- function requireType(typeName, arg, entityName = typeName) {
3928
- return typeof arg !== typeName && throwTypeError(invalidEntity(entityName, arg)),
3929
- arg;
3806
+ function normalizeOptionsOrString(options, optionName) {
3807
+ return "string" == typeof options ? ((optionName, optionVal) => {
3808
+ const res = Object.create(null);
3809
+ return res[optionName] = optionVal, res;
3810
+ })(optionName, options) : requireObjectLike(options);
3930
3811
  }
3931
3812
 
3932
- function requireNumberIsInteger(num, entityName = "number") {
3933
- return Number.isInteger(num) || throwRangeError(((entityName, num) => `Non-integer ${entityName}: ${num}`)(entityName, num)),
3934
- num || 0;
3813
+ function validateRoundingInc(roundingInc, smallestUnit, allowManyLargeUnits, solarMode) {
3814
+ const upUnitNano = solarMode ? nanoInUtcDay : unitNanoMap[smallestUnit + 1];
3815
+ if (upUnitNano) {
3816
+ const unitNano = unitNanoMap[smallestUnit];
3817
+ upUnitNano % ((roundingInc = clampEntity("roundingIncrement", roundingInc, 1, upUnitNano / unitNano - (solarMode ? 0 : 1), 1)) * unitNano) && throwRangeError(invalidEntity("roundingIncrement", roundingInc));
3818
+ } else {
3819
+ roundingInc = clampEntity("roundingIncrement", roundingInc, 1, allowManyLargeUnits ? 10 ** 9 : 1, 1);
3820
+ }
3821
+ return roundingInc;
3935
3822
  }
3936
3823
 
3937
- function toString(arg) {
3938
- return "symbol" == typeof arg && throwTypeError("Cannot convert Symbol to string"),
3939
- String(arg);
3824
+ function validateUnitRange(optionName, unit, minUnit, maxUnit) {
3825
+ return null != unit && clampEntity(optionName, unit, minUnit, maxUnit, 1, unitNamesAsc),
3826
+ unit;
3940
3827
  }
3941
3828
 
3942
- function toPrimitiveWithStringHint(arg) {
3943
- if (!isObjectLike$1(arg)) {
3944
- return arg;
3945
- }
3946
- const exoticToPrimitive = arg[Symbol.toPrimitive];
3947
- if (null != exoticToPrimitive) {
3948
- "function" != typeof exoticToPrimitive && throwTypeError();
3949
- const primitive = Reflect.apply(exoticToPrimitive, arg, [ "string" ]);
3950
- return isObjectLike$1(primitive) && throwTypeError(), primitive;
3951
- }
3952
- return Date.prototype[Symbol.toPrimitive].call(arg, "string");
3829
+ function checkLargestSmallestUnit(largestUnit, smallestUnit) {
3830
+ smallestUnit > largestUnit && throwRangeError("smallestUnit > largestUnit");
3953
3831
  }
3954
3832
 
3955
- function toBigInt(bi) {
3956
- return "boolean" == typeof bi ? BigInt(bi ? 1 : 0) : "string" == typeof bi ? BigInt(bi) : ("bigint" != typeof bi && throwTypeError(`Invalid bigint: ${bi}`),
3957
- bi);
3833
+ function refineDiffOptions(roundingModeInvert, options, defaultLargestUnit, maxUnit = 9, minUnit = 0, defaultRoundingMode = 4) {
3834
+ options = normalizeOptions(options);
3835
+ let largestUnit = coerceLargestUnit(options, minUnit);
3836
+ let roundingInc = coerceRoundingIncInteger(options);
3837
+ let roundingMode = coerceRoundingMode(options, defaultRoundingMode);
3838
+ let smallestUnit = coerceSmallestUnit(options, minUnit, 1);
3839
+ return largestUnit = validateUnitRange("largestUnit", largestUnit, minUnit, maxUnit),
3840
+ smallestUnit = validateUnitRange(smallestUnitStr, smallestUnit, minUnit, maxUnit),
3841
+ null == largestUnit ? largestUnit = Math.max(defaultLargestUnit, smallestUnit) : checkLargestSmallestUnit(largestUnit, smallestUnit),
3842
+ roundingInc = validateRoundingInc(roundingInc, smallestUnit, 1), roundingModeInvert && (roundingMode = (roundingMode => roundingMode < 4 ? (roundingMode + 2) % 4 : roundingMode)(roundingMode)),
3843
+ [ largestUnit, smallestUnit, roundingInc, roundingMode ];
3958
3844
  }
3959
3845
 
3960
- function toStrictInteger(arg, entityName) {
3961
- return requireNumberIsInteger(toFiniteNumber(arg, entityName), entityName);
3846
+ function refineRoundingOptions(options, maxUnit = 6, solarMode) {
3847
+ let roundingInc = coerceRoundingIncInteger(options = normalizeOptionsOrString(options, smallestUnitStr));
3848
+ const roundingMode = coerceRoundingMode(options, 7);
3849
+ let smallestUnit = coerceSmallestUnit(options);
3850
+ return smallestUnit = requirePropDefined(smallestUnitStr, smallestUnit), smallestUnit = validateUnitRange(smallestUnitStr, smallestUnit, 0, maxUnit),
3851
+ roundingInc = validateRoundingInc(roundingInc, smallestUnit, void 0, solarMode),
3852
+ [ smallestUnit, roundingInc, roundingMode ];
3962
3853
  }
3963
3854
 
3964
3855
  function combineDateAndTime(isoDate, time) {
@@ -4308,7 +4199,7 @@ function getStartOfDayInstantFor(timeZone, isoDateTime) {
4308
4199
  }
4309
4200
 
4310
4201
  function moveYearMonth(calendar, isoDate, durationSlots, overflow = 0) {
4311
- computeDurationSign(durationSlots) && getMaxDurationUnit(durationSlots) < 8 && throwRangeError("Cannot use small units");
4202
+ computeDurationSign(durationSlots) && clampEntity("unit", getMaxDurationUnit(durationSlots), 8, 9, 1, durationFieldNamesAsc);
4312
4203
  const first = checkIsoDateInBounds(moveToStartOfMonth(calendar, isoDate));
4313
4204
  return moveToStartOfMonth(calendar, moveDate(calendar, first, durationSlots, overflow));
4314
4205
  }
@@ -4346,7 +4237,7 @@ function moveTime(timeFields, durationFields) {
4346
4237
  }
4347
4238
 
4348
4239
  function moveEpochNano(epochNano, durationFields) {
4349
- return moveEpochNanoByNano(epochNano, (durationHasDateParts(fields = durationFields) && throwRangeError("Cannot use large units"),
4240
+ return moveEpochNanoByNano(epochNano, (clampEntity("unit", getMaxDurationUnit(fields = durationFields), 0, 5, 1, durationFieldNamesAsc),
4350
4241
  durationTimeToBigNano(fields)));
4351
4242
  var fields;
4352
4243
  }
@@ -4692,7 +4583,7 @@ const maxDurationSeconds = 2 ** 53;
4692
4583
 
4693
4584
  function addDurationsWithoutRelativeTo(doSubtract, slots, otherSlots) {
4694
4585
  const maxUnit = Math.max(getMaxDurationUnit(slots), getMaxDurationUnit(otherSlots));
4695
- return maxUnit > 6 && throwRangeError("Cannot use large units"), ((doSubtract, slots, otherSlots, maxUnit) => createDurationSlots(validateDurationFields(((a, b, largestUnit, doSubtract) => {
4586
+ return clampEntity("unit", maxUnit, 0, 6, 1, durationFieldNamesAsc), ((doSubtract, slots, otherSlots, maxUnit) => createDurationSlots(validateDurationFields(((a, b, largestUnit, doSubtract) => {
4696
4587
  const combined = durationDayTimeToBigNano(a) + durationDayTimeToBigNano(b) * BigInt(doSubtract ? -1 : 1);
4697
4588
  return Number.isFinite(Number(combined / bigNanoInUtcDay)) || throwRangeError(outOfBoundsDate),
4698
4589
  {
@@ -4704,7 +4595,19 @@ function addDurationsWithoutRelativeTo(doSubtract, slots, otherSlots) {
4704
4595
 
4705
4596
  function roundDuration(refineRelativeTo, slots, options) {
4706
4597
  const durationLargestUnit = getMaxDurationUnit(slots);
4707
- const [largestUnit, smallestUnit, roundingInc, roundingMode, relativeToSlots] = refineDurationRoundOptions(options, durationLargestUnit, refineRelativeTo);
4598
+ const [largestUnit, smallestUnit, roundingInc, roundingMode, relativeToSlots] = ((options, defaultLargestUnit, refineRelativeTo) => {
4599
+ options = normalizeOptionsOrString(options, smallestUnitStr);
4600
+ let largestUnit = coerceLargestUnit(options);
4601
+ const relativeToInternals = refineRelativeTo(options.relativeTo);
4602
+ let roundingInc = coerceRoundingIncInteger(options);
4603
+ const roundingMode = coerceRoundingMode(options, 7);
4604
+ let smallestUnit = coerceSmallestUnit(options);
4605
+ return void 0 === largestUnit && void 0 === smallestUnit && throwRangeError("Required smallestUnit or largestUnit"),
4606
+ null == smallestUnit && (smallestUnit = 0), null == largestUnit && (largestUnit = Math.max(smallestUnit, defaultLargestUnit)),
4607
+ checkLargestSmallestUnit(largestUnit, smallestUnit), roundingInc = validateRoundingInc(roundingInc, smallestUnit, 1),
4608
+ roundingInc > 1 && smallestUnit > 5 && largestUnit !== smallestUnit && throwRangeError("For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit"),
4609
+ [ largestUnit, smallestUnit, roundingInc, roundingMode, relativeToInternals ];
4610
+ })(options, durationLargestUnit, refineRelativeTo);
4708
4611
  if (!relativeToSlots && Math.max(durationLargestUnit, largestUnit) <= 6) {
4709
4612
  return createDurationSlots(validateDurationFields(((durationFields, largestUnit, smallestUnit, roundingInc, roundingMode) => {
4710
4613
  const roundedBigNano = roundBigNanoToInc(durationDayTimeToBigNano(durationFields), computeBigNanoInc(smallestUnit, roundingInc), roundingMode);
@@ -4984,6 +4887,21 @@ function readAndRefineBagFields(bag, validFieldNames, fieldRefiners, requiredFie
4984
4887
  res;
4985
4888
  }
4986
4889
 
4890
+ function refineOverflowOptions(options) {
4891
+ return void 0 === options ? 0 : coerceOverflow(requireObjectLike(options));
4892
+ }
4893
+
4894
+ function refineZonedFieldOptions(options, defaultOffsetDisambig = 0) {
4895
+ options = normalizeOptions(options);
4896
+ const epochDisambig = coerceEpochDisambig(options);
4897
+ const offsetDisambig = coerceOffsetDisambig(options, defaultOffsetDisambig);
4898
+ return [ coerceOverflow(options), offsetDisambig, epochDisambig ];
4899
+ }
4900
+
4901
+ function refineEpochDisambigOptions(options) {
4902
+ return coerceEpochDisambig(normalizeOptions(options));
4903
+ }
4904
+
4987
4905
  function refineCalendarDateFields(fields, calendar, allowMissingDay) {
4988
4906
  const eraOrigins = getCalendarEraOrigins(calendar);
4989
4907
  void 0 !== fields.year || void 0 !== fields.era && void 0 !== fields.eraYear || throwTypeError(missingYear(eraOrigins)),
@@ -5093,8 +5011,32 @@ const timeZonePeriodDaysByName = {
5093
5011
 
5094
5012
  const minPossibleTransitionSec = -388152e4;
5095
5013
 
5014
+ function refineTimeDisplayTuple(options, maxSmallestUnit = 4) {
5015
+ const subsecDigits = coerceFractionalSecondDigits(options);
5016
+ const roundingMode = coerceRoundingMode(options, 4);
5017
+ const smallestUnit = coerceSmallestUnit(options);
5018
+ return [ roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, maxSmallestUnit), subsecDigits) ];
5019
+ }
5020
+
5021
+ function refineDateDisplayOptions(options) {
5022
+ return coerceCalendarDisplay(normalizeOptions(options));
5023
+ }
5024
+
5025
+ function refineTimeDisplayOptions(options, maxSmallestUnit) {
5026
+ return refineTimeDisplayTuple(normalizeOptions(options), maxSmallestUnit);
5027
+ }
5028
+
5029
+ function resolveSmallestUnitAndSubsecDigits(smallestUnit, subsecDigits) {
5030
+ return null != smallestUnit ? [ unitNanoMap[smallestUnit], smallestUnit < 4 ? 9 - 3 * smallestUnit : -1 ] : [ void 0 === subsecDigits ? 1 : 10 ** (9 - subsecDigits), subsecDigits ];
5031
+ }
5032
+
5096
5033
  function formatInstantIso(refineTimeZoneString, instantSlots, options) {
5097
- const [timeZoneArg, roundingMode, nanoInc, subsecDigits] = refineInstantDisplayOptions(options);
5034
+ const [timeZoneArg, roundingMode, nanoInc, subsecDigits] = (options => {
5035
+ const subsecDigits = coerceFractionalSecondDigits(options = normalizeOptions(options));
5036
+ const roundingMode = coerceRoundingMode(options, 4);
5037
+ const smallestUnit = coerceSmallestUnit(options);
5038
+ return [ options.timeZone, roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, 4), subsecDigits) ];
5039
+ })(options);
5098
5040
  const providedTimeZone = void 0 !== timeZoneArg;
5099
5041
  return ((providedTimeZone, timeZone, epochNano, roundingMode, nanoInc, subsecDigits) => {
5100
5042
  epochNano = roundBigNanoToDayOriginInc(epochNano, BigInt(nanoInc), roundingMode);
@@ -5104,7 +5046,15 @@ function formatInstantIso(refineTimeZoneString, instantSlots, options) {
5104
5046
  }
5105
5047
 
5106
5048
  function formatZonedDateTimeIso(zonedDateTimeSlots0, options) {
5107
- const displayOptions = refineZonedDateTimeDisplayOptions(options);
5049
+ const displayOptions = (options => {
5050
+ options = normalizeOptions(options);
5051
+ const calendarDisplay = coerceCalendarDisplay(options);
5052
+ const subsecDigits = coerceFractionalSecondDigits(options);
5053
+ const offsetDisplay = coerceOffsetDisplay(options);
5054
+ const roundingMode = coerceRoundingMode(options, 4);
5055
+ const smallestUnit = coerceSmallestUnit(options);
5056
+ return [ calendarDisplay, coerceTimeZoneDisplay(options), offsetDisplay, roundingMode, ...resolveSmallestUnitAndSubsecDigits(validateUnitRange(smallestUnitStr, smallestUnit, 0, 4), subsecDigits) ];
5057
+ })(options);
5108
5058
  return ((calendar, timeZoneId, timeZone, epochNano, calendarDisplay, timeZoneDisplay, offsetDisplay, roundingMode, nanoInc, subsecDigits) => {
5109
5059
  epochNano = roundBigNanoToDayOriginInc(epochNano, BigInt(nanoInc), roundingMode);
5110
5060
  const offsetNano = timeZone.B(epochNano);
@@ -5113,7 +5063,7 @@ function formatZonedDateTimeIso(zonedDateTimeSlots0, options) {
5113
5063
  }
5114
5064
 
5115
5065
  function formatPlainDateTimeIso(plainDateTimeSlots0, options) {
5116
- const displayOptions = refineDateTimeDisplayOptions(options);
5066
+ const displayOptions = (options => (options = normalizeOptions(options), [ coerceCalendarDisplay(options), ...refineTimeDisplayTuple(options) ]))(options);
5117
5067
  return ((calendar, isoDateTime, calendarDisplay, roundingMode, nanoInc, subsecDigits) => formatIsoDateTimeFields(roundDateTimeToInc(isoDateTime, nanoInc, roundingMode), subsecDigits) + formatCalendar(calendar, calendarDisplay))(plainDateTimeSlots0.calendar, plainDateTimeSlots0, ...displayOptions);
5118
5068
  }
5119
5069
 
@@ -5918,7 +5868,11 @@ function computeMonthCode(calendar, year, month) {
5918
5868
  }
5919
5869
 
5920
5870
  function totalDuration(refineRelativeTo, slots, options) {
5921
- const [totalUnit, relativeToSlots] = refineTotalOptions(options, refineRelativeTo);
5871
+ const [totalUnit, relativeToSlots] = ((options, refineRelativeTo) => {
5872
+ const relativeToInternals = refineRelativeTo((options = normalizeOptionsOrString(options, "unit")).relativeTo);
5873
+ let totalUnit = coerceTotalUnit(options);
5874
+ return totalUnit = requirePropDefined("unit", totalUnit), [ totalUnit, relativeToInternals ];
5875
+ })(options, refineRelativeTo);
5922
5876
  const maxDurationUnit = getMaxDurationUnit(slots);
5923
5877
  const maxUnit = Math.max(totalUnit, maxDurationUnit);
5924
5878
  const isZoned = relativeToSlots && isZonedEpochSlots(relativeToSlots);
@@ -6146,6 +6100,12 @@ function zonedDateTimeWithPlainTime(zonedDateTimeSlots, plainTimeFields) {
6146
6100
  createZonedEpochNanoSlots(epochNano, timeZone, zonedDateTimeSlots.calendar);
6147
6101
  }
6148
6102
 
6103
+ function refineDirectionOptions(options) {
6104
+ const normalizedOptions = normalizeOptionsOrString(options, "direction");
6105
+ const res = coerceDirection(normalizedOptions, 0);
6106
+ return res || throwRangeError(invalidEntity("direction", res)), res;
6107
+ }
6108
+
6149
6109
  function getCurrentIsoDateTime(timeZone) {
6150
6110
  const epochNano = getCurrentEpochNano();
6151
6111
  const offsetNano = timeZone.B(epochNano);
@@ -7704,6 +7664,60 @@ class GeoLocation {
7704
7664
  }
7705
7665
  this.timeZoneId = timeZoneId;
7706
7666
  }
7667
+ /**
7668
+ * A method that will return the location's local mean time offset in milliseconds from local
7669
+ * [standard time](https://en.wikipedia.org/wiki/Standard_time). The globe is split into 360&deg;, with
7670
+ * 15&deg; per hour of the day. For a local that is at a longitude that is evenly divisible by 15
7671
+ * (longitude % 15 == 0), at solar noon (with adjustment for the
7672
+ * [equation of time](https://en.wikipedia.org/wiki/Equation_of_time)) the sun should be directly overhead,
7673
+ * so a user who is 1&deg; west of this will have noon at 4 minutes after standard time noon, and conversely,
7674
+ * a user who is 1&deg; east of the 15&deg; longitude will have noon at 11:56 AM.
7675
+ * @param instant the instant at which to read the time zone offset (DST is taken into account)
7676
+ * @return the offset in milliseconds not accounting for Daylight saving time. A positive value will be returned
7677
+ * East of the 15&deg; timezone line, and a negative value West of it.
7678
+ */
7679
+ getLocalMeanTimeOffset(instant) {
7680
+ const timezoneOffsetMillis = instant.toZonedDateTimeISO(this.timeZoneId).offsetNanoseconds / 1e6;
7681
+ return this.longitude * 4 * 60 * 1000 - timezoneOffsetMillis;
7682
+ }
7683
+ /**
7684
+ * Adjust the date for [antimeridian](https://en.wikipedia.org/wiki/180th_meridian) crossover. This is
7685
+ * needed to deal with edge cases such as Samoa that use a different calendar date than expected based on their
7686
+ * geographic location.
7687
+ *
7688
+ * The actual Time Zone offset may deviate from the expected offset based on the longitude. Since the 'absolute time'
7689
+ * calculations are always based on longitudinal offset from UTC for a given date, the date is presumed to only
7690
+ * increase East of the Prime Meridian, and to only decrease West of it. For Time Zones that cross the antimeridian,
7691
+ * the date will be artificially adjusted before calculation to conform with this presumption.
7692
+ *
7693
+ * For example, Apia, Samoa with a longitude of -171.75 uses a local offset of +14:00. When calculating sunrise for
7694
+ * 2018-02-03, the calculator should operate using 2018-02-02 since the expected zone is -11. After determining the
7695
+ * UTC time, the local DST offset of [UTC+14:00](https://en.wikipedia.org/wiki/UTC%2B14:00) should be applied
7696
+ * to bring the date back to 2018-02-03.
7697
+ * @param date the date, at the start of which (in this location's time zone) the offset is read
7698
+ * @return the number of days to adjust the date This will typically be 0 unless the date crosses the antimeridian
7699
+ */
7700
+ getAntimeridianAdjustment(date) {
7701
+ // Time zone offsets range from -12:00 to +14:00, so an offset of 20 hours
7702
+ // or more needs a longitude of at least 120 degrees east or 90 degrees
7703
+ // west. Skip resolving the time zone for the rest of the world.
7704
+ if (this.longitude > -90 && this.longitude < 120) {
7705
+ return 0;
7706
+ }
7707
+ const midnight = date.toZonedDateTime(this.timeZoneId).toInstant();
7708
+ const localHoursOffset = this.getLocalMeanTimeOffset(midnight) / 3600000;
7709
+ if (localHoursOffset >= 20) {
7710
+ // a location far east using a time zone from across the antimeridian to
7711
+ // the west (none are known today, but better safe than sorry)
7712
+ return 1; // roll the date forward a day
7713
+ }
7714
+ else if (localHoursOffset <= -20) {
7715
+ // a location far west using a time zone from across the antimeridian to
7716
+ // the east, such as Samoa or Kiritimati
7717
+ return -1; // roll the date back a day
7718
+ }
7719
+ return 0; // 99.999% of the world will have no adjustment
7720
+ }
7707
7721
  }
7708
7722
  /**
7709
7723
  * The commonly used average solar refraction. Calendrical Calculations lists a more accurate global average of
@@ -8056,8 +8070,15 @@ class NOAACalculator {
8056
8070
  * @return the adjusted Calendar
8057
8071
  */
8058
8072
  getAdjustedDate() {
8059
- return this.date;
8073
+ if (this.adjustedDate === undefined) {
8074
+ const offset = this.geoLocation.getAntimeridianAdjustment(this.date);
8075
+ this.adjustedDate =
8076
+ offset === 0 ? this.date : this.date.add({ days: offset });
8077
+ }
8078
+ return this.adjustedDate;
8060
8079
  }
8080
+ /** Memoized result of {@link getAdjustedDate} */
8081
+ adjustedDate;
8061
8082
  /**
8062
8083
  * Method to return the adjustment to the zenith required to account for the elevation. Since a person at a higher
8063
8084
  * elevation can see farther below the horizon, the calculation for sunrise / sunset is calculated below the horizon
@@ -8337,8 +8358,11 @@ class NOAACalculator {
8337
8358
  year -= 1;
8338
8359
  month += 12;
8339
8360
  }
8361
+ // Integer division, as in the Java original: truncating `2 - a + a / 4`
8362
+ // as a whole is off by one day whenever `a` is not a multiple of 4
8363
+ // (e.g. every year from 1900 through 1999).
8340
8364
  const a = Math.trunc(year / 100);
8341
- const b = Math.trunc(2 - a + a / 4);
8365
+ const b = 2 - a + Math.trunc(a / 4);
8342
8366
  return (Math.floor(365.25 * (year + 4716)) +
8343
8367
  Math.floor(30.6001 * (month + 1)) +
8344
8368
  day +
@@ -12500,7 +12524,7 @@ function getHolidaysOnDate(date, il) {
12500
12524
  }
12501
12525
  return events.filter(ev => ev.observedIn(il));
12502
12526
  }
12503
- const { CHAG, LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$2, CHANUKAH_CANDLES: CHANUKAH_CANDLES$1, BEHAB: BEHAB$1, MINOR_FAST: MINOR_FAST$1, SPECIAL_SHABBAT: SPECIAL_SHABBAT$1, MAJOR_FAST: MAJOR_FAST$1, MINOR_HOLIDAY: MINOR_HOLIDAY$1, EREV: EREV$1, } = flags;
12527
+ const { CHAG, LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$2, CHANUKAH_CANDLES: CHANUKAH_CANDLES$1, BEHAB: BEHAB$1, MINOR_FAST: MINOR_FAST$1, SPECIAL_SHABBAT: SPECIAL_SHABBAT$1, MAJOR_FAST: MAJOR_FAST$1, MINOR_HOLIDAY: MINOR_HOLIDAY$1, EREV: EREV$1, SHABBAT_MEVARCHIM: SHABBAT_MEVARCHIM$1, } = flags;
12504
12528
  const SUN = 0;
12505
12529
  const TUE = 2;
12506
12530
  const THU = 4;
@@ -12513,18 +12537,44 @@ function addToMap(map, ...events) {
12513
12537
  const key = ev.date.toString();
12514
12538
  const arr = map.get(key);
12515
12539
  if (arr !== undefined) {
12516
- if (arr[0].hasFlag('EREV')) {
12517
- arr.unshift(ev);
12518
- }
12519
- else {
12520
- arr.push(ev);
12521
- }
12540
+ arr.push(ev);
12522
12541
  }
12523
12542
  else {
12524
12543
  map.set(key, [ev]);
12525
12544
  }
12526
12545
  }
12527
12546
  }
12547
+ /** @internal */
12548
+ const TIME_OF_DAY_MORNING = 0;
12549
+ /** @internal */
12550
+ const TIME_OF_DAY_MEVARCHIM = 1;
12551
+ /** @internal */
12552
+ const TIME_OF_DAY_DAY = 2;
12553
+ /** @internal */
12554
+ const TIME_OF_DAY_EVENING = 3;
12555
+ /**
12556
+ * Approximate time of day of an event, used to order events on the same date.
12557
+ * - Morning: special Shabbatot (tied to the Torah or Haftarah reading), minor
12558
+ * fasts (which begin at dawn) and Birkat Hachamah (recited at sunrise)
12559
+ * - Shabbat Mevarchim, announced in synagogue after the Torah reading
12560
+ * - Day: everything else
12561
+ * - Evening: Erev holidays, Chanukah candle-lighting and Leil Selichot
12562
+ * @internal
12563
+ */
12564
+ function timeOfDay(ev) {
12565
+ const mask = ev.getFlags();
12566
+ const desc = ev.getDesc();
12567
+ if (mask & (EREV$1 | CHANUKAH_CANDLES$1) || desc === holidayDesc.LEIL_SELICHOT) {
12568
+ return TIME_OF_DAY_EVENING;
12569
+ }
12570
+ if (mask & (SPECIAL_SHABBAT$1 | MINOR_FAST$1) || desc === holidayDesc.BIRKAT_HACHAMAH) {
12571
+ return TIME_OF_DAY_MORNING;
12572
+ }
12573
+ if (mask & SHABBAT_MEVARCHIM$1) {
12574
+ return TIME_OF_DAY_MEVARCHIM;
12575
+ }
12576
+ return TIME_OF_DAY_DAY;
12577
+ }
12528
12578
  function addStaticHolidays(map, year) {
12529
12579
  for (const h of staticHolidays) {
12530
12580
  const hd = new HDate(h.dd, h.mm, year);
@@ -12693,6 +12743,9 @@ function getHolidaysForYear_(year) {
12693
12743
  const hd = new HDate(birkatHaChama);
12694
12744
  addToMap(map, new HolidayEvent(hd, holidayDesc.BIRKAT_HACHAMAH, MINOR_HOLIDAY$1, { emoji: '☀️' }));
12695
12745
  }
12746
+ for (const arr of map.values()) {
12747
+ arr.sort((a, b) => timeOfDay(a) - timeOfDay(b));
12748
+ }
12696
12749
  yearCache.set(year, map);
12697
12750
  return map;
12698
12751
  }
@@ -14548,9 +14601,26 @@ function calendar(options = {}) {
14548
14601
  let candlesEv;
14549
14602
  const holidays0 = holidaysYear.get(hd.toString()) || [];
14550
14603
  const holidays = holidays0.filter(ev => ev.observedIn(il));
14604
+ // On Shabbat, events tied to the morning Torah reading and announcements
14605
+ // in synagogue come first: the parsha, special Shabbatot such as
14606
+ // Shabbat Shekalim, then the Molad and Shabbat Mevarchim
14607
+ if (options.sedrot && isSaturday) {
14608
+ const parsha0 = sedra.lookup(abs);
14609
+ if (!parsha0.chag) {
14610
+ evts.push(new ParshaEvent(parsha0));
14611
+ }
14612
+ }
14613
+ let mevarchim = isSaturday && (options.molad || options.shabbatMevarchim)
14614
+ ? makeMoladAndMevarchimChodesh(hd, options)
14615
+ : [];
14551
14616
  for (const ev of holidays) {
14617
+ if (mevarchim.length && timeOfDay(ev) > TIME_OF_DAY_MEVARCHIM) {
14618
+ evts.push(...mevarchim);
14619
+ mevarchim = [];
14620
+ }
14552
14621
  candlesEv = appendHolidayAndRelated(candlesEv, evts, ev, options, isFriday, isSaturday, hasUserMask);
14553
14622
  }
14623
+ evts.push(...mevarchim);
14554
14624
  const mm = hd.getMonth();
14555
14625
  const dd = hd.getDate();
14556
14626
  // When Erev Pesach falls on Shabbat, burning chametz is moved to Friday.
@@ -14560,12 +14630,6 @@ function calendar(options = {}) {
14560
14630
  evts.push(biurEv);
14561
14631
  }
14562
14632
  }
14563
- if (options.sedrot && isSaturday) {
14564
- const parsha0 = sedra.lookup(abs);
14565
- if (!parsha0.chag) {
14566
- evts.push(new ParshaEvent(parsha0));
14567
- }
14568
- }
14569
14633
  if (options.yizkor) {
14570
14634
  if ((mm === months.TISHREI && (dd === 10 || dd === 22)) ||
14571
14635
  (mm === NISAN && dd === (il ? 21 : 22)) ||
@@ -14592,22 +14656,6 @@ function calendar(options = {}) {
14592
14656
  const omerEv = makeOmerEvent(hd, omer, options);
14593
14657
  evts.push(omerEv);
14594
14658
  }
14595
- if (isSaturday && (options.molad || options.shabbatMevarchim)) {
14596
- const events = makeMoladAndMevarchimChodesh(hd, options);
14597
- evts.push(...events);
14598
- }
14599
- if (options.kiddushLevanaMaharil && dd >= 9 && dd <= 17) {
14600
- // The event usually falls between the 11th and the 16th, but may be
14601
- // moved back to candle-lighting before a Shabbat or Yom Tov
14602
- const monthKey = hyear * 100 + mm;
14603
- if (monthKey !== kiddushLevanaMonth) {
14604
- kiddushLevanaMonth = monthKey;
14605
- kiddushLevanaEv = makeKiddushLevanaEvent(hyear, mm, options);
14606
- }
14607
- if (kiddushLevanaEv?.getDate().abs() === abs) {
14608
- evts.push(kiddushLevanaEv);
14609
- }
14610
- }
14611
14659
  if (!candlesEv && options.candlelighting && (isFriday || isSaturday)) {
14612
14660
  candlesEv = makeCandleEvent(undefined, hd, options, isFriday, isSaturday);
14613
14661
  if (isFriday && candlesEv && sedra) {
@@ -14629,6 +14677,18 @@ function calendar(options = {}) {
14629
14677
  if (candlesEv) {
14630
14678
  evts.push(candlesEv);
14631
14679
  }
14680
+ if (options.kiddushLevanaMaharil && dd >= 9 && dd <= 17) {
14681
+ // The event usually falls between the 11th and the 16th, but may be
14682
+ // moved back to candle-lighting before a Shabbat or Yom Tov
14683
+ const monthKey = hyear * 100 + mm;
14684
+ if (monthKey !== kiddushLevanaMonth) {
14685
+ kiddushLevanaMonth = monthKey;
14686
+ kiddushLevanaEv = makeKiddushLevanaEvent(hyear, mm, options);
14687
+ }
14688
+ if (kiddushLevanaEv?.getDate().abs() === abs) {
14689
+ insertTimedEvent(evts, prevEventsLength, kiddushLevanaEv);
14690
+ }
14691
+ }
14632
14692
  if (options.addHebrewDates ||
14633
14693
  (options.addHebrewDatesForEvents &&
14634
14694
  prevEventsLength !== evts.length - numDailyLearning)) {
@@ -14934,6 +14994,23 @@ function setOptionsFromMask(options) {
14934
14994
  options.kiddushLevanaMaharil = true;
14935
14995
  return m;
14936
14996
  }
14997
+ /**
14998
+ * Inserts `ev` into today's events (those at index `start` and beyond)
14999
+ * just before the first `TimedEvent` that occurs later, or appends it.
15000
+ * Unlike other timed events, Latest Kiddush Levana may fall at dawn,
15001
+ * at candle-lighting or late at night, so its position can't be fixed.
15002
+ */
15003
+ function insertTimedEvent(events, start, ev) {
15004
+ const time = ev.eventTime.getTime();
15005
+ for (let i = start; i < events.length; i++) {
15006
+ const other = events[i];
15007
+ if (other instanceof TimedEvent && other.eventTime.getTime() > time) {
15008
+ events.splice(i, 0, ev);
15009
+ return;
15010
+ }
15011
+ }
15012
+ events.push(ev);
15013
+ }
14937
15014
  /**
14938
15015
  * Appends the Event `ev` to the `events` array. Also may add related
14939
15016
  * timed events like candle-lighting or fast start/end