All files index.ts

100% Statements 24/24
100% Branches 12/12
100% Functions 5/5
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 331x 1x   1x   30x   24x 4750x 4750x     24x   20x     1x   18x   12x 12x 10x     1x 1068x 5x   4x    
import { IanaName, Territory, WindowsZoneName } from "./enums";
import { map } from "./time-zone-map";
 
export const findIana = (
  windowsTimeZone: WindowsZoneName,
  territory: Territory = Territory["001"],
): IanaName[] | undefined => {
  const entry = map.find(
    ({ windowsName: itemName, territory: itemTerritory }) =>
      itemName === windowsTimeZone && itemTerritory === territory,
  );
 
  if (typeof entry === "undefined") return undefined;
 
  return entry.iana;
};
 
export const findOneIana = (
  windowsTimeZone: WindowsZoneName,
  territory: Territory = Territory["001"],
): IanaName | undefined => {
  const result = findIana(windowsTimeZone, territory);
  if (typeof result === "undefined") return undefined;
  return result[0];
};
 
export const findWindows = (ianaTimeZone: IanaName): WindowsZoneName | undefined => {
  const entry = map.find(({ iana: itemName }) => itemName.includes(ianaTimeZone));
  if (typeof entry === "undefined") return undefined;
 
  return entry.windowsName;
};