Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const zoneInfoFromUTC = (zoneid: string, utc: number): ZoneInfo => {
init();
let tzinfo = TZ.fromUTC(zoneid, utc);
if (tzinfo === undefined) {
tzinfo = TZ.utcZone();
}
// For the purposes of CLDR stable timezone ids, check if the passed-in
// id is an alias to a current/valid tzdb id.
const isstable = TimeZoneStableIdIndex.get(zoneid) !== -1;
// Use the passed-in id as the stable id if it is an alias,
// otherwise lookup the id in the stable map.
const stableid = isstable ? zoneid : metazones!.getStableId(tzinfo.zoneid);
// Use the corrected zone id to lookup the metazone
const metazoneid = metazones!.getMetazone(tzinfo.zoneid, utc);
return {
...tzinfo,
metazoneid: metazoneid || ('' as MetaZoneType),
stableid