2022-09-16 00:03:40 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
// Usage: tools/update-timezone.mjs
|
2022-10-03 07:16:48 +02:00
|
|
|
import { execSync } from 'node:child_process';
|
2022-09-16 00:03:40 +02:00
|
|
|
import { renameSync, readdirSync, rmSync } from 'node:fs';
|
|
|
|
|
|
|
|
const fileNames = [
|
|
|
|
'zoneinfo64.res',
|
|
|
|
'windowsZones.res',
|
|
|
|
'timezoneTypes.res',
|
|
|
|
'metaZones.res',
|
|
|
|
];
|
|
|
|
|
|
|
|
const availableVersions = readdirSync('icu-data/tzdata/icunew', { withFileTypes: true })
|
|
|
|
.filter((dirent) => dirent.isDirectory())
|
|
|
|
.map((dirent) => dirent.name);
|
|
|
|
|
|
|
|
const latestVersion = availableVersions.sort().at(-1);
|
|
|
|
|
|
|
|
execSync('bzip2 -d deps/icu-small/source/data/in/icudt*.dat.bz2');
|
|
|
|
fileNames.forEach((file) => {
|
|
|
|
renameSync(`icu-data/tzdata/icunew/${latestVersion}/44/le/${file}`, `deps/icu-small/source/data/in/${file}`);
|
2022-10-03 07:16:48 +02:00
|
|
|
execSync(`icupkg -a ${file} icudt*.dat`, { cwd: 'deps/icu-small/source/data/in/' });
|
2022-09-16 00:03:40 +02:00
|
|
|
rmSync(`deps/icu-small/source/data/in/${file}`);
|
|
|
|
});
|
|
|
|
execSync('bzip2 -z deps/icu-small/source/data/in/icudt*.dat');
|
|
|
|
rmSync('icu-data', { recursive: true });
|