Skip to content

Commit 452f91c

Browse files
ptomato12wrigja
authored andcommitted
Use Intl.supportedValuesOf in validStrings test
Intl.supportedValuesOf is available in Node 18. This allows removing the timezones.json dependency and avoiding the hardcoded list of calendars. UPSTREAM_COMMIT=d0b9ab16b49a0acdaced6e609f6f929f69e09f89
1 parent cb0c200 commit 452f91c

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

test/validStrings.mjs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,9 @@
77

88
import assert from 'assert';
99
import * as ES from '../lib/ecmascript';
10-
import timezoneData from 'timezones.json';
1110

12-
const timezoneNames = new Set(timezoneData.reduce((list, entry) => list.concat(entry.utc), []));
13-
// Remove names that are not recognized by Node (which is sourced from CLDR)
14-
const bad = ['Antarctica/McMurdo', 'CST6CDT', 'EST5EDT', 'MST7MDT', 'PST8PDT'];
15-
bad.forEach((name) => timezoneNames.delete(name));
16-
17-
const calendarNames = [
18-
'buddhist',
19-
'chinese',
20-
'coptic',
21-
'dangi',
22-
'ethioaa',
23-
'ethiopic',
24-
'gregory',
25-
'hebrew',
26-
'indian',
27-
'islamic',
28-
'islamic-umalqura',
29-
'islamic-tbla',
30-
'islamic-civil',
31-
'islamic-rgsa',
32-
'iso8601',
33-
'japanese',
34-
'persian',
35-
'roc',
36-
'islamicc'
37-
];
11+
const timezoneNames = Intl.supportedValuesOf('timeZone');
12+
const calendarNames = Intl.supportedValuesOf('calendar');
3813

3914
function toProduction(productionLike) {
4015
if (typeof productionLike === 'string') return new Literal(productionLike);

0 commit comments

Comments
 (0)