This documentation is primarily intended for users developing in JS
and TS
.
::: info Note For other programming languages, please refer to the section on Non-JS Languages.
Additionally, the project supports iCal
file holiday subscriptions, compatible with clients such as Google Calendar, Apple Calendar, and Microsoft Outlook.
:::
Directly include the library in the browser for the most up-to-date version:
<!-- Include the script -->
<script src="https://cdn.jsdelivr.net/npm/chinese-days"></script>
<!-- Use the library -->
<script>
chineseDays.isHoliday('2024-01-01');
// Or use destructuring
const { isHoliday } = chineseDays;
</script>
Alternatively, use type="module"
with ESM:
<script type="module">
import chineseDays from 'https://esm.run/chinese-days';
// Use the library after importing
chineseDays.isHoliday('2024-01-01');
</script>
npm i chinese-days
Using ESM import:
import chineseDays from 'chinese-days';
console.log(chineseDays);
Using in Node.js:
const { isWorkday, isHoliday } = require('chinese-days');
console.log(isWorkday('2020-01-01'));
console.log(isHoliday('2020-01-01'));
It is generally not recommended to specify a version, as holidays are updated based on announcements from the State Council. If you must specify a version, you can refer to jsdelivr, for example:
https://cdn.jsdelivr.net/npm/chinese-days@1.4.0
https://esm.run/chinese-days@1.4.0