@formatjs/intl-durationformat 0.7.6 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.js +1 -4
- package/package.json +15 -9
- package/polyfill-force.js +2 -4
- package/polyfill.js +4 -6
- package/should-polyfill.js +1 -4
- package/src/abstract/DurationRecordSign.d.ts +1 -1
- package/src/abstract/DurationRecordSign.js +3 -6
- package/src/abstract/GetDurationUnitOptions.js +4 -7
- package/src/abstract/IsValidDurationRecord.d.ts +1 -1
- package/src/abstract/IsValidDurationRecord.js +7 -10
- package/src/abstract/PartitionDurationFormatPattern.d.ts +2 -2
- package/src/abstract/PartitionDurationFormatPattern.js +13 -16
- package/src/abstract/ToDurationRecord.d.ts +1 -1
- package/src/abstract/ToDurationRecord.js +14 -17
- package/src/abstract/ToIntegerIfIntegral.js +4 -7
- package/src/constants.d.ts +1 -1
- package/src/constants.js +2 -5
- package/src/core.d.ts +2 -2
- package/src/core.js +33 -38
- package/src/get_internal_slots.d.ts +1 -1
- package/src/get_internal_slots.js +1 -4
- package/src/numbering-systems.generated.js +1 -4
- package/src/time-separators.generated.js +1 -4
- package/src/types.d.ts +2 -2
- package/src/types.js +1 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/polyfill-force.d.ts +0 -1
- package/lib/polyfill-force.js +0 -18
- package/lib/polyfill.d.ts +0 -1
- package/lib/polyfill.js +0 -21
- package/lib/should-polyfill.d.ts +0 -1
- package/lib/should-polyfill.js +0 -3
- package/lib/src/abstract/DurationRecordSign.d.ts +0 -2
- package/lib/src/abstract/DurationRecordSign.js +0 -13
- package/lib/src/abstract/GetDurationUnitOptions.d.ts +0 -4
- package/lib/src/abstract/GetDurationUnitOptions.js +0 -43
- package/lib/src/abstract/IsValidDurationRecord.d.ts +0 -2
- package/lib/src/abstract/IsValidDurationRecord.js +0 -18
- package/lib/src/abstract/PartitionDurationFormatPattern.d.ts +0 -3
- package/lib/src/abstract/PartitionDurationFormatPattern.js +0 -149
- package/lib/src/abstract/ToDurationRecord.d.ts +0 -2
- package/lib/src/abstract/ToDurationRecord.js +0 -68
- package/lib/src/abstract/ToIntegerIfIntegral.d.ts +0 -1
- package/lib/src/abstract/ToIntegerIfIntegral.js +0 -6
- package/lib/src/constants.d.ts +0 -63
- package/lib/src/constants.js +0 -84
- package/lib/src/core.d.ts +0 -14
- package/lib/src/core.js +0 -236
- package/lib/src/get_internal_slots.d.ts +0 -2
- package/lib/src/get_internal_slots.js +0 -9
- package/lib/src/numbering-systems.generated.d.ts +0 -1
- package/lib/src/numbering-systems.generated.js +0 -1
- package/lib/src/time-separators.generated.d.ts +0 -2219
- package/lib/src/time-separators.generated.js +0 -3701
- package/lib/src/types.d.ts +0 -108
- package/lib/src/types.js +0 -2
package/lib/polyfill-force.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DurationFormat } from './';
|
|
2
|
-
if (typeof Intl === 'undefined') {
|
|
3
|
-
if (typeof window !== 'undefined') {
|
|
4
|
-
Object.defineProperty(window, 'Intl', {
|
|
5
|
-
value: {},
|
|
6
|
-
});
|
|
7
|
-
// @ts-ignore we don't include @types/node so global isn't a thing
|
|
8
|
-
}
|
|
9
|
-
else if (typeof global !== 'undefined') {
|
|
10
|
-
// @ts-ignore we don't include @types/node so global isn't a thing
|
|
11
|
-
Object.defineProperty(global, 'Intl', {
|
|
12
|
-
value: {},
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(Intl, 'DurationFormat', {
|
|
17
|
-
value: DurationFormat,
|
|
18
|
-
});
|
package/lib/polyfill.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/polyfill.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DurationFormat } from './';
|
|
2
|
-
import { shouldPolyfill } from './should-polyfill';
|
|
3
|
-
if (typeof Intl === 'undefined') {
|
|
4
|
-
if (typeof window !== 'undefined') {
|
|
5
|
-
Object.defineProperty(window, 'Intl', {
|
|
6
|
-
value: {},
|
|
7
|
-
});
|
|
8
|
-
// @ts-ignore we don't include @types/node so global isn't a thing
|
|
9
|
-
}
|
|
10
|
-
else if (typeof global !== 'undefined') {
|
|
11
|
-
// @ts-ignore we don't include @types/node so global isn't a thing
|
|
12
|
-
Object.defineProperty(global, 'Intl', {
|
|
13
|
-
value: {},
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (shouldPolyfill()) {
|
|
18
|
-
Object.defineProperty(Intl, 'DurationFormat', {
|
|
19
|
-
value: DurationFormat,
|
|
20
|
-
});
|
|
21
|
-
}
|
package/lib/should-polyfill.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function shouldPolyfill(): boolean;
|
package/lib/should-polyfill.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { TABLE_1 } from '../constants';
|
|
2
|
-
export function DurationRecordSign(record) {
|
|
3
|
-
for (var _i = 0, TABLE_1_1 = TABLE_1; _i < TABLE_1_1.length; _i++) {
|
|
4
|
-
var key = TABLE_1_1[_i];
|
|
5
|
-
if (record[key] < 0) {
|
|
6
|
-
return -1;
|
|
7
|
-
}
|
|
8
|
-
if (record[key] > 0) {
|
|
9
|
-
return 1;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function GetDurationUnitOptions<T extends object>(unit: keyof T, options: T, baseStyle: Exclude<T[keyof T], undefined>, stylesList: readonly T[keyof T][], digitalBase: Exclude<T[keyof T], undefined>, prevStyle: string): {
|
|
2
|
-
style: Exclude<T[keyof T], undefined>;
|
|
3
|
-
display: string | Exclude<T[keyof T], undefined>;
|
|
4
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { GetOption } from '@formatjs/ecma402-abstract';
|
|
2
|
-
export function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle) {
|
|
3
|
-
var style = GetOption(options, unit, 'string', stylesList, undefined);
|
|
4
|
-
var displayDefault = 'always';
|
|
5
|
-
if (style === undefined) {
|
|
6
|
-
if (baseStyle === 'digital') {
|
|
7
|
-
if (unit !== 'hours' && unit !== 'minutes' && unit !== 'seconds') {
|
|
8
|
-
displayDefault = 'auto';
|
|
9
|
-
}
|
|
10
|
-
style = digitalBase;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
displayDefault = 'auto';
|
|
14
|
-
if (prevStyle === 'numeric' || prevStyle === '2-digit') {
|
|
15
|
-
style = 'numeric';
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
style = baseStyle;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
var displayField = "".concat(unit, "Display");
|
|
23
|
-
var display = GetOption(options, displayField, 'string', ['always', 'auto'], displayDefault);
|
|
24
|
-
if (prevStyle === 'numeric' || prevStyle === '2-digit') {
|
|
25
|
-
if (style !== 'numeric' && style !== '2-digit') {
|
|
26
|
-
throw new RangeError("Can't mix numeric and non-numeric styles");
|
|
27
|
-
}
|
|
28
|
-
else if (unit === 'minutes' || unit === 'seconds') {
|
|
29
|
-
style = '2-digit';
|
|
30
|
-
}
|
|
31
|
-
if (style === 'numeric' &&
|
|
32
|
-
display === 'always' &&
|
|
33
|
-
(unit === 'milliseconds' ||
|
|
34
|
-
unit === 'microseconds' ||
|
|
35
|
-
unit === 'nanoseconds')) {
|
|
36
|
-
throw new RangeError("Can't display milliseconds, microseconds, or nanoseconds in numeric format");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
style: style,
|
|
41
|
-
display: display,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { invariant } from '@formatjs/ecma402-abstract';
|
|
2
|
-
import { TABLE_1 } from '../constants';
|
|
3
|
-
import { DurationRecordSign } from './DurationRecordSign';
|
|
4
|
-
export function IsValidDurationRecord(record) {
|
|
5
|
-
var sign = DurationRecordSign(record);
|
|
6
|
-
for (var _i = 0, TABLE_1_1 = TABLE_1; _i < TABLE_1_1.length; _i++) {
|
|
7
|
-
var key = TABLE_1_1[_i];
|
|
8
|
-
var v = record[key];
|
|
9
|
-
invariant(isFinite(Number(v)), "".concat(key, " is not finite"));
|
|
10
|
-
if (v < 0 && sign > 0) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
if (v > 0 && sign < 0) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { createMemoizedListFormat, createMemoizedNumberFormat, invariant, } from '@formatjs/ecma402-abstract';
|
|
2
|
-
import { TABLE_2 } from '../constants';
|
|
3
|
-
import { DurationFormat } from '../core';
|
|
4
|
-
import { getInternalSlots } from '../get_internal_slots';
|
|
5
|
-
export function PartitionDurationFormatPattern(df, duration) {
|
|
6
|
-
var result = [];
|
|
7
|
-
var done = false;
|
|
8
|
-
var separated = false;
|
|
9
|
-
var internalSlots = getInternalSlots(df);
|
|
10
|
-
var dataLocale = internalSlots.dataLocale;
|
|
11
|
-
var dataLocaleData = DurationFormat.localeData[dataLocale];
|
|
12
|
-
if (!dataLocaleData) {
|
|
13
|
-
throw new TypeError('Invalid locale');
|
|
14
|
-
}
|
|
15
|
-
var numberingSystem = internalSlots.numberingSystem;
|
|
16
|
-
var separator = dataLocaleData.digitalFormat[numberingSystem];
|
|
17
|
-
var _loop_1 = function (i) {
|
|
18
|
-
var row = TABLE_2[i];
|
|
19
|
-
var value = duration[row.valueField];
|
|
20
|
-
var style = internalSlots[row.styleSlot];
|
|
21
|
-
var display = internalSlots[row.displaySlot];
|
|
22
|
-
var unit = row.unit, numberFormatUnit = row.numberFormatUnit;
|
|
23
|
-
var nfOpts = Object.create(null);
|
|
24
|
-
if (unit === 'seconds' ||
|
|
25
|
-
unit === 'milliseconds' ||
|
|
26
|
-
unit === 'microseconds') {
|
|
27
|
-
var nextStyle = void 0;
|
|
28
|
-
if (unit === 'seconds') {
|
|
29
|
-
nextStyle = internalSlots.milliseconds;
|
|
30
|
-
}
|
|
31
|
-
else if (unit === 'milliseconds') {
|
|
32
|
-
nextStyle = internalSlots.microseconds;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
nextStyle = internalSlots.nanoseconds;
|
|
36
|
-
}
|
|
37
|
-
if (nextStyle === 'numeric') {
|
|
38
|
-
if (unit === 'seconds') {
|
|
39
|
-
value +=
|
|
40
|
-
duration.milliseconds / 1e3 +
|
|
41
|
-
duration.microseconds / 1e6 +
|
|
42
|
-
duration.nanoseconds / 1e9;
|
|
43
|
-
}
|
|
44
|
-
else if (unit === 'milliseconds') {
|
|
45
|
-
value += duration.microseconds / 1e3 + duration.nanoseconds / 1e6;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
value += duration.nanoseconds / 1e3;
|
|
49
|
-
}
|
|
50
|
-
if (internalSlots.fractionalDigits === undefined) {
|
|
51
|
-
nfOpts.maximumFractionDigits = 9;
|
|
52
|
-
nfOpts.minimumFractionDigits = 0;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
nfOpts.maximumFractionDigits = internalSlots.fractionalDigits;
|
|
56
|
-
nfOpts.minimumFractionDigits = internalSlots.fractionalDigits;
|
|
57
|
-
}
|
|
58
|
-
nfOpts.roundingMode = 'trunc';
|
|
59
|
-
done = true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (value !== 0 || display !== 'auto') {
|
|
63
|
-
nfOpts.numberingSystem = internalSlots.numberingSystem;
|
|
64
|
-
if (style === '2-digit') {
|
|
65
|
-
nfOpts.minimumIntegerDigits = 2;
|
|
66
|
-
}
|
|
67
|
-
if (style !== '2-digit' && style !== 'numeric') {
|
|
68
|
-
nfOpts.style = 'unit';
|
|
69
|
-
nfOpts.unit = numberFormatUnit;
|
|
70
|
-
nfOpts.unitDisplay = style;
|
|
71
|
-
}
|
|
72
|
-
var nf = createMemoizedNumberFormat(internalSlots.locale, nfOpts);
|
|
73
|
-
var list_1;
|
|
74
|
-
if (!separated) {
|
|
75
|
-
list_1 = [];
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
list_1 = result[result.length - 1];
|
|
79
|
-
list_1.push({
|
|
80
|
-
type: 'literal',
|
|
81
|
-
value: separator,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
var parts = nf.formatToParts(value);
|
|
85
|
-
parts.forEach(function (_a) {
|
|
86
|
-
var type = _a.type, value = _a.value;
|
|
87
|
-
list_1.push({
|
|
88
|
-
type: type,
|
|
89
|
-
value: value,
|
|
90
|
-
unit: numberFormatUnit,
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
if (!separated) {
|
|
94
|
-
if (style === '2-digit' || style === 'numeric') {
|
|
95
|
-
separated = true;
|
|
96
|
-
}
|
|
97
|
-
result.push(list_1);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
separated = false;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
for (var i = 0; i < TABLE_2.length && !done; i++) {
|
|
105
|
-
_loop_1(i);
|
|
106
|
-
}
|
|
107
|
-
var lfOpts = Object.create(null);
|
|
108
|
-
lfOpts.type = 'unit';
|
|
109
|
-
var listStyle = internalSlots.style;
|
|
110
|
-
if (listStyle === 'digital') {
|
|
111
|
-
listStyle = 'short';
|
|
112
|
-
}
|
|
113
|
-
lfOpts.style = listStyle;
|
|
114
|
-
var lf = createMemoizedListFormat(internalSlots.locale, lfOpts);
|
|
115
|
-
var strings = [];
|
|
116
|
-
for (var _i = 0, result_1 = result; _i < result_1.length; _i++) {
|
|
117
|
-
var parts = result_1[_i];
|
|
118
|
-
var string = '';
|
|
119
|
-
for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
|
|
120
|
-
var value = parts_1[_a].value;
|
|
121
|
-
string += value;
|
|
122
|
-
}
|
|
123
|
-
strings.push(string);
|
|
124
|
-
}
|
|
125
|
-
var formatted = lf.formatToParts(strings);
|
|
126
|
-
var resultIndex = 0;
|
|
127
|
-
var resultLength = result.length;
|
|
128
|
-
var flattened = [];
|
|
129
|
-
for (var _b = 0, formatted_1 = formatted; _b < formatted_1.length; _b++) {
|
|
130
|
-
var _c = formatted_1[_b], type = _c.type, value = _c.value;
|
|
131
|
-
if (type === 'element') {
|
|
132
|
-
invariant(resultIndex < resultLength, 'Index out of bounds');
|
|
133
|
-
var parts = result[resultIndex];
|
|
134
|
-
for (var _d = 0, parts_2 = parts; _d < parts_2.length; _d++) {
|
|
135
|
-
var part = parts_2[_d];
|
|
136
|
-
flattened.push(part);
|
|
137
|
-
}
|
|
138
|
-
resultIndex++;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
invariant(type === 'literal', 'Type must be literal');
|
|
142
|
-
flattened.push({
|
|
143
|
-
type: 'literal',
|
|
144
|
-
value: value,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return flattened;
|
|
149
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { IsValidDurationRecord } from './IsValidDurationRecord';
|
|
2
|
-
import { ToIntegerIfIntegral } from './ToIntegerIfIntegral';
|
|
3
|
-
export function ToDurationRecord(input) {
|
|
4
|
-
if (typeof input !== 'object') {
|
|
5
|
-
if (typeof input === 'string') {
|
|
6
|
-
throw new RangeError('Invalid duration format');
|
|
7
|
-
}
|
|
8
|
-
throw new TypeError('Invalid duration');
|
|
9
|
-
}
|
|
10
|
-
var result = {
|
|
11
|
-
years: 0,
|
|
12
|
-
months: 0,
|
|
13
|
-
weeks: 0,
|
|
14
|
-
days: 0,
|
|
15
|
-
hours: 0,
|
|
16
|
-
minutes: 0,
|
|
17
|
-
seconds: 0,
|
|
18
|
-
milliseconds: 0,
|
|
19
|
-
microseconds: 0,
|
|
20
|
-
nanoseconds: 0,
|
|
21
|
-
};
|
|
22
|
-
if (input.days !== undefined) {
|
|
23
|
-
result.days = ToIntegerIfIntegral(input.days);
|
|
24
|
-
}
|
|
25
|
-
if (input.hours !== undefined) {
|
|
26
|
-
result.hours = ToIntegerIfIntegral(input.hours);
|
|
27
|
-
}
|
|
28
|
-
if (input.microseconds !== undefined) {
|
|
29
|
-
result.microseconds = ToIntegerIfIntegral(input.microseconds);
|
|
30
|
-
}
|
|
31
|
-
if (input.milliseconds !== undefined) {
|
|
32
|
-
result.milliseconds = ToIntegerIfIntegral(input.milliseconds);
|
|
33
|
-
}
|
|
34
|
-
if (input.minutes !== undefined) {
|
|
35
|
-
result.minutes = ToIntegerIfIntegral(input.minutes);
|
|
36
|
-
}
|
|
37
|
-
if (input.months !== undefined) {
|
|
38
|
-
result.months = ToIntegerIfIntegral(input.months);
|
|
39
|
-
}
|
|
40
|
-
if (input.nanoseconds !== undefined) {
|
|
41
|
-
result.nanoseconds = ToIntegerIfIntegral(input.nanoseconds);
|
|
42
|
-
}
|
|
43
|
-
if (input.seconds !== undefined) {
|
|
44
|
-
result.seconds = ToIntegerIfIntegral(input.seconds);
|
|
45
|
-
}
|
|
46
|
-
if (input.weeks !== undefined) {
|
|
47
|
-
result.weeks = ToIntegerIfIntegral(input.weeks);
|
|
48
|
-
}
|
|
49
|
-
if (input.years !== undefined) {
|
|
50
|
-
result.years = ToIntegerIfIntegral(input.years);
|
|
51
|
-
}
|
|
52
|
-
if (input.years === undefined &&
|
|
53
|
-
input.months === undefined &&
|
|
54
|
-
input.weeks === undefined &&
|
|
55
|
-
input.days === undefined &&
|
|
56
|
-
input.hours === undefined &&
|
|
57
|
-
input.minutes === undefined &&
|
|
58
|
-
input.seconds === undefined &&
|
|
59
|
-
input.milliseconds === undefined &&
|
|
60
|
-
input.microseconds === undefined &&
|
|
61
|
-
input.nanoseconds === undefined) {
|
|
62
|
-
throw new TypeError('Invalid duration format');
|
|
63
|
-
}
|
|
64
|
-
if (!IsValidDurationRecord(result)) {
|
|
65
|
-
throw new RangeError('Invalid duration format');
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function ToIntegerIfIntegral(arg: any): number;
|
package/lib/src/constants.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { DurationRecord } from './types';
|
|
2
|
-
export declare const TABLE_1: Array<keyof DurationRecord>;
|
|
3
|
-
export declare const TABLE_2: readonly [{
|
|
4
|
-
readonly valueField: "years";
|
|
5
|
-
readonly styleSlot: "years";
|
|
6
|
-
readonly displaySlot: "yearsDisplay";
|
|
7
|
-
readonly unit: "years";
|
|
8
|
-
readonly numberFormatUnit: "year";
|
|
9
|
-
}, {
|
|
10
|
-
readonly valueField: "months";
|
|
11
|
-
readonly styleSlot: "months";
|
|
12
|
-
readonly displaySlot: "monthsDisplay";
|
|
13
|
-
readonly unit: "months";
|
|
14
|
-
readonly numberFormatUnit: "month";
|
|
15
|
-
}, {
|
|
16
|
-
readonly valueField: "weeks";
|
|
17
|
-
readonly styleSlot: "weeks";
|
|
18
|
-
readonly displaySlot: "weeksDisplay";
|
|
19
|
-
readonly unit: "weeks";
|
|
20
|
-
readonly numberFormatUnit: "week";
|
|
21
|
-
}, {
|
|
22
|
-
readonly valueField: "days";
|
|
23
|
-
readonly styleSlot: "days";
|
|
24
|
-
readonly displaySlot: "daysDisplay";
|
|
25
|
-
readonly unit: "days";
|
|
26
|
-
readonly numberFormatUnit: "day";
|
|
27
|
-
}, {
|
|
28
|
-
readonly valueField: "hours";
|
|
29
|
-
readonly styleSlot: "hours";
|
|
30
|
-
readonly displaySlot: "hoursDisplay";
|
|
31
|
-
readonly unit: "hours";
|
|
32
|
-
readonly numberFormatUnit: "hour";
|
|
33
|
-
}, {
|
|
34
|
-
readonly valueField: "minutes";
|
|
35
|
-
readonly styleSlot: "minutes";
|
|
36
|
-
readonly displaySlot: "minutesDisplay";
|
|
37
|
-
readonly unit: "minutes";
|
|
38
|
-
readonly numberFormatUnit: "minute";
|
|
39
|
-
}, {
|
|
40
|
-
readonly valueField: "seconds";
|
|
41
|
-
readonly styleSlot: "seconds";
|
|
42
|
-
readonly displaySlot: "secondsDisplay";
|
|
43
|
-
readonly unit: "seconds";
|
|
44
|
-
readonly numberFormatUnit: "second";
|
|
45
|
-
}, {
|
|
46
|
-
readonly valueField: "milliseconds";
|
|
47
|
-
readonly styleSlot: "milliseconds";
|
|
48
|
-
readonly displaySlot: "millisecondsDisplay";
|
|
49
|
-
readonly unit: "milliseconds";
|
|
50
|
-
readonly numberFormatUnit: "millisecond";
|
|
51
|
-
}, {
|
|
52
|
-
readonly valueField: "microseconds";
|
|
53
|
-
readonly styleSlot: "microseconds";
|
|
54
|
-
readonly displaySlot: "microsecondsDisplay";
|
|
55
|
-
readonly unit: "microseconds";
|
|
56
|
-
readonly numberFormatUnit: "microsecond";
|
|
57
|
-
}, {
|
|
58
|
-
readonly valueField: "nanoseconds";
|
|
59
|
-
readonly styleSlot: "nanoseconds";
|
|
60
|
-
readonly displaySlot: "nanosecondsDisplay";
|
|
61
|
-
readonly unit: "nanoseconds";
|
|
62
|
-
readonly numberFormatUnit: "nanosecond";
|
|
63
|
-
}];
|
package/lib/src/constants.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
export var TABLE_1 = [
|
|
2
|
-
'years',
|
|
3
|
-
'months',
|
|
4
|
-
'weeks',
|
|
5
|
-
'days',
|
|
6
|
-
'hours',
|
|
7
|
-
'minutes',
|
|
8
|
-
'seconds',
|
|
9
|
-
'milliseconds',
|
|
10
|
-
'microseconds',
|
|
11
|
-
'nanoseconds',
|
|
12
|
-
];
|
|
13
|
-
export var TABLE_2 = [
|
|
14
|
-
{
|
|
15
|
-
valueField: 'years',
|
|
16
|
-
styleSlot: 'years',
|
|
17
|
-
displaySlot: 'yearsDisplay',
|
|
18
|
-
unit: 'years',
|
|
19
|
-
numberFormatUnit: 'year',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
valueField: 'months',
|
|
23
|
-
styleSlot: 'months',
|
|
24
|
-
displaySlot: 'monthsDisplay',
|
|
25
|
-
unit: 'months',
|
|
26
|
-
numberFormatUnit: 'month',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
valueField: 'weeks',
|
|
30
|
-
styleSlot: 'weeks',
|
|
31
|
-
displaySlot: 'weeksDisplay',
|
|
32
|
-
unit: 'weeks',
|
|
33
|
-
numberFormatUnit: 'week',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
valueField: 'days',
|
|
37
|
-
styleSlot: 'days',
|
|
38
|
-
displaySlot: 'daysDisplay',
|
|
39
|
-
unit: 'days',
|
|
40
|
-
numberFormatUnit: 'day',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
valueField: 'hours',
|
|
44
|
-
styleSlot: 'hours',
|
|
45
|
-
displaySlot: 'hoursDisplay',
|
|
46
|
-
unit: 'hours',
|
|
47
|
-
numberFormatUnit: 'hour',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
valueField: 'minutes',
|
|
51
|
-
styleSlot: 'minutes',
|
|
52
|
-
displaySlot: 'minutesDisplay',
|
|
53
|
-
unit: 'minutes',
|
|
54
|
-
numberFormatUnit: 'minute',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
valueField: 'seconds',
|
|
58
|
-
styleSlot: 'seconds',
|
|
59
|
-
displaySlot: 'secondsDisplay',
|
|
60
|
-
unit: 'seconds',
|
|
61
|
-
numberFormatUnit: 'second',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
valueField: 'milliseconds',
|
|
65
|
-
styleSlot: 'milliseconds',
|
|
66
|
-
displaySlot: 'millisecondsDisplay',
|
|
67
|
-
unit: 'milliseconds',
|
|
68
|
-
numberFormatUnit: 'millisecond',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
valueField: 'microseconds',
|
|
72
|
-
styleSlot: 'microseconds',
|
|
73
|
-
displaySlot: 'microsecondsDisplay',
|
|
74
|
-
unit: 'microseconds',
|
|
75
|
-
numberFormatUnit: 'microsecond',
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
valueField: 'nanoseconds',
|
|
79
|
-
styleSlot: 'nanoseconds',
|
|
80
|
-
displaySlot: 'nanosecondsDisplay',
|
|
81
|
-
unit: 'nanoseconds',
|
|
82
|
-
numberFormatUnit: 'nanosecond',
|
|
83
|
-
},
|
|
84
|
-
];
|
package/lib/src/core.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { DurationFormatLocaleInternalData, DurationFormatPart, DurationFormat as DurationFormatType, DurationInput, ResolvedDurationFormatOptions } from './types';
|
|
2
|
-
import { DurationFormatOptions } from './types';
|
|
3
|
-
export declare class DurationFormat implements DurationFormatType {
|
|
4
|
-
constructor(locales?: string | string[], options?: DurationFormatOptions);
|
|
5
|
-
resolvedOptions(): ResolvedDurationFormatOptions;
|
|
6
|
-
formatToParts(duration: DurationInput): DurationFormatPart[];
|
|
7
|
-
format(duration: DurationInput): string;
|
|
8
|
-
static supportedLocalesOf(locales: string | string[], options?: Pick<DurationFormatOptions, 'localeMatcher'>): string[];
|
|
9
|
-
static __defaultLocale: string;
|
|
10
|
-
static availableLocales: Set<string>;
|
|
11
|
-
static localeData: Record<string, DurationFormatLocaleInternalData | undefined>;
|
|
12
|
-
static getDefaultLocale: () => string;
|
|
13
|
-
static polyfilled: boolean;
|
|
14
|
-
}
|