timeZoneAtfunction
The IANA time zone at a point in a country, and whether it is known or estimated.
A country with one zone gives that zone, estimated: false. In a country with several: a point within 30 km of a
zone's principal city in IANA's zone.tab takes that zone (Ciudad Juárez, America/Ciudad_Juarez); any other takes the
zone of the subdivision whose capital or middle is nearest (subdivisionTimeZone). Both are estimated: true.
Limits, since kuni has no boundaries: a point near the edge of a state or province can be given its neighbour's
zone; a subdivision split between zones gives its most-populous part's (East Tennessee is given Central time); and a
place that keeps a different rule inside a subdivision is not known (the Navajo Nation keeps daylight saving time in
Arizona). Say "estimated" where it is shown. A map of regions that knows the region asks subdivisionTimeZone.
Import it
import { timeZoneAt } from "@johnmorrisdotca/kuni/zones";
Definition
function timeZoneAt(code: string, point: LatLon): ZoneAnswer | null
Parameters
| Name | Type | Description |
|---|---|---|
code | string | The country the point is in, an ISO 3166-1 alpha-2 code in either case. |
point | LatLon | The point, |
Returns
ZoneAnswer | null
The zone and whether it was estimated; null for a code that is not a country or a country with no zone.
Examples
import { timeZoneAt } from "@johnmorrisdotca/kuni/zones";
console.log(timeZoneAt("JP", { lat: 43.06, lon: 141.35 })); // { zone: "Asia/Tokyo", estimated: false }
console.log(timeZoneAt("US", { lat: 47.61, lon: -122.33 })?.zone); // "America/Los_Angeles"{ zone: 'Asia/Tokyo', estimated: false }
America/Los_AngelesWhat it prints (run when this page was built)