timeZoneAt関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
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 { timeZoneAt } from "@johnmorrisdotca/kuni/zones";
定義
function timeZoneAt(code: string, point: LatLon): ZoneAnswer | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
code | string | The country the point is in, an ISO 3166-1 alpha-2 code in either case. |
point | LatLon | The point, |
戻り値
ZoneAnswer | null
The zone and whether it was estimated; null for a code that is not a country or a country with no zone.
例
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_Angeles出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。