query-taiwan-holiday
Query Taiwan Holiday
Overview
Resolve whether a Taiwan date is a holiday or workday using the official holidaytw CLI when possible, automatically adapting to whatever tools are available in the current environment, and falling back to the static JSON API only when no trusted CLI install path works.
1. Validate the date
Require one exact ASCII ISO date (YYYY-MM-DD). Reject whitespace, timestamps, slashes, impossible dates (e.g. 2026-02-30), and anything that does not round-trip through a calendar-aware date parser. Never proceed with an unvalidated or guessed date.
2. Resolve a way to query — try candidates in order, falling through on failure
Attempt each candidate that is applicable to the current environment, in order. If one fails (command not found, install error, network failure for that step), do not stop or give up — continue to the next candidate. Only after every applicable candidate below, including the static API fallback in step 4, has failed should you report retrieval failure.
- Already installed — check
command -v holidaytw(POSIX shells) orGet-Command holidaytw(PowerShell). If found, use it directly. - npm / npx — when Node.js 20 or newer and npm are available, run the officially published package without requiring a global install: