本文へ移動

Kuni国

国、コード、名前、行政区画を調べ、必要なときに国のデータを読み込み、標準の国のカードを表示できます。

「国(くに)」は、国を表す日本語です。 名前について(英語)

目次

リファレンス · /zones

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

引数

名前型説明
codestring

The country the point is in, an ISO 3166-1 alpha-2 code in either case.

pointLatLon

The point, { lat, lon } in degrees.

戻り値

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/kuni 1.19.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。