How to use the @phensley/timezone.TZ.resolveId function in @phensley/timezone

To help you get started, we’ve selected a few @phensley/timezone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phensley / cldr-engine / packages / cldr-core / src / systems / calendars / timezone.ts View on Github external
export const getStableTimeZoneId = (zoneid: string): string => {
  init();
  // Check if this is already a CLDR stable timezone id.
  const isstable = TimeZoneStableIdIndex.get(zoneid) !== -1;
  if (!isstable) {
    // Resolve the passed-in string to a real tzdb zone id
    const realid = TZ.resolveId(zoneid);
    if (realid) {
      // Map to a CLDR stable id
      zoneid = metazones!.getStableId(realid);
    }
  }
  return zoneid;
};
github phensley / cldr-engine / packages / cldr-compiler / src / cli / generator / code / zones.ts View on Github external
const buildStableIdMapping = (data: any): string => {
  const tzids = TZ.zoneIds();
  const stableids = data.timeZoneIds;
  const res: string[] = [];
  for (const stableid of stableids) {
    const resolved = TZ.resolveId(stableid);
    if (resolved === undefined || stableid === resolved) {
      continue;
    }
    const i = tzids.indexOf(resolved);
    // const j = stableids.indexOf(stableid);
    res.push(`${i}:${stableid}`);
  }
  return res.join('|');
};
github phensley / cldr-engine / packages / cldr-compiler / src / cli / generator / code / zones.ts View on Github external
Object.keys(data).forEach((id, mi) => {
    // Map the metazone id to the index of the time zone id in the TZ data.
    let zi = zoneids.indexOf(id);
    if (zi === -1) {
      // We have an alias, e.g. Africa/Addis_Ababa, so follow the link to
      // get the correct tzdb id.
      const zid = TZ.resolveId(id);
      if (zid === undefined) {
        throw new Error(`${chalk.red('Error')} tzdb / cldr mismatch. zone id failed ${id}`);
      }
      zi = zoneids.indexOf(zid);
    }

    zonemap.set(zi, mi);
  });
github phensley / cldr-engine / packages / cldr-compiler / src / cli / generator / code / aliases.ts View on Github external
const zones = Object.keys(zoneAlias).filter(alias => {
    const zi = zoneids.indexOf(alias);
    if (zi !== -1) {
      // alias is in list of valid tzdb ids, ignore
      return false;
    }

    // if alias fails to resolve, include in this list
    return TZ.resolveId(alias) === undefined;
  }).sort().map(k => [k, zoneAlias[k]].join(':')).join('|');
github phensley / cldr-engine / packages / cldr-core / src / api / calendars.ts View on Github external
resolveTimeZoneId(zoneid: string): string | undefined {
    return TZ.resolveId(substituteZoneAlias(zoneid));
  }

@phensley/timezone

Compact timezone lib based on tz database

Apache-2.0
Latest version published 15 days ago

Package Health Score

62 / 100
Full package analysis