soff-date 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -46
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,80 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/bledxs/soff-monorepo/master/assets/logo.png" alt="Soff Logo" width="100" height="100">
|
|
3
|
+
<h1>Soff Date</h1>
|
|
4
|
+
<p>Lightweight, tree-shakeable holiday calculator with algorithmic date computation.</p>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
2
8
|
|
|
3
9
|
[](https://www.npmjs.com/package/soff-date)
|
|
4
|
-
[](LICENSE)
|
|
11
|
+
[](https://github.com/bledxs/soff-monorepo/actions)
|
|
12
|
+
[](https://codecov.io/gh/bledxs/soff-monorepo)
|
|
7
13
|
[](https://bundlephobia.com/package/soff-date)
|
|
8
|
-
[](#contributors)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
---
|
|
11
19
|
|
|
12
20
|
**Zero dependencies** · **TypeScript** · **~3KB per locale**
|
|
13
21
|
|
|
14
22
|
## Table of Contents
|
|
15
23
|
|
|
16
|
-
- [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
|
|
24
|
+
- [Table of Contents](#table-of-contents)
|
|
25
|
+
- [🤔 Why?](#-why)
|
|
26
|
+
- [📦 Install](#-install)
|
|
27
|
+
- [🚀 Quick Start](#-quick-start)
|
|
28
|
+
- [🌍 i18n Support](#-i18n-support)
|
|
29
|
+
- [Available Locales](#available-locales)
|
|
30
|
+
- [Available Languages](#available-languages)
|
|
31
|
+
- [Shift Rules Explained](#shift-rules-explained)
|
|
32
|
+
- [Emiliani (Colombia, Argentina)](#emiliani-colombia-argentina)
|
|
33
|
+
- [Observed US (USA, UK)](#observed-us-usa-uk)
|
|
34
|
+
- [Advanced: Create Your Own Locale](#advanced-create-your-own-locale)
|
|
35
|
+
- [Advanced: Use Algorithms Directly](#advanced-use-algorithms-directly)
|
|
36
|
+
- [Bundle Size](#bundle-size)
|
|
37
|
+
- [API Reference](#api-reference)
|
|
38
|
+
- [`getHolidays(year, options?)`](#getholidaysyear-options)
|
|
39
|
+
- [`isHoliday(date, options?)`](#isholidaydate-options)
|
|
40
|
+
- [`getNextHoliday(from?, options?)`](#getnextholidayfrom-options)
|
|
41
|
+
- [Types](#types)
|
|
42
|
+
- [Contributing](#contributing)
|
|
43
|
+
- [License](#license)
|
|
44
|
+
- [Documentation](#documentation)
|
|
45
|
+
- [Contributors](#contributors)
|
|
46
|
+
|
|
47
|
+
## 🤔 Why?
|
|
48
|
+
|
|
49
|
+
Most holiday libraries ship **giant JSON files** with dates until 2050. This library **calculates dates algorithmically**, supporting:
|
|
50
|
+
|
|
51
|
+
| Feature | Description | Example |
|
|
52
|
+
| ---------------------- | ----------------------------- | ------------------------------- |
|
|
53
|
+
| 📅 **Fixed Dates** | Static dates every year | December 25 (Christmas) |
|
|
54
|
+
| 📆 **Nth Weekday** | Relative weekday calculations | 3rd Monday of January (MLK Day) |
|
|
55
|
+
| ✨ **Easter-relative** | Based on Easter calculation | Good Friday = Easter - 2 days |
|
|
56
|
+
| 🔄 **Shift Rules** | Move holidays to workdays | Colombia's Emiliani Law |
|
|
57
|
+
|
|
58
|
+
**Result:** Tiny bundle size (~3KB) with unlimited year support! 🎉
|
|
59
|
+
|
|
60
|
+
## 📦 Install
|
|
50
61
|
|
|
51
62
|
```bash
|
|
63
|
+
# npm
|
|
52
64
|
npm install soff-date
|
|
65
|
+
|
|
66
|
+
# pnpm
|
|
67
|
+
pnpm add soff-date
|
|
68
|
+
|
|
69
|
+
# yarn
|
|
70
|
+
yarn add soff-date
|
|
71
|
+
|
|
72
|
+
# bun
|
|
73
|
+
bun add soff-date
|
|
53
74
|
```
|
|
54
75
|
|
|
55
|
-
## Quick Start
|
|
76
|
+
## 🚀 Quick Start
|
|
56
77
|
|
|
57
78
|
```typescript
|
|
58
79
|
// Only Colombia included in bundle (~3KB)
|
|
59
80
|
import { getHolidays, isHoliday, getNextHoliday } from 'soff-date/locales/co';
|
|
60
81
|
|
|
61
|
-
// Get all holidays for a year
|
|
82
|
+
// 🏆 Get all holidays for a year
|
|
62
83
|
getHolidays(2025);
|
|
63
84
|
// → [{ date: '2025-01-01', key: 'newYear', name: 'Año Nuevo' }, ...]
|
|
64
85
|
|
|
65
|
-
// Check if a date is a holiday
|
|
86
|
+
// ❓ Check if a date is a holiday
|
|
66
87
|
isHoliday(new Date('2025-01-01'));
|
|
67
88
|
// → { date: '2025-01-01', key: 'newYear', name: 'Año Nuevo' }
|
|
68
89
|
|
|
69
90
|
isHoliday(new Date('2025-01-02'));
|
|
70
91
|
// → null
|
|
71
92
|
|
|
72
|
-
// Get next holiday from a date
|
|
93
|
+
// ➡️ Get next holiday from a date
|
|
73
94
|
getNextHoliday(new Date('2025-01-02'));
|
|
74
95
|
// → { date: '2025-01-06', key: 'epiphany', name: 'Día de los Reyes Magos' }
|
|
75
96
|
```
|
|
76
97
|
|
|
77
|
-
## i18n Support
|
|
98
|
+
## 🌍 i18n Support
|
|
78
99
|
|
|
79
100
|
```typescript
|
|
80
101
|
import { getHolidays } from 'soff-date/locales/co';
|
|
@@ -268,7 +289,7 @@ Thanks goes to these wonderful people ([emoji key](https://all-contributors.js.o
|
|
|
268
289
|
<table>
|
|
269
290
|
<tbody>
|
|
270
291
|
<tr>
|
|
271
|
-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bledxs"><img src="https://avatars.githubusercontent.com/u/90062924?v=4" width="100px;" alt="Luis C. Rojas"/><br /><sub><b>Luis C. Rojas</b></sub></a><br /><a href="https://github.com/bledxs/soff-
|
|
292
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bledxs"><img src="https://avatars.githubusercontent.com/u/90062924?v=4" width="100px;" alt="Luis C. Rojas"/><br /><sub><b>Luis C. Rojas</b></sub></a><br /><a href="https://github.com/bledxs/soff-monorepo/commits?author=bledxs" title="Code">💻</a> <a href="https://github.com/bledxs/soff-monorepo/commits?author=bledxs" title="Documentation">📖</a> <a href="#maintenance-bledxs" title="Maintenance">🚧</a></td>
|
|
272
293
|
</tr>
|
|
273
294
|
</tbody>
|
|
274
295
|
</table>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soff-date",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Lightweight, tree-shakeable holiday calculator with algorithmic date computation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"bugs": {
|
|
163
163
|
"url": "https://github.com/bledxs/soff-monorepo/issues"
|
|
164
164
|
},
|
|
165
|
-
"homepage": "https://github.com/bledxs/soff-monorepo/tree/
|
|
165
|
+
"homepage": "https://github.com/bledxs/soff-monorepo/tree/master/packages/soff-date#readme",
|
|
166
166
|
"engines": {
|
|
167
167
|
"node": ">=20"
|
|
168
168
|
},
|