How to use the @phensley/timezone.TZ.utcZone 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 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

@phensley/timezone

Compact timezone lib based on tz database

Apache-2.0
Latest version published 2 months ago

Package Health Score

60 / 100
Full package analysis