# @youngbeen/workday

> Workday/holiday util

Latest version **0.2.9** (published 2026-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @youngbeen/workday
pnpm add @youngbeen/workday
yarn add @youngbeen/workday
bun add @youngbeen/workday
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.9 |
| Published | 2026-11-19 |
| First published | 2023-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | youngbeen |
| Maintainers | youngbeen |
| Keywords | workday, holiday, chinese, holiday |

## Links

- npm: https://www.npmjs.com/package/@youngbeen/workday
- Repository: https://github.com/youngbeen/workday
- Homepage: https://github.com/youngbeen/workday#readme
- Issues: https://github.com/youngbeen/workday/issues
- npm.io page: https://npm.io/package/@youngbeen/workday

## Dependencies (1)

- [@youngbeen/angle-util](https://npm.io/package/@youngbeen/angle-util.md) ^1.3.16

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.9 (latest) — 2026-11-19
- 0.2.8 — 2025-12-01
- 0.2.7 — 2024-12-02
- 0.2.6 — 2023-12-11

## README

# workday

Provides workday and holiday supports in pure JavaScript.
Holiday plans are based on legal holiday plans, you can use custom local plans instead.

> Tip: This repo will be updated every year with new year legal holiday plan released. Hence local dependency should be updated every year as well.

## Install

```shell
npm install @youngbeen/workday
```

## How-to

Wherever you want to use, import the apis you need. e.g.

```javascript
import { isWeekend, getFollowWorkday } from '@youngbeen/workday'
```

## Apis

### Determine a date is workday or holiday

`getDayType(date)`

date - date to check, any valid date type

Example:

```javascript
getDayType('2022-01-14') // -> 'workday'
getDayType('2022-01-16 10:23:32') // -> 'holiday'
getDayType(new Date())
```

### Check a date is workday or not

`isWorkday(date)`

date - date to check, any valid date type

Example:

```javascript
isWorkday('2022-01-14') // -> true
isWorkday('2022-01-16 10:23:32') // -> false
isWorkday(new Date())
```

### Check a date is weekend or not

`isWeekend(date)`

date - date to check, any valid date type

Example:

```javascript
isWeekend('2022-01-14') // -> false
isWeekend('2022-01-16 10:23:32') // -> true
isWeekend(new Date())
```

### Get a date's following workday

`getFollowWorkday(date)`

date - a date, any valid date type

Example:

```javascript
getFollowWorkday('2022-01-13') // return the 14th Jan 2022 by local timezone
getFollowWorkday('2022-01-14 10:23:32') // return the 17th Jan 2022 by local timezone
getFollowWorkday(new Date()) // return today's follow workday by local timezone
```

### Get a date's next N workday

`getComingWorkday(date, n)`

date - a date, any valid date type
n - count after the date, defaults to 1

Example:

```javascript
getComingWorkday('2022-01-13') // return the first workday after 2022-01-13 by local timezone
getComingWorkday('2022-01-14 10:23:32', 3) // return the third workday after 2022-01-14 10:23:32 by local timezone
getComingWorkday(new Date(), 2) // return the second workday after today by local timezone
```

### Get a date's following day

`getFollowNatureDay(date)`

date - a date, any valid date type

Example:

```javascript
getFollowNatureDay('2022-01-13') // return the 14th Jan 2022 by local timezone
getFollowNatureDay('2022-01-14 10:23:32') // return the 15th Jan 2022 by local timezone
getFollowNatureDay(new Date()) // return today's follow day by local timezone
```

### Get a date's next N day

`getComingNatureDay(date, n)`

date - a date, any valid date type
n - count after the date, defaults to 1

Example:

```javascript
getComingNatureDay('2022-01-13') // return the first day after 2022-01-13 by local timezone
getComingNatureDay('2022-01-14 10:23:32', 3) // return the third day after 2022-01-14 10:23:32 by local timezone
getComingNatureDay(new Date(), 2) // return the second day after today by local timezone
```

### Get a date's next weekday X

`getFollowWeekday(date, x)`

date - a date, any valid date type
x - weekday, 0 - Sunday, 1~6 - Monday~Saturday

Example:

```javascript
getFollowWeekday('2022-01-13', 2) // return the next tuesday after 2022-01-13 by local timezone
getFollowWeekday('2022-01-14 10:23:32', 6) // return the next saturady after 2022-01-14 10:23:32 by local timezone
getFollowWeekday(new Date(), 0) // return the next sunday after today by local timezone
```

---
_Source: https://npm.io/package/@youngbeen/workday · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
