subdivisionTimeZonefunction
The IANA time zone of a first-level subdivision, by its ISO 3166-2 code: what a map of a country's regions shows.
In a country with one zone, that zone (estimated: false). In a country with several, the zone Wikidata gives the
subdivision where it gives one of the country's zones alone (estimated: false); where it gives several (Indiana,
Idaho) or none, the one whose principal city in IANA's zone.tab is nearest the subdivision's capital
(estimated: true); and for the few kuni has no point for and Wikidata names no zone of (Beijing, Catalonia), the
zone of the country's capital (estimated: true).
Import it
import { subdivisionTimeZone } from "@johnmorrisdotca/kuni/zones";
Definition
function subdivisionTimeZone(code: string): ZoneAnswer | null
Parameters
| Name | Type | Description |
|---|---|---|
code | string | An ISO 3166-2 code, "US-WA" or "us-wa". |
Returns
ZoneAnswer | null
The zone and whether it was estimated; null for a code kuni does not list as a first-level subdivision,
or one in a country with no zone.
Examples
import { subdivisionTimeZone } from "@johnmorrisdotca/kuni/zones";
console.log(subdivisionTimeZone("US-WA")); // { zone: "America/Los_Angeles", estimated: false }
console.log(subdivisionTimeZone("JP-13")?.zone); // "Asia/Tokyo"{ zone: 'America/Los_Angeles', estimated: false }
Asia/TokyoWhat it prints (run when this page was built)