UNPKG

iana-tz-json-generator-and-importer

Version:

Quickly get timezone names and metadata from the IANA into your application in the format you want.

20 lines (16 loc) 574 B
import {readFileAsync} from '../util/util'; import * as path from 'path'; import {walk} from '../util/walk'; export async function loadIANATzJsonFile(filename: string) { const timezonesPath = path.join(__dirname, '../..', 'timezones'); const files: string[] = await walk(timezonesPath); if(!files.includes(filename)) { throw new Error(` File does not exist Options: ${files} `) } const filePath = path.join(timezonesPath, filename); const file = await readFileAsync(filePath); return file.toString(); }