@liha-labs/holiday
v0.1.0
Published
Japanese holiday library synced from official data
Readme
@liha-labs/holiday
日本の祝日を扱う ESM ライブラリです。
- 祝日判定は公式データベース準拠(計算ロジックなし)
holidayName()はstring | nullgetHoliday()/list*()はweekday付きの詳細を返却
Install
pnpm add @liha-labs/holidayExports
@liha-labs/holiday@liha-labs/holiday/full
default export はありません。
Main Types
export type Holiday = { date: "YYYY-MM-DD"; name: string };
export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6; // 0=Sun ... 6=Sat
export type HolidayDetail = Holiday & { weekday: Weekday };
export type ClientOptions = {
remoteBaseUrl?: string;
fetch?: typeof globalThis.fetch;
cache?: "memory" | "none";
};API
holidayName(input: Date | string): Promise<string | null>
isHoliday(input: Date | string): Promise<boolean>
getHoliday(input: Date | string): Promise<HolidayDetail | null>
listYear(year: number): Promise<HolidayDetail[]>
listMonth(ym: `${number}-${string}`): Promise<HolidayDetail[]>
listRange(start: Date | string, end: Date | string): Promise<HolidayDetail[]>
listAll(): Promise<HolidayDetail[]>
createClient(options?: ClientOptions): HolidayClient
info(): InfoBasic Usage
import {
createClient,
getHoliday,
holidayName,
isHoliday,
listMonth,
listRange,
listYear,
info
} from "@liha-labs/holiday";
await holidayName("2026-01-01");
// => "元日"
await isHoliday("2026-01-02");
// => false
await getHoliday("2026-01-01");
// => { date: "2026-01-01", name: "元日", weekday: 4 }
await listYear(2026);
await listMonth("2026-01");
await listRange("2026-01-01", "2026-12-31");
const meta = info();
const client = createClient({ cache: "memory" });
await client.listYear(2035);Full Entry Usage
import { createClient, listAll, listYear } from "@liha-labs/holiday/full";
await listYear(2026);
await listAll();
const fullClient = createClient();
await fullClient.getHoliday("2026-01-01");Input Rules
Dateはローカル日付としてgetFullYear()/getMonth()/getDate()で正規化- 文字列は
YYYY-MM-DDのみ許可 listMonthはYYYY-MMのみ許可- 不正日付はエラー
weekdayはランタイムでnew Date(y, m - 1, d).getDay()から算出
