UNPKG

@hyunbinseo/holidays-kr

Version:

South Korea's national holidays, based on the official gazette

34 lines (33 loc) 1.97 kB
import { n as y2018 } from "./2018-C5AwMa7y.js"; import { n as y2019 } from "./2019-CsvcRi6c.js"; import { n as y2020 } from "./2020-Do-jf8yU.js"; import { n as y2021 } from "./2021-kMgaJFlk.js"; import { n as y2022 } from "./2022-JrHXz0nq.js"; import { n as y2023 } from "./2023-B1YUK2Tb.js"; import { n as y2024 } from "./2024-Bc6AOiCH.js"; import { n as y2025 } from "./2025-DhUTK95M.js"; import { n as y2026 } from "./2026-94COvbcH.js"; //#region src/holidays/utils.ts const KST_OFFSET = 540 * 6e4; const modules = /* @__PURE__ */ Object.assign({ "./2018.ts": () => import("./2018-C5AwMa7y.js").then((n) => n.t).then((m) => m["default"]), "./2019.ts": () => import("./2019-CsvcRi6c.js").then((n) => n.t).then((m) => m["default"]), "./2020.ts": () => import("./2020-Do-jf8yU.js").then((n) => n.t).then((m) => m["default"]), "./2021.ts": () => import("./2021-kMgaJFlk.js").then((n) => n.t).then((m) => m["default"]), "./2022.ts": () => import("./2022-JrHXz0nq.js").then((n) => n.t).then((m) => m["default"]), "./2023.ts": () => import("./2023-B1YUK2Tb.js").then((n) => n.t).then((m) => m["default"]), "./2024.ts": () => import("./2024-Bc6AOiCH.js").then((n) => n.t).then((m) => m["default"]), "./2025.ts": () => import("./2025-DhUTK95M.js").then((n) => n.t).then((m) => m["default"]), "./2026.ts": () => import("./2026-94COvbcH.js").then((n) => n.t).then((m) => m["default"]) }); const getHolidayNames = async (date) => { if (!(date instanceof Date)) throw new TypeError(`${date} is not a Date`); const yyyy_mm_dd = new Date(date.valueOf() + KST_OFFSET).toISOString().slice(0, 10); const yyyy = yyyy_mm_dd.slice(0, 4); const loader = modules[`./${yyyy}.ts`]; if (!loader) throw new RangeError(`No preset for year ${yyyy}.`); return (await loader())[yyyy_mm_dd] ?? null; }; const isHoliday = async (date) => !!await getHolidayNames(date); //#endregion export { getHolidayNames, isHoliday, y2018, y2019, y2020, y2021, y2022, y2023, y2024, y2025, y2026 };