@formatjs/intl-datetimeformat 6.17.1 → 6.17.2

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 (30) hide show
  1. package/lib/src/abstract/FormatDateTime.d.ts +2 -1
  2. package/lib/src/abstract/FormatDateTimePattern.d.ts +2 -1
  3. package/lib/src/abstract/FormatDateTimePattern.js +6 -1
  4. package/lib/src/abstract/FormatDateTimeRange.d.ts +2 -1
  5. package/lib/src/abstract/FormatDateTimeRangeToParts.d.ts +2 -1
  6. package/lib/src/abstract/FormatDateTimeToParts.d.ts +3 -2
  7. package/lib/src/abstract/FormatDateTimeToParts.js +1 -1
  8. package/lib/src/abstract/PartitionDateTimePattern.d.ts +3 -2
  9. package/lib/src/abstract/PartitionDateTimePattern.js +2 -4
  10. package/lib/src/abstract/PartitionDateTimeRangePattern.d.ts +2 -1
  11. package/lib/src/abstract/PartitionDateTimeRangePattern.js +2 -2
  12. package/lib/src/abstract/ToLocalTime.d.ts +2 -1
  13. package/lib/src/abstract/ToLocalTime.js +3 -4
  14. package/lib/src/core.js +13 -23
  15. package/package.json +5 -4
  16. package/polyfill.iife.js +283 -257
  17. package/src/abstract/FormatDateTime.d.ts +2 -1
  18. package/src/abstract/FormatDateTimePattern.d.ts +2 -1
  19. package/src/abstract/FormatDateTimePattern.js +7 -1
  20. package/src/abstract/FormatDateTimeRange.d.ts +2 -1
  21. package/src/abstract/FormatDateTimeRangeToParts.d.ts +2 -1
  22. package/src/abstract/FormatDateTimeToParts.d.ts +3 -2
  23. package/src/abstract/FormatDateTimeToParts.js +1 -1
  24. package/src/abstract/PartitionDateTimePattern.d.ts +3 -2
  25. package/src/abstract/PartitionDateTimePattern.js +1 -3
  26. package/src/abstract/PartitionDateTimeRangePattern.d.ts +2 -1
  27. package/src/abstract/PartitionDateTimeRangePattern.js +2 -2
  28. package/src/abstract/ToLocalTime.d.ts +2 -1
  29. package/src/abstract/ToLocalTime.js +2 -3
  30. package/src/core.js +13 -23
@@ -1,8 +1,9 @@
1
1
  import { DateTimeFormat } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  import { PartitionDateTimePattern } from './PartitionDateTimePattern';
3
4
  /**
4
5
  * https://tc39.es/ecma402/#sec-formatdatetime
5
6
  * @param dtf DateTimeFormat
6
7
  * @param x
7
8
  */
