variantOn関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The flag a place had on a date: by default the legal one, the flag the law made the national flag, or with { role: "in-use" } the flag
flown in practice. Where the two are different flags the answer says so: other names the second flag and why (Canada before 1965: the Union
Flag was the legal flag and the Red Ensigns were flown). The variant whose years cover the day, the default (the flag of today) when the
date is after the newest change, and null where the package knows no flag for that day (flagOn says why). Only the official and
historical variants have a turn; a de-facto or local flag is never the answer, and a variant with no dates is left out. A date
is a Date (read in UTC) or a string, "1962-09-29", "1962-09" or "1962" (the first day of that month or year). The day a flag
changed belongs to the new flag, and where two variants cover a date (a year-only change) the later one wins. A former
country has an answer only within the years it existed, and only where one of its dated flags covers the day: the Soviet Union's
1936 flag from 1936-12-05, its 1955 flag to 1991-12-25, and null before and after. null also means the place has no
dated flags here yet: ask flag(code) for the flag of today.
A restricted flag (Germany's of 1935 to 1945) is found, with its restricted reason, and withheld is true: it is never given as a
drawing unless allowRestricted: true.
インポート
import { variantOn } from "@johnmorrisdotca/hata/manifest";
定義
function variantOn(code: string, date: string | Date, options?: VariantOptions): DatedVariant | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
code | string | A code in any case: "CA", "us", "SUHH", "URS". |
date | string | Date | The day: a |
options (省略可) | VariantOptions | undefined |
|
戻り値
DatedVariant | null
The variant in use that day with its role, other and withheld, or null when the package has no flag for the place on that day in that role (before its first known flag, after a former country's end, in a gap, or for a place with no dated flags).
例
import { variantOn } from "@johnmorrisdotca/hata/manifest";
console.log(variantOn("CA", "1962-09-29")?.id); // "union-flag": the legal flag
console.log(variantOn("CA", "1962-09-29", { role: "in-use" })?.id); // "red-ensign-1957": flown in practice
console.log(variantOn("CA", "1965-02-15")?.id); // "maple-leaf": the day the new flag came in belongs to it
console.log(variantOn("CA", "2026-01-01")?.other); // null: after the newest change, one flag is both
console.log(variantOn("US", "1950")?.id); // "stars-48"
console.log(variantOn("SUHH", "1991-12-26")); // null: the Soviet Union had ended the day before
console.log(variantOn("DE", "1940")?.withheld); // true: restricted, with its reason and no drawingunion-flag
red-ensign-1957
maple-leaf
null
stars-48
null
true出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。