1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.SingularRelativeTimeUnit = SingularRelativeTimeUnit;
|
4 | var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function SingularRelativeTimeUnit(unit) {
|
10 | (0, ecma402_abstract_1.invariant)((0, ecma402_abstract_1.Type)(unit) === 'String', 'unit must be a string');
|
11 | if (unit === 'seconds')
|
12 | return 'second';
|
13 | if (unit === 'minutes')
|
14 | return 'minute';
|
15 | if (unit === 'hours')
|
16 | return 'hour';
|
17 | if (unit === 'days')
|
18 | return 'day';
|
19 | if (unit === 'weeks')
|
20 | return 'week';
|
21 | if (unit === 'months')
|
22 | return 'month';
|
23 | if (unit === 'quarters')
|
24 | return 'quarter';
|
25 | if (unit === 'years')
|
26 | return 'year';
|
27 | if (unit !== 'second' &&
|
28 | unit !== 'minute' &&
|
29 | unit !== 'hour' &&
|
30 | unit !== 'day' &&
|
31 | unit !== 'week' &&
|
32 | unit !== 'month' &&
|
33 | unit !== 'quarter' &&
|
34 | unit !== 'year') {
|
35 | throw new RangeError('invalid unit');
|
36 | }
|
37 | return unit;
|
38 | }
|