8
- export declare function FormatDateTime(dtf: Intl.DateTimeFormat | DateTimeFormat, x: number, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): string;
9
+ export declare function FormatDateTime(dtf: Intl.DateTimeFormat | DateTimeFormat, x: Decimal, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): string;
@@ -1,4 +1,5 @@
1
1
  import { DateTimeFormat, DateTimeFormatLocaleInternalData, IntlDateTimeFormatInternal, IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  import { ToLocalTimeImplDetails } from './ToLocalTime';
3
4
  export interface FormatDateTimePatternImplDetails {
4
5
  getInternalSlots(dtf: Intl.DateTimeFormat | DateTimeFormat): IntlDateTimeFormatInternal;
@@ -10,4 +11,4 @@ export interface FormatDateTimePatternImplDetails {
10
11
  * @param dtf
11
12
  * @param x
12
13
  */
13
- export declare function FormatDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, patternParts: IntlDateTimeFormatPart[], x: number, { getInternalSlots, localeData, getDefaultTimeZone, tzData, }: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
14
+ export declare function FormatDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, patternParts: IntlDateTimeFormatPart[], x: Decimal, { getInternalSlots, localeData, getDefaultTimeZone, tzData, }: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
@@ -1,4 +1,5 @@
1
1
  import { TimeClip, createMemoizedNumberFormat, } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  import { ToLocalTime } from './ToLocalTime';
3
4
  import { DATE_TIME_PROPS } from './utils';
4
5
  function pad(n) {
@@ -72,7 +73,11 @@ export function FormatDateTimePattern(dtf, patternParts, x, _a) {
72
73
  });
73
74
  }
74
75
  else if (p === 'fractionalSecondDigits') {
75
- var v = Math.floor(tm.millisecond * Math.pow(10, ((fractionalSecondDigits || 0) - 3)));
76
+ var v = new Decimal(tm.millisecond)
77
+ .times(10)
78
+ .pow((fractionalSecondDigits || 0) - 3)
79
+ .floor()
80
+ .toNumber();
76
81
  result.push({
77
82
  type: 'fractionalSecond',
78
83
  value: nf3.format(v),
@@ -1,3 +1,4 @@
1
+ import Decimal from 'decimal.js';
1
2
  import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
2
3
  import { ToLocalTimeImplDetails } from './ToLocalTime';
3
- export declare function FormatDateTimeRange(dtf: Intl.DateTimeFormat, x: number, y: number, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): string;
4
+ export declare function FormatDateTimeRange(dtf: Intl.DateTimeFormat, x: Decimal, y: Decimal, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): string;
@@ -1,4 +1,5 @@
1
1
  import { IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
+ import { Decimal } from 'decimal.js';
2
3
  import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
3
4
  import { ToLocalTimeImplDetails } from './ToLocalTime';
4
- export declare function FormatDateTimeRangeToParts(dtf: Intl.DateTimeFormat, x: number, y: number, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
5
+ export declare function FormatDateTimeRangeToParts(dtf: Intl.DateTimeFormat, x: Decimal, y: Decimal, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
@@ -1,5 +1,6 @@
1
- import { PartitionDateTimePattern } from './PartitionDateTimePattern';
2
1
  import { IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
3
+ import { PartitionDateTimePattern } from './PartitionDateTimePattern';
3
4
  /**
4
5
  * https://tc39.es/ecma402/#sec-formatdatetimetoparts
5
6
  *
@@ -7,4 +8,4 @@ import { IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
7
8
  * @param x
8
9
  * @param implDetails
9
10
  */
10
- export declare function FormatDateTimeToParts(dtf: Intl.DateTimeFormat, x: number, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): IntlDateTimeFormatPart[];
11
+ export declare function FormatDateTimeToParts(dtf: Intl.DateTimeFormat, x: Decimal, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): IntlDateTimeFormatPart[];
@@ -1,5 +1,5 @@
1
- import { PartitionDateTimePattern } from './PartitionDateTimePattern';
2
1
  import { ArrayCreate } from '@formatjs/ecma402-abstract';
2
+ import { PartitionDateTimePattern } from './PartitionDateTimePattern';
3
3
  /**
4
4
  * https://tc39.es/ecma402/#sec-formatdatetimetoparts
5
5
  *
@@ -1,9 +1,10 @@
1
1
  import { DateTimeFormat, IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
- import { ToLocalTimeImplDetails } from './ToLocalTime';
2
+ import Decimal from 'decimal.js';
3
3
  import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
4
+ import { ToLocalTimeImplDetails } from './ToLocalTime';
4
5
  /**
5
6
  * https://tc39.es/ecma402/#sec-partitiondatetimepattern
6
7
  * @param dtf
7
8
  * @param x
8
9
  */
9
- export declare function PartitionDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, x: number, implDetails: ToLocalTimeImplDetails & FormatDateTimePatternImplDetails): IntlDateTimeFormatPart[];
10
+ export declare function PartitionDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, x: Decimal, implDetails: ToLocalTimeImplDetails & FormatDateTimePatternImplDetails): IntlDateTimeFormatPart[];
@@ -1,4 +1,4 @@
1
- import { PartitionPattern, TimeClip, } from '@formatjs/ecma402-abstract';
1
+ import { invariant, PartitionPattern, TimeClip, } from '@formatjs/ecma402-abstract';
2
2
  import { FormatDateTimePattern, } from './FormatDateTimePattern';
3
3
  /**
4
4
  * https://tc39.es/ecma402/#sec-partitiondatetimepattern
@@ -7,9 +7,7 @@ import { FormatDateTimePattern, } from './FormatDateTimePattern';
7
7
  */
8
8
  export function PartitionDateTimePattern(dtf, x, implDetails) {
9
9
  x = TimeClip(x);
10
- if (isNaN(x)) {
11
- throw new RangeError('invalid time');
12
- }
10
+ invariant(!x.isNaN(), 'Invalid time', RangeError);
13
11
  /** IMPL START */
14
12
  var getInternalSlots = implDetails.getInternalSlots;
15
13
  var internalSlots = getInternalSlots(dtf);
@@ -1,4 +1,5 @@
1
1
  import { IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
3
4
  import { ToLocalTimeImplDetails } from './ToLocalTime';
4
- export declare function PartitionDateTimeRangePattern(dtf: Intl.DateTimeFormat, x: number, y: number, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
5
+ export declare function PartitionDateTimeRangePattern(dtf: Intl.DateTimeFormat, x: Decimal, y: Decimal, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
@@ -15,11 +15,11 @@ var TABLE_2_FIELDS = [
15
15
  ];
16
16
  export function PartitionDateTimeRangePattern(dtf, x, y, implDetails) {
17
17
  x = TimeClip(x);
18
- if (isNaN(x)) {
18
+ if (x.isNaN()) {
19
19
  throw new RangeError('Invalid start time');
20
20
  }
21
21
  y = TimeClip(y);
22
- if (isNaN(y)) {
22
+ if (y.isNaN()) {
23
23
  throw new RangeError('Invalid end time');
24
24
  }
25
25
  /** IMPL START */
@@ -1,4 +1,5 @@
1
1
  import { UnpackedZoneData } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  export interface ToLocalTimeImplDetails {
3
4
  tzData: Record<string, UnpackedZoneData[]>;
4
5
  }
@@ -8,7 +9,7 @@ export interface ToLocalTimeImplDetails {
8
9
  * @param calendar
9
10
  * @param timeZone
10
11
  */
11
- export declare function ToLocalTime(t: number, calendar: string, timeZone: string, { tzData }: ToLocalTimeImplDetails): {
12
+ export declare function ToLocalTime(t: Decimal, calendar: string, timeZone: string, { tzData }: ToLocalTimeImplDetails): {
12
13
  weekday: number;
13
14
  era: string;
14
15
  year: number;
@@ -1,4 +1,4 @@
1
- import { Type, YearFromTime, WeekDay, MonthFromTime, DateFromTime, HourFromTime, MinFromTime, SecFromTime, msFromTime, invariant, } from '@formatjs/ecma402-abstract';
1
+ import { DateFromTime, HourFromTime, MinFromTime, MonthFromTime, SecFromTime, WeekDay, YearFromTime, invariant, msFromTime, } from '@formatjs/ecma402-abstract';
2
2
  function getApplicableZoneData(t, timeZone, tzData) {
3
3
  var _a;
4
4
  var zoneData = tzData[timeZone];
@@ -26,10 +26,9 @@ function getApplicableZoneData(t, timeZone, tzData) {
26
26
  */
27
27
  export function ToLocalTime(t, calendar, timeZone, _a) {
28
28
  var tzData = _a.tzData;
29
- invariant(Type(t) === 'Number', 'invalid time');
30
29
  invariant(calendar === 'gregory', 'We only support Gregory calendar right now');
31
- var _b = getApplicableZoneData(t, timeZone, tzData), timeZoneOffset = _b[0], inDST = _b[1];
32
- var tz = t + timeZoneOffset;
30
+ var _b = getApplicableZoneData(t.toNumber(), timeZone, tzData), timeZoneOffset = _b[0], inDST = _b[1];
31
+ var tz = t.plus(timeZoneOffset).toNumber();
33
32
  var year = YearFromTime(tz);
34
33
  return {
35
34
  weekday: WeekDay(tz),
package/lib/src/core.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { __assign, __rest } from "tslib";
2
2
  import { CanonicalizeLocaleList, CanonicalizeTimeZoneName, IsValidTimeZoneName, OrdinaryHasInstance, SupportedLocales, ToNumber, defineProperty, invariant, } from '@formatjs/ecma402-abstract';
3
+ import Decimal from 'decimal.js';
3
4
  import { FormatDateTime } from './abstract/FormatDateTime';
4
5
  import { FormatDateTimeRange } from './abstract/FormatDateTimeRange';
5
6
  import { FormatDateTimeRangeToParts } from './abstract/FormatDateTimeRangeToParts';
@@ -49,10 +50,10 @@ var formatDescriptor = {
49
50
  boundFormat = function (date) {
50
51
  var x;
51
52
  if (date === undefined) {
52
- x = Date.now();
53
+ x = new Decimal(Date.now());
53
54
  }
54
55
  else {
55
- x = Number(date);
56
+ x = ToNumber(date);
56
57
  }
57
58
  return FormatDateTime(dtf, x, {
58
59
  getInternalSlots: getInternalSlots,
@@ -156,13 +157,14 @@ defineProperty(DateTimeFormat.prototype, 'resolvedOptions', {
156
157
  });
157
158
  defineProperty(DateTimeFormat.prototype, 'formatToParts', {
158
159
  value: function formatToParts(date) {
160
+ var x;
159
161
  if (date === undefined) {
160
- date = Date.now();
162
+ x = new Decimal(Date.now());
161
163
  }
162
164
  else {
163
- date = ToNumber(date).toNumber();
165
+ x = ToNumber(date);
164
166
  }
165
- return FormatDateTimeToParts(this, date, {
167
+ return FormatDateTimeToParts(this, x, {
166
168
  getInternalSlots: getInternalSlots,
167
169
  localeData: DateTimeFormat.localeData,
168
170
  tzData: DateTimeFormat.tzData,
@@ -173,15 +175,9 @@ defineProperty(DateTimeFormat.prototype, 'formatToParts', {
173
175
  defineProperty(DateTimeFormat.prototype, 'formatRangeToParts', {
174
176
  value: function formatRangeToParts(startDate, endDate) {
175
177
  var dtf = this;
176
- if (typeof dtf !== 'object') {
177
- throw new TypeError();
178
- }
179
- if (startDate === undefined || endDate === undefined) {
180
- throw new TypeError('startDate/endDate cannot be undefined');
181
- }
182
- var x = ToNumber(startDate).toNumber();
183
- var y = ToNumber(endDate).toNumber();
184
- return FormatDateTimeRangeToParts(dtf, x, y, {
178
+ invariant(typeof dtf === 'object', 'receiver is not an object', TypeError);
179
+ invariant(startDate !== undefined && endDate !== undefined, 'startDate/endDate cannot be undefined', TypeError);
180
+ return FormatDateTimeRangeToParts(dtf, ToNumber(startDate), ToNumber(endDate), {
185
181
  getInternalSlots: getInternalSlots,
186
182
  localeData: DateTimeFormat.localeData,
187
183
  tzData: DateTimeFormat.tzData,
@@ -192,15 +188,9 @@ defineProperty(DateTimeFormat.prototype, 'formatRangeToParts', {
192
188
  defineProperty(DateTimeFormat.prototype, 'formatRange', {
193
189
  value: function formatRange(startDate, endDate) {
194
190
  var dtf = this;
195
- if (typeof dtf !== 'object') {
196
- throw new TypeError();
197
- }
198
- if (startDate === undefined || endDate === undefined) {
199
- throw new TypeError('startDate/endDate cannot be undefined');
200
- }
201
- var x = ToNumber(startDate).toNumber();
202
- var y = ToNumber(endDate).toNumber();
203
- return FormatDateTimeRange(dtf, x, y, {
191
+ invariant(typeof dtf === 'object', 'receiver is not an object', TypeError);
192
+ invariant(startDate !== undefined && endDate !== undefined, 'startDate/endDate cannot be undefined', TypeError);
193
+ return FormatDateTimeRange(dtf, ToNumber(startDate), ToNumber(endDate), {
204
194
  getInternalSlots: getInternalSlots,
205
195
  localeData: DateTimeFormat.localeData,
206
196
  tzData: DateTimeFormat.tzData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-datetimeformat",
3
- "version": "6.17.1",
3
+ "version": "6.17.2",
4
4
  "description": "Intl.DateTimeFormat polyfill",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -22,12 +22,13 @@
22
22
  },
23
23
  "homepage": "https://github.com/formatjs/formatjs#readme",
24
24
  "dependencies": {
25
+ "decimal.js": "10",
25
26
  "tslib": "2",
26
- "@formatjs/ecma402-abstract": "2.3.1",
27
- "@formatjs/intl-localematcher": "0.5.9"
27
+ "@formatjs/ecma402-abstract": "2.3.2",
28
+ "@formatjs/intl-localematcher": "0.5.10"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@formatjs/intl-getcanonicallocales": "2.5.4",
31
- "@formatjs/intl-locale": "4.2.8"
32
+ "@formatjs/intl-locale": "4.2.9"
32
33
  }
33
34
  }
package/polyfill.iife.js CHANGED
@@ -2407,6 +2407,180 @@
2407
2407
  var ZERO = new decimal_default(0);
2408
2408
  var NEGATIVE_ZERO = new decimal_default(-0);
2409
2409
 
2410
+ // node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
2411
+ var extendStatics = function(d, b) {
2412
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2413
+ d2.__proto__ = b2;
2414
+ } || function(d2, b2) {
2415
+ for (var p in b2)
2416
+ if (Object.prototype.hasOwnProperty.call(b2, p))
2417
+ d2[p] = b2[p];
2418
+ };
2419
+ return extendStatics(d, b);
2420
+ };
2421
+ function __extends(d, b) {
2422
+ if (typeof b !== "function" && b !== null)
2423
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2424
+ extendStatics(d, b);
2425
+ function __() {
2426
+ this.constructor = d;
2427
+ }
2428
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2429
+ }
2430
+ function __spreadArray(to, from, pack) {
2431
+ if (pack || arguments.length === 2)
2432
+ for (var i = 0, l = from.length, ar; i < l; i++) {
2433
+ if (ar || !(i in from)) {
2434
+ if (!ar)
2435
+ ar = Array.prototype.slice.call(from, 0, i);
2436
+ ar[i] = from[i];
2437
+ }
2438
+ }
2439
+ return to.concat(ar || Array.prototype.slice.call(from));
2440
+ }
2441
+
2442
+ // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/lib/index.js
2443
+ function memoize(fn, options) {
2444
+ var cache = options && options.cache ? options.cache : cacheDefault;
2445
+ var serializer = options && options.serializer ? options.serializer : serializerDefault;
2446
+ var strategy = options && options.strategy ? options.strategy : strategyDefault;
2447
+ return strategy(fn, {
2448
+ cache,
2449
+ serializer
2450
+ });
2451
+ }
2452
+ function isPrimitive(value) {
2453
+ return value == null || typeof value === "number" || typeof value === "boolean";
2454
+ }
2455
+ function monadic(fn, cache, serializer, arg) {
2456
+ var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
2457
+ var computedValue = cache.get(cacheKey);
2458
+ if (typeof computedValue === "undefined") {
2459
+ computedValue = fn.call(this, arg);
2460
+ cache.set(cacheKey, computedValue);
2461
+ }
2462
+ return computedValue;
2463
+ }
2464
+ function variadic(fn, cache, serializer) {
2465
+ var args = Array.prototype.slice.call(arguments, 3);
2466
+ var cacheKey = serializer(args);
2467
+ var computedValue = cache.get(cacheKey);
2468
+ if (typeof computedValue === "undefined") {
2469
+ computedValue = fn.apply(this, args);
2470
+ cache.set(cacheKey, computedValue);
2471
+ }
2472
+ return computedValue;
2473
+ }
2474
+ function assemble(fn, context, strategy, cache, serialize) {
2475
+ return strategy.bind(context, fn, cache, serialize);
2476
+ }
2477
+ function strategyDefault(fn, options) {
2478
+ var strategy = fn.length === 1 ? monadic : variadic;
2479
+ return assemble(fn, this, strategy, options.cache.create(), options.serializer);
2480
+ }
2481
+ function strategyVariadic(fn, options) {
2482
+ return assemble(fn, this, variadic, options.cache.create(), options.serializer);
2483
+ }
2484
+ function strategyMonadic(fn, options) {
2485
+ return assemble(fn, this, monadic, options.cache.create(), options.serializer);
2486
+ }
2487
+ var serializerDefault = function() {
2488
+ return JSON.stringify(arguments);
2489
+ };
2490
+ var ObjectWithoutPrototypeCache = (
2491
+ /** @class */
2492
+ function() {
2493
+ function ObjectWithoutPrototypeCache2() {
2494
+ this.cache = /* @__PURE__ */ Object.create(null);
2495
+ }
2496
+ ObjectWithoutPrototypeCache2.prototype.get = function(key) {
2497
+ return this.cache[key];
2498
+ };
2499
+ ObjectWithoutPrototypeCache2.prototype.set = function(key, value) {
2500
+ this.cache[key] = value;
2501
+ };
2502
+ return ObjectWithoutPrototypeCache2;
2503
+ }()
2504
+ );
2505
+ var cacheDefault = {
2506
+ create: function create() {
2507
+ return new ObjectWithoutPrototypeCache();
2508
+ }
2509
+ };
2510
+ var strategies = {
2511
+ variadic: strategyVariadic,
2512
+ monadic: strategyMonadic
2513
+ };
2514
+
2515
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/utils.js
2516
+ function defineProperty(target, name, _a) {
2517
+ var value = _a.value;
2518
+ Object.defineProperty(target, name, {
2519
+ configurable: true,
2520
+ enumerable: false,
2521
+ writable: true,
2522
+ value
2523
+ });
2524
+ }
2525
+ function invariant(condition, message, Err) {
2526
+ if (Err === void 0) {
2527
+ Err = Error;
2528
+ }
2529
+ if (!condition) {
2530
+ throw new Err(message);
2531
+ }
2532
+ }
2533
+ var createMemoizedNumberFormat = memoize(function() {
2534
+ var _a;
2535
+ var args = [];
2536
+ for (var _i = 0; _i < arguments.length; _i++) {
2537
+ args[_i] = arguments[_i];
2538
+ }
2539
+ return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2540
+ }, {
2541
+ strategy: strategies.variadic
2542
+ });
2543
+ var createMemoizedDateTimeFormat = memoize(function() {
2544
+ var _a;
2545
+ var args = [];
2546
+ for (var _i = 0; _i < arguments.length; _i++) {
2547
+ args[_i] = arguments[_i];
2548
+ }
2549
+ return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2550
+ }, {
2551
+ strategy: strategies.variadic
2552
+ });
2553
+ var createMemoizedPluralRules = memoize(function() {
2554
+ var _a;
2555
+ var args = [];
2556
+ for (var _i = 0; _i < arguments.length; _i++) {
2557
+ args[_i] = arguments[_i];
2558
+ }
2559
+ return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))();
2560
+ }, {
2561
+ strategy: strategies.variadic
2562
+ });
2563
+ var createMemoizedLocale = memoize(function() {
2564
+ var _a;
2565
+ var args = [];
2566
+ for (var _i = 0; _i < arguments.length; _i++) {
2567
+ args[_i] = arguments[_i];
2568
+ }
2569
+ return new ((_a = Intl.Locale).bind.apply(_a, __spreadArray([void 0], args, false)))();
2570
+ }, {
2571
+ strategy: strategies.variadic
2572
+ });
2573
+ var createMemoizedListFormat = memoize(function() {
2574
+ var _a;
2575
+ var args = [];
2576
+ for (var _i = 0; _i < arguments.length; _i++) {
2577
+ args[_i] = arguments[_i];
2578
+ }
2579
+ return new ((_a = Intl.ListFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2580
+ }, {
2581
+ strategy: strategies.variadic
2582
+ });
2583
+
2410
2584
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/262.js
2411
2585
  function ToString(o) {
2412
2586
  if (typeof o === "symbol") {
@@ -2414,20 +2588,31 @@
2414
2588
  }
2415
2589
  return String(o);
2416
2590
  }
2417
- function ToNumber(val) {
2418
- if (val === void 0) {
2591
+ function ToNumber(arg) {
2592
+ if (typeof arg === "number") {
2593
+ return new Decimal(arg);
2594
+ }
2595
+ invariant(typeof arg !== "bigint" && typeof arg !== "symbol", "BigInt and Symbol are not supported", TypeError);
2596
+ if (arg === void 0) {
2419
2597
  return new Decimal(NaN);
2420
2598
  }
2421
- if (val === null) {
2599
+ if (arg === null || arg === 0) {
2422
2600
  return ZERO;
2423
2601
  }
2424
- if (typeof val === "boolean") {
2425
- return new Decimal(val ? 1 : 0);
2602
+ if (arg === true) {
2603
+ return new Decimal(1);
2426
2604
  }
2427
- if (typeof val === "symbol" || typeof val === "bigint") {
2428
- throw new TypeError("Cannot convert symbol/bigint to number");
2605
+ if (typeof arg === "string") {
2606
+ try {
2607
+ return new Decimal(arg);
2608
+ } catch (e) {
2609
+ return new Decimal(NaN);
2610
+ }
2429
2611
  }
2430
- return new Decimal(Number(val));
2612
+ invariant(typeof arg === "object", "object expected", TypeError);
2613
+ var primValue = ToPrimitive(arg, "number");
2614
+ invariant(typeof primValue !== "object", "object expected", TypeError);
2615
+ return ToNumber(primValue);
2431
2616
  }
2432
2617
  function ToInteger(n) {
2433
2618
  var number = ToNumber(n);
@@ -2444,13 +2629,13 @@
2444
2629
  return integer;
2445
2630
  }
2446
2631
  function TimeClip(time) {
2447
- if (!isFinite(time)) {
2448
- return NaN;
2632
+ if (!time.isFinite()) {
2633
+ return new Decimal(NaN);
2449
2634
  }
2450
- if (Math.abs(time) > 8.64 * 1e15) {
2451
- return NaN;
2635
+ if (time.abs().greaterThan(8.64 * 1e15)) {
2636
+ return new Decimal(NaN);
2452
2637
  }
2453
- return ToInteger(time).toNumber();
2638
+ return ToInteger(time);
2454
2639
  }
2455
2640
  function ToObject(arg) {
2456
2641
  if (arg == null) {
@@ -2470,32 +2655,6 @@
2470
2655
  function ArrayCreate(len) {
2471
2656
  return new Array(len);
2472
2657
  }
2473
- function Type(x) {
2474
- if (x === null) {
2475
- return "Null";
2476
- }
2477
- if (typeof x === "undefined") {
2478
- return "Undefined";
2479
- }
2480
- if (typeof x === "function" || typeof x === "object") {
2481
- return "Object";
2482
- }
2483
- if (typeof x === "number") {
2484
- return "Number";
2485
- }
2486
- if (typeof x === "boolean") {
2487
- return "Boolean";
2488
- }
2489
- if (typeof x === "string") {
2490
- return "String";
2491
- }
2492
- if (typeof x === "symbol") {
2493
- return "Symbol";
2494
- }
2495
- if (typeof x === "bigint") {
2496
- return "BigInt";
2497
- }
2498
- }
2499
2658
  var MS_PER_DAY = 864e5;
2500
2659
  function mod2(x, y) {
2501
2660
  return x - Math.floor(x / y) * y;
@@ -2651,6 +2810,51 @@
2651
2810
  function msFromTime(t) {
2652
2811
  return mod2(t, MS_PER_SECOND);
2653
2812
  }
2813
+ function OrdinaryToPrimitive(O, hint) {
2814
+ var methodNames;
2815
+ if (hint === "string") {
2816
+ methodNames = ["toString", "valueOf"];
2817
+ } else {
2818
+ methodNames = ["valueOf", "toString"];
2819
+ }
2820
+ for (var _i = 0, methodNames_1 = methodNames; _i < methodNames_1.length; _i++) {
2821
+ var name_1 = methodNames_1[_i];
2822
+ var method = O[name_1];
2823
+ if (IsCallable(method)) {
2824
+ var result = method.call(O);
2825
+ if (typeof result !== "object") {
2826
+ return result;
2827
+ }
2828
+ }
2829
+ }
2830
+ throw new TypeError("Cannot convert object to primitive value");
2831
+ }
2832
+ function ToPrimitive(input, preferredType) {
2833
+ if (typeof input === "object" && input != null) {
2834
+ var exoticToPrim = Symbol.toPrimitive in input ? input[Symbol.toPrimitive] : void 0;
2835
+ var hint = void 0;
2836
+ if (exoticToPrim !== void 0) {
2837
+ if (preferredType === void 0) {
2838
+ hint = "default";
2839
+ } else if (preferredType === "string") {
2840
+ hint = "string";
2841
+ } else {
2842
+ invariant(preferredType === "number", 'preferredType must be "string" or "number"');
2843
+ hint = "number";
2844
+ }
2845
+ var result = exoticToPrim.call(input, hint);
2846
+ if (typeof result !== "object") {
2847
+ return result;
2848
+ }
2849
+ throw new TypeError("Cannot convert exotic object to primitive.");
2850
+ }
2851
+ if (preferredType === void 0) {
2852
+ preferredType = "number";
2853
+ }
2854
+ return OrdinaryToPrimitive(input, preferredType);
2855
+ }
2856
+ return input;
2857
+ }
2654
2858
 
2655
2859
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/DefaultNumberOption.js
2656
2860
  function DefaultNumberOption(inputVal, min2, max2, fallback) {
@@ -2765,180 +2969,6 @@
2765
2969
  return zoneNames.has(uppercasedTz) || linkNames.has(uppercasedTz);
2766
2970
  }
2767
2971
 
2768
- // node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
2769
- var extendStatics = function(d, b) {
2770
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2771
- d2.__proto__ = b2;
2772
- } || function(d2, b2) {
2773
- for (var p in b2)
2774
- if (Object.prototype.hasOwnProperty.call(b2, p))
2775
- d2[p] = b2[p];
2776
- };
2777
- return extendStatics(d, b);
2778
- };
2779
- function __extends(d, b) {
2780
- if (typeof b !== "function" && b !== null)
2781
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2782
- extendStatics(d, b);
2783
- function __() {
2784
- this.constructor = d;
2785
- }
2786
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2787
- }
2788
- function __spreadArray(to, from, pack) {
2789
- if (pack || arguments.length === 2)
2790
- for (var i = 0, l = from.length, ar; i < l; i++) {
2791
- if (ar || !(i in from)) {
2792
- if (!ar)
2793
- ar = Array.prototype.slice.call(from, 0, i);
2794
- ar[i] = from[i];
2795
- }
2796
- }
2797
- return to.concat(ar || Array.prototype.slice.call(from));
2798
- }
2799
-
2800
- // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/lib/index.js
2801
- function memoize(fn, options) {
2802
- var cache = options && options.cache ? options.cache : cacheDefault;
2803
- var serializer = options && options.serializer ? options.serializer : serializerDefault;
2804
- var strategy = options && options.strategy ? options.strategy : strategyDefault;
2805
- return strategy(fn, {
2806
- cache,
2807
- serializer
2808
- });
2809
- }
2810
- function isPrimitive(value) {
2811
- return value == null || typeof value === "number" || typeof value === "boolean";
2812
- }
2813
- function monadic(fn, cache, serializer, arg) {
2814
- var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
2815
- var computedValue = cache.get(cacheKey);
2816
- if (typeof computedValue === "undefined") {
2817
- computedValue = fn.call(this, arg);
2818
- cache.set(cacheKey, computedValue);
2819
- }
2820
- return computedValue;
2821
- }
2822
- function variadic(fn, cache, serializer) {
2823
- var args = Array.prototype.slice.call(arguments, 3);
2824
- var cacheKey = serializer(args);
2825
- var computedValue = cache.get(cacheKey);
2826
- if (typeof computedValue === "undefined") {
2827
- computedValue = fn.apply(this, args);
2828
- cache.set(cacheKey, computedValue);
2829
- }
2830
- return computedValue;
2831
- }
2832
- function assemble(fn, context, strategy, cache, serialize) {
2833
- return strategy.bind(context, fn, cache, serialize);
2834
- }
2835
- function strategyDefault(fn, options) {
2836
- var strategy = fn.length === 1 ? monadic : variadic;
2837
- return assemble(fn, this, strategy, options.cache.create(), options.serializer);
2838
- }
2839
- function strategyVariadic(fn, options) {
2840
- return assemble(fn, this, variadic, options.cache.create(), options.serializer);
2841
- }
2842
- function strategyMonadic(fn, options) {
2843
- return assemble(fn, this, monadic, options.cache.create(), options.serializer);
2844
- }
2845
- var serializerDefault = function() {
2846
- return JSON.stringify(arguments);
2847
- };
2848
- var ObjectWithoutPrototypeCache = (
2849
- /** @class */
2850
- function() {
2851
- function ObjectWithoutPrototypeCache2() {
2852
- this.cache = /* @__PURE__ */ Object.create(null);
2853
- }
2854
- ObjectWithoutPrototypeCache2.prototype.get = function(key) {
2855
- return this.cache[key];
2856
- };
2857
- ObjectWithoutPrototypeCache2.prototype.set = function(key, value) {
2858
- this.cache[key] = value;
2859
- };
2860
- return ObjectWithoutPrototypeCache2;
2861
- }()
2862
- );
2863
- var cacheDefault = {
2864
- create: function create() {
2865
- return new ObjectWithoutPrototypeCache();
2866
- }
2867
- };
2868
- var strategies = {
2869
- variadic: strategyVariadic,
2870
- monadic: strategyMonadic
2871
- };
2872
-
2873
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/utils.js
2874
- function defineProperty(target, name, _a) {
2875
- var value = _a.value;
2876
- Object.defineProperty(target, name, {
2877
- configurable: true,
2878
- enumerable: false,
2879
- writable: true,
2880
- value
2881
- });
2882
- }
2883
- function invariant(condition, message, Err) {
2884
- if (Err === void 0) {
2885
- Err = Error;
2886
- }
2887
- if (!condition) {
2888
- throw new Err(message);
2889
- }
2890
- }
2891
- var createMemoizedNumberFormat = memoize(function() {
2892
- var _a;
2893
- var args = [];
2894
- for (var _i = 0; _i < arguments.length; _i++) {
2895
- args[_i] = arguments[_i];
2896
- }
2897
- return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2898
- }, {
2899
- strategy: strategies.variadic
2900
- });
2901
- var createMemoizedDateTimeFormat = memoize(function() {
2902
- var _a;
2903
- var args = [];
2904
- for (var _i = 0; _i < arguments.length; _i++) {
2905
- args[_i] = arguments[_i];
2906
- }
2907
- return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2908
- }, {
2909
- strategy: strategies.variadic
2910
- });
2911
- var createMemoizedPluralRules = memoize(function() {
2912
- var _a;
2913
- var args = [];
2914
- for (var _i = 0; _i < arguments.length; _i++) {
2915
- args[_i] = arguments[_i];
2916
- }
2917
- return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))();
2918
- }, {
2919
- strategy: strategies.variadic
2920
- });
2921
- var createMemoizedLocale = memoize(function() {
2922
- var _a;
2923
- var args = [];
2924
- for (var _i = 0; _i < arguments.length; _i++) {
2925
- args[_i] = arguments[_i];
2926
- }
2927
- return new ((_a = Intl.Locale).bind.apply(_a, __spreadArray([void 0], args, false)))();
2928
- }, {
2929
- strategy: strategies.variadic
2930
- });
2931
- var createMemoizedListFormat = memoize(function() {
2932
- var _a;
2933
- var args = [];
2934
- for (var _i = 0; _i < arguments.length; _i++) {
2935
- args[_i] = arguments[_i];
2936
- }
2937
- return new ((_a = Intl.ListFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2938
- }, {
2939
- strategy: strategies.variadic
2940
- });
2941
-
2942
2972
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ComputeExponentForMagnitude.js
2943
2973
  decimal_default.set({
2944
2974
  toExpPos: 100
@@ -2949,11 +2979,6 @@
2949
2979
  toExpPos: 100
2950
2980
  });
2951
2981
 
2952
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ToRawPrecision.js
2953
- decimal_default.set({
2954
- toExpPos: 100
2955
- });
2956
-
2957
2982
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/regex.generated.js
2958
2983
  var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
2959
2984
 
@@ -7419,13 +7444,16 @@
7419
7444
  return [offset * 1e3, dst];
7420
7445
  }
7421
7446
  function ToLocalTime(t, calendar, timeZone, { tzData }) {
7422
- invariant(Type(t) === "Number", "invalid time");
7423
7447
  invariant(
7424
7448
  calendar === "gregory",
7425
7449
  "We only support Gregory calendar right now"
7426
7450
  );
7427
- const [timeZoneOffset, inDST] = getApplicableZoneData(t, timeZone, tzData);
7428
- const tz = t + timeZoneOffset;
7451
+ const [timeZoneOffset, inDST] = getApplicableZoneData(
7452
+ t.toNumber(),
7453
+ timeZone,
7454
+ tzData
7455
+ );
7456
+ const tz = t.plus(timeZoneOffset).toNumber();
7429
7457
  const year = YearFromTime(tz);
7430
7458
  return {
7431
7459
  weekday: WeekDay(tz),
@@ -7534,9 +7562,7 @@
7534
7562
  value: patternPart.value
7535
7563
  });
7536
7564
  } else if (p === "fractionalSecondDigits") {
7537
- const v = Math.floor(
7538
- tm.millisecond * __pow(10, (fractionalSecondDigits || 0) - 3)
7539
- );
7565
+ const v = new decimal_default(tm.millisecond).times(10).pow((fractionalSecondDigits || 0) - 3).floor().toNumber();
7540
7566
  result.push({
7541
7567
  type: "fractionalSecond",
7542
7568
  value: nf3.format(v)
@@ -7640,9 +7666,7 @@
7640
7666
  // packages/intl-datetimeformat/src/abstract/PartitionDateTimePattern.ts
7641
7667
  function PartitionDateTimePattern(dtf, x, implDetails) {
7642
7668
  x = TimeClip(x);
7643
- if (isNaN(x)) {
7644
- throw new RangeError("invalid time");
7645
- }
7669
+ invariant(!x.isNaN(), "Invalid time", RangeError);
7646
7670
  const { getInternalSlots: getInternalSlots2 } = implDetails;
7647
7671
  const internalSlots = getInternalSlots2(dtf);
7648
7672
  const { pattern } = internalSlots;
@@ -7679,11 +7703,11 @@
7679
7703
  ];
7680
7704
  function PartitionDateTimeRangePattern(dtf, x, y, implDetails) {
7681
7705
  x = TimeClip(x);
7682
- if (isNaN(x)) {
7706
+ if (x.isNaN()) {
7683
7707
  throw new RangeError("Invalid start time");
7684
7708
  }
7685
7709
  y = TimeClip(y);
7686
- if (isNaN(y)) {
7710
+ if (y.isNaN()) {
7687
7711
  throw new RangeError("Invalid end time");
7688
7712
  }
7689
7713
  const { getInternalSlots: getInternalSlots2, tzData } = implDetails;
@@ -8954,9 +8978,9 @@
8954
8978
  boundFormat = (date) => {
8955
8979
  let x;
8956
8980
  if (date === void 0) {
8957
- x = Date.now();
8981
+ x = new decimal_default(Date.now());
8958
8982
  } else {
8959
- x = Number(date);
8983
+ x = ToNumber(date);
8960
8984
  }
8961
8985
  return FormatDateTime(dtf, x, {
8962
8986
  getInternalSlots,
@@ -9050,12 +9074,13 @@
9050
9074
  });
9051
9075
  defineProperty(DateTimeFormat4.prototype, "formatToParts", {
9052
9076
  value: function formatToParts2(date) {
9077
+ let x;
9053
9078
  if (date === void 0) {
9054
- date = Date.now();
9079
+ x = new decimal_default(Date.now());
9055
9080
  } else {
9056
- date = ToNumber(date).toNumber();
9081
+ x = ToNumber(date);
9057
9082
  }
9058
- return FormatDateTimeToParts(this, date, {
9083
+ return FormatDateTimeToParts(this, x, {
9059
9084
  getInternalSlots,
9060
9085
  localeData: DateTimeFormat4.localeData,
9061
9086
  tzData: DateTimeFormat4.tzData,
@@ -9066,34 +9091,35 @@
9066
9091
  defineProperty(DateTimeFormat4.prototype, "formatRangeToParts", {
9067
9092
  value: function formatRangeToParts(startDate, endDate) {
9068
9093
  const dtf = this;
9069
- if (typeof dtf !== "object") {
9070
- throw new TypeError();
9071
- }
9072
- if (startDate === void 0 || endDate === void 0) {
9073
- throw new TypeError("startDate/endDate cannot be undefined");
9074
- }
9075
- const x = ToNumber(startDate).toNumber();
9076
- const y = ToNumber(endDate).toNumber();
9077
- return FormatDateTimeRangeToParts(dtf, x, y, {
9078
- getInternalSlots,
9079
- localeData: DateTimeFormat4.localeData,
9080
- tzData: DateTimeFormat4.tzData,
9081
- getDefaultTimeZone: DateTimeFormat4.getDefaultTimeZone
9082
- });
9094
+ invariant(typeof dtf === "object", "receiver is not an object", TypeError);
9095
+ invariant(
9096
+ startDate !== void 0 && endDate !== void 0,
9097
+ "startDate/endDate cannot be undefined",
9098
+ TypeError
9099
+ );
9100
+ return FormatDateTimeRangeToParts(
9101
+ dtf,
9102
+ ToNumber(startDate),
9103
+ ToNumber(endDate),
9104
+ {
9105
+ getInternalSlots,
9106
+ localeData: DateTimeFormat4.localeData,
9107
+ tzData: DateTimeFormat4.tzData,
9108
+ getDefaultTimeZone: DateTimeFormat4.getDefaultTimeZone
9109
+ }
9110
+ );
9083
9111
  }
9084
9112
  });
9085
9113
  defineProperty(DateTimeFormat4.prototype, "formatRange", {
9086
9114
  value: function formatRange(startDate, endDate) {
9087
9115
  const dtf = this;
9088
- if (typeof dtf !== "object") {
9089
- throw new TypeError();
9090
- }
9091
- if (startDate === void 0 || endDate === void 0) {
9092
- throw new TypeError("startDate/endDate cannot be undefined");
9093
- }
9094
- const x = ToNumber(startDate).toNumber();
9095
- const y = ToNumber(endDate).toNumber();
9096
- return FormatDateTimeRange(dtf, x, y, {
9116
+ invariant(typeof dtf === "object", "receiver is not an object", TypeError);
9117
+ invariant(
9118
+ startDate !== void 0 && endDate !== void 0,
9119
+ "startDate/endDate cannot be undefined",
9120
+ TypeError
9121
+ );
9122
+ return FormatDateTimeRange(dtf, ToNumber(startDate), ToNumber(endDate), {
9097
9123
  getInternalSlots,
9098
9124
  localeData: DateTimeFormat4.localeData,
9099
9125
  tzData: DateTimeFormat4.tzData,
@@ -1,8 +1,9 @@
1
1
  import { DateTimeFormat } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  import { PartitionDateTimePattern } from './PartitionDateTimePattern';
3
4
  /**
4
5
  * https://tc39.es/ecma402/#sec-formatdatetime
5
6
  * @param dtf DateTimeFormat
6
7
  * @param x
7
8
  */
8
- export declare function FormatDateTime(dtf: Intl.DateTimeFormat | DateTimeFormat, x: number, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): string;
9
+ export declare function FormatDateTime(dtf: Intl.DateTimeFormat | DateTimeFormat, x: Decimal, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): string;
@@ -1,4 +1,5 @@
1
1
  import { DateTimeFormat, DateTimeFormatLocaleInternalData, IntlDateTimeFormatInternal, IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  import { ToLocalTimeImplDetails } from './ToLocalTime';
3
4
  export interface FormatDateTimePatternImplDetails {
4
5
  getInternalSlots(dtf: Intl.DateTimeFormat | DateTimeFormat): IntlDateTimeFormatInternal;
@@ -10,4 +11,4 @@ export interface FormatDateTimePatternImplDetails {
10
11
  * @param dtf
11
12
  * @param x
12
13
  */
13
- export declare function FormatDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, patternParts: IntlDateTimeFormatPart[], x: number, { getInternalSlots, localeData, getDefaultTimeZone, tzData, }: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
14
+ export declare function FormatDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, patternParts: IntlDateTimeFormatPart[], x: Decimal, { getInternalSlots, localeData, getDefaultTimeZone, tzData, }: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FormatDateTimePattern = FormatDateTimePattern;
4
+ var tslib_1 = require("tslib");
4
5
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
6
+ var decimal_js_1 = tslib_1.__importDefault(require("decimal.js"));
5
7
  var ToLocalTime_1 = require("./ToLocalTime");
6
8
  var utils_1 = require("./utils");
7
9
  function pad(n) {
@@ -75,7 +77,11 @@ function FormatDateTimePattern(dtf, patternParts, x, _a) {
75
77
  });
76
78
  }
77
79
  else if (p === 'fractionalSecondDigits') {
78
- var v = Math.floor(tm.millisecond * Math.pow(10, ((fractionalSecondDigits || 0) - 3)));
80
+ var v = new decimal_js_1.default(tm.millisecond)
81
+ .times(10)
82
+ .pow((fractionalSecondDigits || 0) - 3)
83
+ .floor()
84
+ .toNumber();
79
85
  result.push({
80
86
  type: 'fractionalSecond',
81
87
  value: nf3.format(v),
@@ -1,3 +1,4 @@
1
+ import Decimal from 'decimal.js';
1
2
  import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
2
3
  import { ToLocalTimeImplDetails } from './ToLocalTime';
3
- export declare function FormatDateTimeRange(dtf: Intl.DateTimeFormat, x: number, y: number, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): string;
4
+ export declare function FormatDateTimeRange(dtf: Intl.DateTimeFormat, x: Decimal, y: Decimal, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): string;
@@ -1,4 +1,5 @@
1
1
  import { IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
+ import { Decimal } from 'decimal.js';
2
3
  import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
3
4
  import { ToLocalTimeImplDetails } from './ToLocalTime';
4
- export declare function FormatDateTimeRangeToParts(dtf: Intl.DateTimeFormat, x: number, y: number, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
5
+ export declare function FormatDateTimeRangeToParts(dtf: Intl.DateTimeFormat, x: Decimal, y: Decimal, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
@@ -1,5 +1,6 @@
1
- import { PartitionDateTimePattern } from './PartitionDateTimePattern';
2
1
  import { IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
3
+ import { PartitionDateTimePattern } from './PartitionDateTimePattern';
3
4
  /**
4
5
  * https://tc39.es/ecma402/#sec-formatdatetimetoparts
5
6
  *
@@ -7,4 +8,4 @@ import { IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
7
8
  * @param x
8
9
  * @param implDetails
9
10
  */
10
- export declare function FormatDateTimeToParts(dtf: Intl.DateTimeFormat, x: number, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): IntlDateTimeFormatPart[];
11
+ export declare function FormatDateTimeToParts(dtf: Intl.DateTimeFormat, x: Decimal, implDetails: Parameters<typeof PartitionDateTimePattern>[2]): IntlDateTimeFormatPart[];
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FormatDateTimeToParts = FormatDateTimeToParts;
4
- var PartitionDateTimePattern_1 = require("./PartitionDateTimePattern");
5
4
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
+ var PartitionDateTimePattern_1 = require("./PartitionDateTimePattern");
6
6
  /**
7
7
  * https://tc39.es/ecma402/#sec-formatdatetimetoparts
8
8
  *
@@ -1,9 +1,10 @@
1
1
  import { DateTimeFormat, IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
- import { ToLocalTimeImplDetails } from './ToLocalTime';
2
+ import Decimal from 'decimal.js';
3
3
  import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
4
+ import { ToLocalTimeImplDetails } from './ToLocalTime';
4
5
  /**
5
6
  * https://tc39.es/ecma402/#sec-partitiondatetimepattern
6
7
  * @param dtf
7
8
  * @param x
8
9
  */
9
- export declare function PartitionDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, x: number, implDetails: ToLocalTimeImplDetails & FormatDateTimePatternImplDetails): IntlDateTimeFormatPart[];
10
+ export declare function PartitionDateTimePattern(dtf: Intl.DateTimeFormat | DateTimeFormat, x: Decimal, implDetails: ToLocalTimeImplDetails & FormatDateTimePatternImplDetails): IntlDateTimeFormatPart[];
@@ -10,9 +10,7 @@ var FormatDateTimePattern_1 = require("./FormatDateTimePattern");
10
10
  */
11
11
  function PartitionDateTimePattern(dtf, x, implDetails) {
12
12
  x = (0, ecma402_abstract_1.TimeClip)(x);
13
- if (isNaN(x)) {
14
- throw new RangeError('invalid time');
15
- }
13
+ (0, ecma402_abstract_1.invariant)(!x.isNaN(), 'Invalid time', RangeError);
16
14
  /** IMPL START */
17
15
  var getInternalSlots = implDetails.getInternalSlots;
18
16
  var internalSlots = getInternalSlots(dtf);
@@ -1,4 +1,5 @@
1
1
  import { IntlDateTimeFormatPart } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  import { FormatDateTimePatternImplDetails } from './FormatDateTimePattern';
3
4
  import { ToLocalTimeImplDetails } from './ToLocalTime';
4
- export declare function PartitionDateTimeRangePattern(dtf: Intl.DateTimeFormat, x: number, y: number, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
5
+ export declare function PartitionDateTimeRangePattern(dtf: Intl.DateTimeFormat, x: Decimal, y: Decimal, implDetails: FormatDateTimePatternImplDetails & ToLocalTimeImplDetails): IntlDateTimeFormatPart[];
@@ -18,11 +18,11 @@ var TABLE_2_FIELDS = [
18
18
  ];
19
19
  function PartitionDateTimeRangePattern(dtf, x, y, implDetails) {
20
20
  x = (0, ecma402_abstract_1.TimeClip)(x);
21
- if (isNaN(x)) {
21
+ if (x.isNaN()) {
22
22
  throw new RangeError('Invalid start time');
23
23
  }
24
24
  y = (0, ecma402_abstract_1.TimeClip)(y);
25
- if (isNaN(y)) {
25
+ if (y.isNaN()) {
26
26
  throw new RangeError('Invalid end time');
27
27
  }
28
28
  /** IMPL START */
@@ -1,4 +1,5 @@
1
1
  import { UnpackedZoneData } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  export interface ToLocalTimeImplDetails {
3
4
  tzData: Record<string, UnpackedZoneData[]>;
4
5
  }
@@ -8,7 +9,7 @@ export interface ToLocalTimeImplDetails {
8
9
  * @param calendar
9
10
  * @param timeZone
10
11
  */
11
- export declare function ToLocalTime(t: number, calendar: string, timeZone: string, { tzData }: ToLocalTimeImplDetails): {
12
+ export declare function ToLocalTime(t: Decimal, calendar: string, timeZone: string, { tzData }: ToLocalTimeImplDetails): {
12
13
  weekday: number;
13
14
  era: string;
14
15
  year: number;
@@ -29,10 +29,9 @@ function getApplicableZoneData(t, timeZone, tzData) {
29
29
  */
30
30
  function ToLocalTime(t, calendar, timeZone, _a) {
31
31
  var tzData = _a.tzData;
32
- (0, ecma402_abstract_1.invariant)((0, ecma402_abstract_1.Type)(t) === 'Number', 'invalid time');
33
32
  (0, ecma402_abstract_1.invariant)(calendar === 'gregory', 'We only support Gregory calendar right now');
34
- var _b = getApplicableZoneData(t, timeZone, tzData), timeZoneOffset = _b[0], inDST = _b[1];
35
- var tz = t + timeZoneOffset;
33
+ var _b = getApplicableZoneData(t.toNumber(), timeZone, tzData), timeZoneOffset = _b[0], inDST = _b[1];
34
+ var tz = t.plus(timeZoneOffset).toNumber();
36
35
  var year = (0, ecma402_abstract_1.YearFromTime)(tz);
37
36
  return {
38
37
  weekday: (0, ecma402_abstract_1.WeekDay)(tz),
package/src/core.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DateTimeFormat = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
6
+ var decimal_js_1 = tslib_1.__importDefault(require("decimal.js"));
6
7
  var FormatDateTime_1 = require("./abstract/FormatDateTime");
7
8
  var FormatDateTimeRange_1 = require("./abstract/FormatDateTimeRange");
8
9
  var FormatDateTimeRangeToParts_1 = require("./abstract/FormatDateTimeRangeToParts");
@@ -52,10 +53,10 @@ var formatDescriptor = {
52
53
  boundFormat = function (date) {
53
54
  var x;
54
55
  if (date === undefined) {
55
- x = Date.now();
56
+ x = new decimal_js_1.default(Date.now());
56
57
  }
57
58
  else {
58
- x = Number(date);
59
+ x = (0, ecma402_abstract_1.ToNumber)(date);
59
60
  }
60
61
  return (0, FormatDateTime_1.FormatDateTime)(dtf, x, {
61
62
  getInternalSlots: get_internal_slots_1.default,
@@ -159,13 +160,14 @@ exports.DateTimeFormat = function (locales, options) {
159
160
  });
160
161
  (0, ecma402_abstract_1.defineProperty)(exports.DateTimeFormat.prototype, 'formatToParts', {
161
162
  value: function formatToParts(date) {
163
+ var x;
162
164
  if (date === undefined) {
163
- date = Date.now();
165
+ x = new decimal_js_1.default(Date.now());
164
166
  }
165
167
  else {
166
- date = (0, ecma402_abstract_1.ToNumber)(date).toNumber();
168
+ x = (0, ecma402_abstract_1.ToNumber)(date);
167
169
  }
168
- return (0, FormatDateTimeToParts_1.FormatDateTimeToParts)(this, date, {
170
+ return (0, FormatDateTimeToParts_1.FormatDateTimeToParts)(this, x, {
169
171
  getInternalSlots: get_internal_slots_1.default,
170
172
  localeData: exports.DateTimeFormat.localeData,
171
173
  tzData: exports.DateTimeFormat.tzData,
@@ -176,15 +178,9 @@ exports.DateTimeFormat = function (locales, options) {
176
178
  (0, ecma402_abstract_1.defineProperty)(exports.DateTimeFormat.prototype, 'formatRangeToParts', {
177
179
  value: function formatRangeToParts(startDate, endDate) {
178
180
  var dtf = this;
179
- if (typeof dtf !== 'object') {
180
- throw new TypeError();
181
- }
182
- if (startDate === undefined || endDate === undefined) {
183
- throw new TypeError('startDate/endDate cannot be undefined');
184
- }
185
- var x = (0, ecma402_abstract_1.ToNumber)(startDate).toNumber();
186
- var y = (0, ecma402_abstract_1.ToNumber)(endDate).toNumber();
187
- return (0, FormatDateTimeRangeToParts_1.FormatDateTimeRangeToParts)(dtf, x, y, {
181
+ (0, ecma402_abstract_1.invariant)(typeof dtf === 'object', 'receiver is not an object', TypeError);
182
+ (0, ecma402_abstract_1.invariant)(startDate !== undefined && endDate !== undefined, 'startDate/endDate cannot be undefined', TypeError);
183
+ return (0, FormatDateTimeRangeToParts_1.FormatDateTimeRangeToParts)(dtf, (0, ecma402_abstract_1.ToNumber)(startDate), (0, ecma402_abstract_1.ToNumber)(endDate), {
188
184
  getInternalSlots: get_internal_slots_1.default,
189
185
  localeData: exports.DateTimeFormat.localeData,
190
186
  tzData: exports.DateTimeFormat.tzData,
@@ -195,15 +191,9 @@ exports.DateTimeFormat = function (locales, options) {
195
191
  (0, ecma402_abstract_1.defineProperty)(exports.DateTimeFormat.prototype, 'formatRange', {
196
192
  value: function formatRange(startDate, endDate) {
197
193
  var dtf = this;
198
- if (typeof dtf !== 'object') {
199
- throw new TypeError();
200
- }
201
- if (startDate === undefined || endDate === undefined) {
202
- throw new TypeError('startDate/endDate cannot be undefined');
203
- }
204
- var x = (0, ecma402_abstract_1.ToNumber)(startDate).toNumber();
205
- var y = (0, ecma402_abstract_1.ToNumber)(endDate).toNumber();
206
- return (0, FormatDateTimeRange_1.FormatDateTimeRange)(dtf, x, y, {
194
+ (0, ecma402_abstract_1.invariant)(typeof dtf === 'object', 'receiver is not an object', TypeError);
195
+ (0, ecma402_abstract_1.invariant)(startDate !== undefined && endDate !== undefined, 'startDate/endDate cannot be undefined', TypeError);
196
+ return (0, FormatDateTimeRange_1.FormatDateTimeRange)(dtf, (0, ecma402_abstract_1.ToNumber)(startDate), (0, ecma402_abstract_1.ToNumber)(endDate), {
207
197
  getInternalSlots: get_internal_slots_1.default,
208
198
  localeData: exports.DateTimeFormat.localeData,
209
199
  tzData: exports.DateTimeFormat.tzData,