A lightweight library to determine Chinese public holidays and workdays
- 🎯 Accurate - Based on official Chinese government holiday announcements
- 🚀 Lightweight - Zero dependencies, minimal footprint
- 📅 Up-to-date - Regularly updated with latest holiday data
- 💪 TypeScript - Full TypeScript support with type definitions
- 🔄 Comprehensive - Handles both holidays and workdays (including adjusted workdays)
pnpm install @kang8/chinese-holidaysOr using npm:
npm install @kang8/chinese-holidaysOr using yarn:
yarn add @kang8/chinese-holidaysimport { holiday } from '@kang8/chinese-holidays'
const nationalDay = new Date('2022-10-01')
// Check if it's a holiday
holiday.isHoliday(nationalDay) // true
// Check if it's a workday
holiday.isWorkday(nationalDay) // false
// Get the holiday name
holiday.publicHolidayName(nationalDay) // '国庆节'Check if the given date is a holiday (including weekends and public holidays).
holiday.isHoliday(new Date('2022-10-01')) // true - National Day
holiday.isHoliday(new Date('2022-10-08')) // true - Weekend (Saturday)Check if the given date is a workday.
holiday.isWorkday(new Date('2022-10-07')) // false - National Day holiday period
holiday.isWorkday(new Date('2022-10-11')) // true - Regular workdayCheck if the given date is an official public holiday (excluding regular weekends).
holiday.isPublicHoliday(new Date('2022-10-01')) // true - National Day
holiday.isPublicHoliday(new Date('2022-10-08')) // false - Regular weekendCheck if the given date is an adjusted workday (working on weekend due to holiday scheduling).
// October 8, 2022 (Saturday) was a working day to compensate for National Day holiday
holiday.isPublicWorkday(new Date('2022-10-08')) // trueGet the name of the public holiday. Returns null if the date is not a public holiday.
holiday.publicHolidayName(new Date('2022-10-01')) // '国庆节'
holiday.publicHolidayName(new Date('2022-09-30')) // nullHoliday data is sourced from NateScarlet/holiday-cn, which aggregates official announcements from the State Council of China. The data is regularly updated to reflect the latest official holiday schedules.
This project uses pnpm as the package manager.
# Install dependencies
pnpm install
# Build the project
pnpm build
# Run tests
pnpm testContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -am 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- chinese-workday - Another Chinese workday library
- chinese-holidays-node - Node.js Chinese holidays library
- chinese-holidays - Alternative Chinese holidays implementation