indian-banking-holiday 1.0.0
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/LICENSE +201 -0
- package/README.md +336 -0
- package/dist/index.d.mts +93 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +215 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +203 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# Indian Banking Holiday
|
|
2
|
+
|
|
3
|
+
A lightweight, zero-dependency npm library for Indian banking holidays. Query holidays by date, state, or date range. All banks in India follow the same holidays as per RBI regulations.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Comprehensive Coverage** — National, state-specific, and regional holidays (2025-2027)
|
|
8
|
+
- **State-wise Filtering** — Get holidays for any Indian state or union territory
|
|
9
|
+
- **TypeScript Support** — Full type definitions included
|
|
10
|
+
- **Simple API** — Easy-to-use functions for common queries
|
|
11
|
+
- **Date Range Queries** — Get holidays within any date range
|
|
12
|
+
- **Zero Dependencies** — Lightweight and fast
|
|
13
|
+
- **ESM & CommonJS** — Works with both module systems
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install indian-banking-holiday
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import {
|
|
25
|
+
getAllHolidays,
|
|
26
|
+
getHolidaysByYear,
|
|
27
|
+
getHolidaysByState,
|
|
28
|
+
isHoliday,
|
|
29
|
+
getNextHoliday,
|
|
30
|
+
} from 'indian-banking-holiday';
|
|
31
|
+
|
|
32
|
+
// Get all holidays
|
|
33
|
+
const allHolidays = getAllHolidays();
|
|
34
|
+
|
|
35
|
+
// Get holidays for a specific year
|
|
36
|
+
const holidays2026 = getHolidaysByYear(2026);
|
|
37
|
+
|
|
38
|
+
// Check if a date is a holiday
|
|
39
|
+
isHoliday('2026-01-26'); // true (Republic Day)
|
|
40
|
+
|
|
41
|
+
// Get holidays for a specific state
|
|
42
|
+
const maharashtraHolidays = getHolidaysByState('Maharashtra', 2026);
|
|
43
|
+
|
|
44
|
+
// Get the next upcoming holiday
|
|
45
|
+
const nextHoliday = getNextHoliday();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API Reference
|
|
49
|
+
|
|
50
|
+
### `getAllHolidays()`
|
|
51
|
+
|
|
52
|
+
Returns all banking holidays in the database.
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
const holidays = getAllHolidays();
|
|
56
|
+
// Returns: Holiday[]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### `getHolidays(options?)`
|
|
60
|
+
|
|
61
|
+
Query holidays with flexible filtering options.
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// Get holidays for a year
|
|
65
|
+
const result = getHolidays({ year: 2026 });
|
|
66
|
+
|
|
67
|
+
// Get holidays for a specific month
|
|
68
|
+
const janHolidays = getHolidays({ year: 2026, month: 1 });
|
|
69
|
+
|
|
70
|
+
// Get holidays for a state
|
|
71
|
+
const stateHolidays = getHolidays({
|
|
72
|
+
state: 'Maharashtra',
|
|
73
|
+
year: 2026
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Get holidays in a date range
|
|
77
|
+
const rangeHolidays = getHolidays({
|
|
78
|
+
startDate: '2026-01-01',
|
|
79
|
+
endDate: '2026-03-31',
|
|
80
|
+
state: 'Karnataka'
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Options:**
|
|
85
|
+
|
|
86
|
+
| Option | Type | Description |
|
|
87
|
+
|--------|------|-------------|
|
|
88
|
+
| `year` | `number` | Filter by year |
|
|
89
|
+
| `month` | `number` | Filter by month (1-12) |
|
|
90
|
+
| `state` | `IndianState` | Filter by state |
|
|
91
|
+
| `startDate` | `string` | Start date (YYYY-MM-DD) |
|
|
92
|
+
| `endDate` | `string` | End date (YYYY-MM-DD) |
|
|
93
|
+
|
|
94
|
+
**Returns:** `HolidayResult` with `holidays`, `total`, and `query` properties.
|
|
95
|
+
|
|
96
|
+
### `getHolidaysByYear(year)`
|
|
97
|
+
|
|
98
|
+
Get all holidays for a specific year.
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const holidays2026 = getHolidaysByYear(2026);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### `getHolidaysByMonth(year, month)`
|
|
105
|
+
|
|
106
|
+
Get holidays for a specific month.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const janHolidays = getHolidaysByMonth(2026, 1);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### `getHolidaysByState(state, year?)`
|
|
113
|
+
|
|
114
|
+
Get holidays for a specific state.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const maharashtraHolidays = getHolidaysByState('Maharashtra', 2026);
|
|
118
|
+
const allMaharashtraHolidays = getHolidaysByState('Maharashtra'); // all years
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### `getHolidaysByDateRange(startDate, endDate, options?)`
|
|
122
|
+
|
|
123
|
+
Get holidays within a date range.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
const holidays = getHolidaysByDateRange(
|
|
127
|
+
'2026-01-01',
|
|
128
|
+
'2026-03-31',
|
|
129
|
+
{ state: 'Karnataka' }
|
|
130
|
+
);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### `isHoliday(date, state?)`
|
|
134
|
+
|
|
135
|
+
Check if a specific date is a banking holiday.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// Check if a date is a holiday
|
|
139
|
+
isHoliday('2026-01-26'); // true (Republic Day)
|
|
140
|
+
isHoliday('2026-01-27'); // false
|
|
141
|
+
|
|
142
|
+
// Check for a specific state
|
|
143
|
+
isHoliday('2026-05-01', 'Maharashtra'); // true (Maharashtra Day)
|
|
144
|
+
|
|
145
|
+
// Accepts Date objects
|
|
146
|
+
isHoliday(new Date('2026-01-26')); // true
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### `getHolidayByDate(date, state?)`
|
|
150
|
+
|
|
151
|
+
Get holiday information for a specific date. Returns `null` if not a holiday.
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const holiday = getHolidayByDate('2026-01-26');
|
|
155
|
+
// Returns: { date: '2026-01-26', name: 'Republic Day', type: 'National' }
|
|
156
|
+
|
|
157
|
+
const notHoliday = getHolidayByDate('2026-01-27');
|
|
158
|
+
// Returns: null
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### `getNextHoliday(fromDate?, state?)`
|
|
162
|
+
|
|
163
|
+
Get the next banking holiday from a given date (defaults to today).
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
const nextHoliday = getNextHoliday();
|
|
167
|
+
const nextStateHoliday = getNextHoliday(undefined, 'Maharashtra');
|
|
168
|
+
const nextFromDate = getNextHoliday('2026-06-01');
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### `getUpcomingHolidays(days?, state?)`
|
|
172
|
+
|
|
173
|
+
Get upcoming holidays within a specified number of days (default: 30).
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
// Get holidays in next 30 days
|
|
177
|
+
const upcoming = getUpcomingHolidays();
|
|
178
|
+
|
|
179
|
+
// Get holidays in next 60 days for Maharashtra
|
|
180
|
+
const stateUpcoming = getUpcomingHolidays(60, 'Maharashtra');
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### `getHolidayCount(year, state?)`
|
|
184
|
+
|
|
185
|
+
Get the count of holidays for a year.
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
const count = getHolidayCount(2026);
|
|
189
|
+
const stateCount = getHolidayCount(2026, 'Maharashtra');
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Types
|
|
193
|
+
|
|
194
|
+
### `Holiday`
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
interface Holiday {
|
|
198
|
+
date: string; // ISO date string (YYYY-MM-DD)
|
|
199
|
+
name: string; // Holiday name
|
|
200
|
+
type: HolidayType; // 'National' | 'State' | 'Regional'
|
|
201
|
+
states?: IndianState[]; // Applicable states (undefined = all states)
|
|
202
|
+
description?: string; // Optional description
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### `HolidayType`
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
type HolidayType = 'National' | 'State' | 'Regional';
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
- **National** — Applies to all states (Republic Day, Independence Day, Gandhi Jayanti)
|
|
213
|
+
- **State** — Specific to certain states (Maharashtra Day, Karnataka Rajyotsava)
|
|
214
|
+
- **Regional** — Regional holidays that may vary by state (Diwali, Holi, Eid)
|
|
215
|
+
|
|
216
|
+
### `IndianState`
|
|
217
|
+
|
|
218
|
+
All 28 states and 8 union territories are supported:
|
|
219
|
+
|
|
220
|
+
**States:** Andhra Pradesh, Arunachal Pradesh, Assam, Bihar, Chhattisgarh, Goa, Gujarat, Haryana, Himachal Pradesh, Jharkhand, Karnataka, Kerala, Madhya Pradesh, Maharashtra, Manipur, Meghalaya, Mizoram, Nagaland, Odisha, Punjab, Rajasthan, Sikkim, Tamil Nadu, Telangana, Tripura, Uttar Pradesh, Uttarakhand, West Bengal
|
|
221
|
+
|
|
222
|
+
**Union Territories:** Andaman and Nicobar Islands, Chandigarh, Dadra and Nagar Haveli and Daman and Diu, Delhi, Jammu and Kashmir, Ladakh, Lakshadweep, Puducherry
|
|
223
|
+
|
|
224
|
+
### `HolidayQueryOptions`
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
interface HolidayQueryOptions {
|
|
228
|
+
year?: number;
|
|
229
|
+
month?: number; // 1-12
|
|
230
|
+
state?: IndianState;
|
|
231
|
+
startDate?: string; // YYYY-MM-DD
|
|
232
|
+
endDate?: string; // YYYY-MM-DD
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### `HolidayResult`
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
interface HolidayResult {
|
|
240
|
+
holidays: Holiday[];
|
|
241
|
+
total: number;
|
|
242
|
+
query: HolidayQueryOptions;
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Examples
|
|
247
|
+
|
|
248
|
+
### Check if payment can be processed
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { isHoliday } from 'indian-banking-holiday';
|
|
252
|
+
|
|
253
|
+
function canProcessPayment(date: Date): boolean {
|
|
254
|
+
const isWeekend = date.getDay() === 0 || date.getDay() === 6;
|
|
255
|
+
return !isWeekend && !isHoliday(date);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const paymentDate = new Date('2026-01-26');
|
|
259
|
+
if (canProcessPayment(paymentDate)) {
|
|
260
|
+
console.log('Payment can be processed');
|
|
261
|
+
} else {
|
|
262
|
+
console.log('Payment date is a weekend or banking holiday');
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Find next working day
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
import { isHoliday } from 'indian-banking-holiday';
|
|
270
|
+
|
|
271
|
+
function getNextWorkingDay(date: Date): Date {
|
|
272
|
+
const nextDay = new Date(date);
|
|
273
|
+
nextDay.setDate(nextDay.getDate() + 1);
|
|
274
|
+
|
|
275
|
+
// Skip weekends and holidays
|
|
276
|
+
while (nextDay.getDay() === 0 || nextDay.getDay() === 6 || isHoliday(nextDay)) {
|
|
277
|
+
nextDay.setDate(nextDay.getDate() + 1);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return nextDay;
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Get upcoming holidays for planning
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
import { getUpcomingHolidays } from 'indian-banking-holiday';
|
|
288
|
+
|
|
289
|
+
const upcoming = getUpcomingHolidays(90, 'Maharashtra');
|
|
290
|
+
|
|
291
|
+
console.log('Upcoming holidays in Maharashtra:');
|
|
292
|
+
upcoming.forEach(holiday => {
|
|
293
|
+
console.log(`${holiday.date}: ${holiday.name}`);
|
|
294
|
+
});
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### List all state holidays
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
import { getHolidaysByState } from 'indian-banking-holiday';
|
|
301
|
+
|
|
302
|
+
const karnatakaHolidays = getHolidaysByState('Karnataka', 2026);
|
|
303
|
+
console.log(`Karnataka has ${karnatakaHolidays.length} holidays in 2026`);
|
|
304
|
+
|
|
305
|
+
karnatakaHolidays.forEach(h => {
|
|
306
|
+
console.log(`${h.date} - ${h.name} (${h.type})`);
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Data Coverage
|
|
311
|
+
|
|
312
|
+
The library includes holiday data for:
|
|
313
|
+
- **2025** — Complete
|
|
314
|
+
- **2026** — Complete (validated against HDFC Bank holiday list)
|
|
315
|
+
- **2027** — Complete
|
|
316
|
+
|
|
317
|
+
Holiday data is sourced from official bank holiday lists and RBI notifications.
|
|
318
|
+
|
|
319
|
+
## Contributing
|
|
320
|
+
|
|
321
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
322
|
+
|
|
323
|
+
To add or update holiday data:
|
|
324
|
+
1. Update `src/holidays.ts`
|
|
325
|
+
2. Run `npm run build`
|
|
326
|
+
3. Run `npm test` to validate
|
|
327
|
+
|
|
328
|
+
## License
|
|
329
|
+
|
|
330
|
+
ISC
|
|
331
|
+
|
|
332
|
+
## Links
|
|
333
|
+
|
|
334
|
+
- [GitHub Repository](https://github.com/abhiiitr6002/Indian-banking-holiday)
|
|
335
|
+
- [Report Issues](https://github.com/abhiiitr6002/Indian-banking-holiday/issues)
|
|
336
|
+
- [npm Package](https://www.npmjs.com/package/indian-banking-holiday)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indian states and union territories
|
|
3
|
+
*/
|
|
4
|
+
type IndianState = 'Andhra Pradesh' | 'Arunachal Pradesh' | 'Assam' | 'Bihar' | 'Chhattisgarh' | 'Goa' | 'Gujarat' | 'Haryana' | 'Himachal Pradesh' | 'Jharkhand' | 'Karnataka' | 'Kerala' | 'Madhya Pradesh' | 'Maharashtra' | 'Manipur' | 'Meghalaya' | 'Mizoram' | 'Nagaland' | 'Odisha' | 'Punjab' | 'Rajasthan' | 'Sikkim' | 'Tamil Nadu' | 'Telangana' | 'Tripura' | 'Uttar Pradesh' | 'Uttarakhand' | 'West Bengal' | 'Andaman and Nicobar Islands' | 'Chandigarh' | 'Dadra and Nagar Haveli and Daman and Diu' | 'Delhi' | 'Jammu and Kashmir' | 'Ladakh' | 'Lakshadweep' | 'Puducherry';
|
|
5
|
+
/**
|
|
6
|
+
* Holiday type
|
|
7
|
+
*/
|
|
8
|
+
type HolidayType = 'National' | 'State' | 'Regional';
|
|
9
|
+
/**
|
|
10
|
+
* Holiday information
|
|
11
|
+
*/
|
|
12
|
+
interface Holiday {
|
|
13
|
+
date: string;
|
|
14
|
+
name: string;
|
|
15
|
+
type: HolidayType;
|
|
16
|
+
states?: IndianState[];
|
|
17
|
+
description?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Query options for holiday lookup
|
|
21
|
+
*/
|
|
22
|
+
interface HolidayQueryOptions {
|
|
23
|
+
year?: number;
|
|
24
|
+
month?: number;
|
|
25
|
+
state?: IndianState;
|
|
26
|
+
startDate?: string;
|
|
27
|
+
endDate?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Holiday result with metadata
|
|
31
|
+
*/
|
|
32
|
+
interface HolidayResult {
|
|
33
|
+
holidays: Holiday[];
|
|
34
|
+
total: number;
|
|
35
|
+
query: HolidayQueryOptions;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get all banking holidays
|
|
40
|
+
*/
|
|
41
|
+
declare function getAllHolidays(): Holiday[];
|
|
42
|
+
/**
|
|
43
|
+
* Query holidays based on various filters
|
|
44
|
+
*/
|
|
45
|
+
declare function getHolidays(options?: HolidayQueryOptions): HolidayResult;
|
|
46
|
+
/**
|
|
47
|
+
* Get holidays for a specific year
|
|
48
|
+
*/
|
|
49
|
+
declare function getHolidaysByYear(year: number): Holiday[];
|
|
50
|
+
/**
|
|
51
|
+
* Get holidays for a specific month
|
|
52
|
+
*/
|
|
53
|
+
declare function getHolidaysByMonth(year: number, month: number): Holiday[];
|
|
54
|
+
/**
|
|
55
|
+
* Get holidays for a specific state
|
|
56
|
+
*/
|
|
57
|
+
declare function getHolidaysByState(state: IndianState, year?: number): Holiday[];
|
|
58
|
+
/**
|
|
59
|
+
* Get holidays for a date range
|
|
60
|
+
*/
|
|
61
|
+
declare function getHolidaysByDateRange(startDate: string, endDate: string, options?: Omit<HolidayQueryOptions, 'startDate' | 'endDate'>): Holiday[];
|
|
62
|
+
/**
|
|
63
|
+
* Check if a specific date is a banking holiday
|
|
64
|
+
* @param date - Date to check (string in YYYY-MM-DD format or Date object)
|
|
65
|
+
* @param state - Optional state filter
|
|
66
|
+
*/
|
|
67
|
+
declare function isHoliday(date: string | Date, state?: IndianState): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Get holiday information for a specific date
|
|
70
|
+
* @param date - Date to check (string in YYYY-MM-DD format or Date object)
|
|
71
|
+
* @param state - Optional state filter
|
|
72
|
+
*/
|
|
73
|
+
declare function getHolidayByDate(date: string | Date, state?: IndianState): Holiday | null;
|
|
74
|
+
/**
|
|
75
|
+
* Get the next banking holiday from a given date
|
|
76
|
+
* @param fromDate - Starting date (defaults to today)
|
|
77
|
+
* @param state - Optional state filter
|
|
78
|
+
*/
|
|
79
|
+
declare function getNextHoliday(fromDate?: string | Date, state?: IndianState): Holiday | null;
|
|
80
|
+
/**
|
|
81
|
+
* Get upcoming holidays within a specified number of days
|
|
82
|
+
* @param days - Number of days to look ahead (default: 30)
|
|
83
|
+
* @param state - Optional state filter
|
|
84
|
+
*/
|
|
85
|
+
declare function getUpcomingHolidays(days?: number, state?: IndianState): Holiday[];
|
|
86
|
+
/**
|
|
87
|
+
* Get holidays count for a year
|
|
88
|
+
* @param year - Year to get count for
|
|
89
|
+
* @param state - Optional state filter
|
|
90
|
+
*/
|
|
91
|
+
declare function getHolidayCount(year: number, state?: IndianState): number;
|
|
92
|
+
|
|
93
|
+
export { type Holiday, type HolidayQueryOptions, type HolidayResult, type HolidayType, type IndianState, getAllHolidays, getHolidayByDate, getHolidayCount, getHolidays, getHolidaysByDateRange, getHolidaysByMonth, getHolidaysByState, getHolidaysByYear, getNextHoliday, getUpcomingHolidays, isHoliday };
|