Skip to the content

Hata旗

Load a native country or region flag, choose supported framing and keep each drawing’s source, author and licence.

Hata (旗) is Japanese for a flag. About the name

Contents

Reference · Flag source and framing metadata

variantOnfunction

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 it

import { variantOn } from "@johnmorrisdotca/hata/manifest";

Definition

function variantOn(code: string, date: string | Date, options?: VariantOptions): DatedVariant | null

Parameters

NameTypeDescription
codestring

A code in any case: "CA", "us", "SUHH", "URS".

datestring | Date

The day: a Date, or "YYYY-MM-DD", "YYYY-MM" or "YYYY".

options (optional)VariantOptions | undefined

role (legal, the default, or in-use) and allowRestricted.

Returns

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).

Examples

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 drawing
union-flag
red-ensign-1957
maple-leaf
null
stars-48
null
true

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hata 1.31.0.