pakdatakit 1.1.0 → 2.1.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 +21 -21
- package/README.md +907 -666
- package/dist/address.cjs +17 -0
- package/dist/address.d.cts +36 -0
- package/dist/address.d.ts +36 -0
- package/dist/address.js +4 -0
- package/dist/chunk-3COX5FSL.cjs +1650 -0
- package/dist/chunk-422X6FEZ.cjs +220 -0
- package/dist/chunk-432ZYMYV.js +31 -0
- package/dist/chunk-4VVFS6FN.cjs +715 -0
- package/dist/chunk-6TSKA2PH.js +38 -0
- package/dist/chunk-APXP7OK7.cjs +226 -0
- package/dist/chunk-AUATLZA5.cjs +168 -0
- package/dist/chunk-BSS4Z7NI.cjs +422 -0
- package/dist/chunk-CEPNSHIC.js +33 -0
- package/dist/chunk-CQKK3S7A.js +217 -0
- package/dist/chunk-CYJJ7KGC.cjs +108 -0
- package/dist/chunk-EEVNLTB4.js +32 -0
- package/dist/chunk-ENQ7O7VW.js +32 -0
- package/dist/chunk-H4DVWUYH.js +231 -0
- package/dist/chunk-H6M6L26S.cjs +37 -0
- package/dist/chunk-HBOZIITD.js +351 -0
- package/dist/chunk-HTCSHHOR.cjs +35 -0
- package/dist/chunk-JKE4AMSZ.js +47 -0
- package/dist/chunk-K6CZFCX6.js +1642 -0
- package/dist/chunk-KEHCTYLO.cjs +52 -0
- package/dist/chunk-KQKW2ZEK.cjs +18 -0
- package/dist/chunk-L2BDDM2W.js +165 -0
- package/dist/chunk-L45UXUWX.js +21 -0
- package/dist/chunk-LIYNKIKS.js +709 -0
- package/dist/chunk-LVHTH4P7.cjs +41 -0
- package/dist/chunk-OVUR47QH.cjs +22 -0
- package/dist/chunk-P4CGOJEM.js +16 -0
- package/dist/chunk-PHHKIMO2.cjs +35 -0
- package/dist/chunk-QQQKISXT.js +223 -0
- package/dist/chunk-T3E4B5MJ.js +417 -0
- package/dist/chunk-VPBMIYO2.cjs +38 -0
- package/dist/chunk-WPKV5JT3.cjs +235 -0
- package/dist/chunk-XCXFGTHW.cjs +355 -0
- package/dist/chunk-XT4ZNXRC.js +20 -0
- package/dist/chunk-Y6BUGLXU.js +95 -0
- package/dist/chunk-YLWZGSFY.cjs +99 -0
- package/dist/chunk-YS7MOLK2.cjs +23 -0
- package/dist/chunk-Z5JEIQVW.js +102 -0
- package/dist/cli.js +78 -2654
- package/dist/cnic.cjs +15 -0
- package/dist/cnic.d.cts +35 -0
- package/dist/cnic.d.ts +35 -0
- package/dist/cnic.js +2 -0
- package/dist/format.cjs +14 -0
- package/dist/format.d.cts +27 -0
- package/dist/format.d.ts +27 -0
- package/dist/format.js +1 -0
- package/dist/geo.cjs +27 -0
- package/dist/geo.d.cts +43 -0
- package/dist/geo.d.ts +43 -0
- package/dist/geo.js +2 -0
- package/dist/hijri.cjs +26 -0
- package/dist/hijri.d.cts +62 -0
- package/dist/hijri.d.ts +62 -0
- package/dist/hijri.js +1 -0
- package/dist/holidays.cjs +19 -0
- package/dist/holidays.d.cts +72 -0
- package/dist/holidays.d.ts +72 -0
- package/dist/holidays.js +2 -0
- package/dist/iban.cjs +15 -0
- package/dist/iban.d.cts +21 -0
- package/dist/iban.d.ts +21 -0
- package/dist/iban.js +2 -0
- package/dist/index.cjs +211 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -300
- package/dist/index.js +18 -2764
- package/dist/networks.cjs +12 -0
- package/dist/networks.d.cts +20 -0
- package/dist/networks.d.ts +20 -0
- package/dist/networks.js +3 -0
- package/dist/numbers.cjs +24 -0
- package/dist/numbers.d.cts +53 -0
- package/dist/numbers.d.ts +53 -0
- package/dist/numbers.js +3 -0
- package/dist/phone.cjs +29 -0
- package/dist/phone.d.cts +56 -0
- package/dist/phone.d.ts +56 -0
- package/dist/phone.js +4 -0
- package/dist/postal.cjs +27 -0
- package/dist/postal.d.cts +40 -0
- package/dist/postal.d.ts +40 -0
- package/dist/postal.js +2 -0
- package/dist/raast.cjs +20 -0
- package/dist/raast.d.cts +119 -0
- package/dist/raast.d.ts +119 -0
- package/dist/raast.js +3 -0
- package/dist/rules-GxgPiVws.d.cts +7 -0
- package/dist/rules-GxgPiVws.d.ts +7 -0
- package/dist/tax.cjs +20 -0
- package/dist/tax.d.cts +47 -0
- package/dist/tax.d.ts +47 -0
- package/dist/tax.js +3 -0
- package/dist/text.cjs +23 -0
- package/dist/text.d.cts +34 -0
- package/dist/text.d.ts +34 -0
- package/dist/text.js +2 -0
- package/dist/valibot.cjs +47 -0
- package/dist/valibot.d.cts +22 -0
- package/dist/valibot.d.ts +22 -0
- package/dist/valibot.js +25 -0
- package/dist/whatsapp.cjs +12 -0
- package/dist/whatsapp.d.cts +12 -0
- package/dist/whatsapp.d.ts +12 -0
- package/dist/whatsapp.js +3 -0
- package/dist/words.cjs +14 -0
- package/dist/words.d.cts +49 -0
- package/dist/words.d.ts +49 -0
- package/dist/words.js +1 -0
- package/dist/yup.cjs +32 -0
- package/dist/yup.d.cts +22 -0
- package/dist/yup.d.ts +22 -0
- package/dist/yup.js +30 -0
- package/dist/zod.cjs +27 -0
- package/dist/zod.d.cts +22 -0
- package/dist/zod.d.ts +22 -0
- package/dist/zod.js +25 -0
- package/package.json +309 -77
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkCYJJ7KGC_cjs = require('./chunk-CYJJ7KGC.cjs');
|
|
4
|
+
|
|
5
|
+
// data/holidays.json
|
|
6
|
+
var holidays_default = {
|
|
7
|
+
"2020": {
|
|
8
|
+
eidUlFitr: {
|
|
9
|
+
dates: [
|
|
10
|
+
"2020-05-22",
|
|
11
|
+
"2020-05-23",
|
|
12
|
+
"2020-05-24",
|
|
13
|
+
"2020-05-25",
|
|
14
|
+
"2020-05-26",
|
|
15
|
+
"2020-05-27"
|
|
16
|
+
],
|
|
17
|
+
source: "https://www.sbp.org.pk/bprd/2020/CL23.htm"
|
|
18
|
+
},
|
|
19
|
+
eidUlAdha: {
|
|
20
|
+
dates: ["2020-07-31", "2020-08-01", "2020-08-02"],
|
|
21
|
+
source: "https://www.sbp.org.pk/bprd/2020/CL35.htm"
|
|
22
|
+
},
|
|
23
|
+
ashura: {
|
|
24
|
+
dates: ["2020-08-29", "2020-08-30"],
|
|
25
|
+
source: "https://arynews.tv/muharram-moon-sighting-youm-i-ashur-ruet-e-hilal-committee"
|
|
26
|
+
},
|
|
27
|
+
eidMiladUnNabi: {
|
|
28
|
+
dates: ["2020-10-30"],
|
|
29
|
+
source: "https://www.geo.tv/latest/313746-rabiul-awwal-moon-not-sighted-eid-i-miladun-nabi-on-oct-30"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"2021": {
|
|
33
|
+
eidUlFitr: {
|
|
34
|
+
dates: [
|
|
35
|
+
"2021-05-10",
|
|
36
|
+
"2021-05-11",
|
|
37
|
+
"2021-05-12",
|
|
38
|
+
"2021-05-13",
|
|
39
|
+
"2021-05-14",
|
|
40
|
+
"2021-05-15"
|
|
41
|
+
],
|
|
42
|
+
source: "https://www.sbp.org.pk/bprd/2021/CL13.htm"
|
|
43
|
+
},
|
|
44
|
+
eidUlAdha: {
|
|
45
|
+
dates: ["2021-07-20", "2021-07-21", "2021-07-22"],
|
|
46
|
+
source: "https://www.sbp.org.pk/press/2021/Pr-15-Jul-2021.pdf"
|
|
47
|
+
},
|
|
48
|
+
ashura: {
|
|
49
|
+
dates: ["2021-08-18", "2021-08-19"],
|
|
50
|
+
source: "https://propakistani.pk/2021/08/13/govt-announces-ashura-holidays/"
|
|
51
|
+
},
|
|
52
|
+
eidMiladUnNabi: {
|
|
53
|
+
dates: ["2021-10-19"],
|
|
54
|
+
source: "https://www.geo.tv/latest/376025-eid-milad-un-nabi-govt-notifies-12th-rabi-ul-awal-as-nationwide-public-holiday"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"2022": {
|
|
58
|
+
eidUlFitr: {
|
|
59
|
+
dates: ["2022-05-02", "2022-05-03", "2022-05-04", "2022-05-05"],
|
|
60
|
+
source: "https://www.sbp.org.pk/bprd/2022/CL14.htm"
|
|
61
|
+
},
|
|
62
|
+
eidUlAdha: {
|
|
63
|
+
dates: [
|
|
64
|
+
"2022-07-08",
|
|
65
|
+
"2022-07-09",
|
|
66
|
+
"2022-07-10",
|
|
67
|
+
"2022-07-11",
|
|
68
|
+
"2022-07-12"
|
|
69
|
+
],
|
|
70
|
+
source: "https://www.sbp.org.pk/bprd/2022/CL22.htm"
|
|
71
|
+
},
|
|
72
|
+
ashura: {
|
|
73
|
+
dates: ["2022-08-08", "2022-08-09"],
|
|
74
|
+
source: "https://www.sbp.org.pk/bprd/2022/CL24.htm"
|
|
75
|
+
},
|
|
76
|
+
eidMiladUnNabi: {
|
|
77
|
+
dates: ["2022-10-09"],
|
|
78
|
+
source: "https://www.thenews.com.pk/latest/994846-rabiul-awwal-moon-not-sighted-eid-milad-un-nabi-pbuh-to-be-observed-on-october-9"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"2023": {
|
|
82
|
+
eidUlFitr: {
|
|
83
|
+
dates: [
|
|
84
|
+
"2023-04-21",
|
|
85
|
+
"2023-04-22",
|
|
86
|
+
"2023-04-23",
|
|
87
|
+
"2023-04-24",
|
|
88
|
+
"2023-04-25"
|
|
89
|
+
],
|
|
90
|
+
source: "https://gulfnews.com/world/asia/pakistan/eid-al-fitr-2023-pakistan-announces-five-day-holiday-1.95122615"
|
|
91
|
+
},
|
|
92
|
+
eidUlAdha: {
|
|
93
|
+
dates: ["2023-06-28", "2023-06-29", "2023-06-30"],
|
|
94
|
+
source: "https://cabinet.gov.pk/SiteImage/Misc/files/Holidays/N-22-06-2023.pdf"
|
|
95
|
+
},
|
|
96
|
+
ashura: {
|
|
97
|
+
dates: ["2023-07-28", "2023-07-29"],
|
|
98
|
+
source: "https://thestandard.com.pk/government-announces-public-holidays-on-july-28-29-for-ashura/"
|
|
99
|
+
},
|
|
100
|
+
eidMiladUnNabi: {
|
|
101
|
+
dates: ["2023-09-29"],
|
|
102
|
+
source: "https://www.sbp.org.pk/bprd/2023/CL18.htm"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"2024": {
|
|
106
|
+
eidUlFitr: {
|
|
107
|
+
dates: ["2024-04-10", "2024-04-11", "2024-04-12"],
|
|
108
|
+
source: "https://thefridaytimes.com/04-Apr-2024/govt-announces-eidul-fitr-holidays-from-april-10"
|
|
109
|
+
},
|
|
110
|
+
eidUlAdha: {
|
|
111
|
+
dates: ["2024-06-17", "2024-06-18", "2024-06-19"],
|
|
112
|
+
source: "https://english.aaj.tv/news/330364828/govt-announces-eid-ul-adha-hoildays"
|
|
113
|
+
},
|
|
114
|
+
ashura: {
|
|
115
|
+
dates: ["2024-07-16", "2024-07-17"],
|
|
116
|
+
source: "https://www.sbp.org.pk/bprd/2024/CL14.htm"
|
|
117
|
+
},
|
|
118
|
+
eidMiladUnNabi: {
|
|
119
|
+
dates: ["2024-09-17"],
|
|
120
|
+
source: "https://www.sbp.org.pk/bprd/2024/CL18.htm"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"2025": {
|
|
124
|
+
eidUlFitr: {
|
|
125
|
+
dates: ["2025-03-31", "2025-04-01", "2025-04-02"],
|
|
126
|
+
source: "https://arynews.tv/eidul-fitr-2025-holidays-announcement-pakistan/"
|
|
127
|
+
},
|
|
128
|
+
eidUlAdha: {
|
|
129
|
+
dates: ["2025-06-06", "2025-06-07", "2025-06-08", "2025-06-09"],
|
|
130
|
+
source: "https://www.cabinet.gov.pk/SiteImage/Misc/files/Press%20Release/Eid-ul-Azha-Holidays-02_06_25.pdf"
|
|
131
|
+
},
|
|
132
|
+
ashura: {
|
|
133
|
+
dates: ["2025-07-05", "2025-07-06"],
|
|
134
|
+
source: "https://tribune.com.pk/story/2554016/govt-announces-july-5-6-holidays-on-account-of-ashura"
|
|
135
|
+
},
|
|
136
|
+
eidMiladUnNabi: {
|
|
137
|
+
dates: ["2025-09-06"],
|
|
138
|
+
source: "https://www.sbp.org.pk/bprd/2025/CL19.htm"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"2026": {
|
|
142
|
+
eidUlFitr: {
|
|
143
|
+
dates: ["2026-03-20", "2026-03-21"],
|
|
144
|
+
source: "https://www.app.com.pk/?p=1180682"
|
|
145
|
+
},
|
|
146
|
+
eidUlAdha: {
|
|
147
|
+
dates: ["2026-05-26", "2026-05-27", "2026-05-28"],
|
|
148
|
+
source: "https://pkrevenue.com/pakistan-declares-three-day-eid-ul-adha-2026-holidays/"
|
|
149
|
+
},
|
|
150
|
+
ashura: {
|
|
151
|
+
dates: ["2026-06-25", "2026-06-26"],
|
|
152
|
+
source: "https://en.dailypakistan.com.pk/22-Jun-2026/ashura-holidays-notification-june-2026"
|
|
153
|
+
},
|
|
154
|
+
eidMiladUnNabi: {
|
|
155
|
+
dates: ["2026-08-26"],
|
|
156
|
+
source: "https://www.sbp.org.pk/assets/documents/press-release/PR-25-August-2026.pdf"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// src/holidays.ts
|
|
162
|
+
var FIXED_HOLIDAYS = [
|
|
163
|
+
{
|
|
164
|
+
id: "kashmir-day",
|
|
165
|
+
name: "Kashmir Solidarity Day",
|
|
166
|
+
month: 2,
|
|
167
|
+
day: 5,
|
|
168
|
+
type: "national"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: "pakistan-day",
|
|
172
|
+
name: "Pakistan Day",
|
|
173
|
+
month: 3,
|
|
174
|
+
day: 23,
|
|
175
|
+
type: "national"
|
|
176
|
+
},
|
|
177
|
+
{ id: "labour-day", name: "Labour Day", month: 5, day: 1, type: "national" },
|
|
178
|
+
{
|
|
179
|
+
id: "youm-e-takbeer",
|
|
180
|
+
name: "Youm-e-Takbeer",
|
|
181
|
+
month: 5,
|
|
182
|
+
day: 28,
|
|
183
|
+
type: "national",
|
|
184
|
+
// A one-off holiday in 2024, on the annual list since 2025.
|
|
185
|
+
appliesIn: (year) => year >= 2024
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: "independence-day",
|
|
189
|
+
name: "Independence Day",
|
|
190
|
+
month: 8,
|
|
191
|
+
day: 14,
|
|
192
|
+
type: "national"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: "iqbal-day",
|
|
196
|
+
name: "Iqbal Day",
|
|
197
|
+
month: 11,
|
|
198
|
+
day: 9,
|
|
199
|
+
type: "national",
|
|
200
|
+
// Dropped from 2015 to 2021, restored in 2022.
|
|
201
|
+
appliesIn: (year) => year <= 2014 || year >= 2022
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: "quaid-e-azam-day",
|
|
205
|
+
name: "Quaid-e-Azam Day / Christmas",
|
|
206
|
+
month: 12,
|
|
207
|
+
day: 25,
|
|
208
|
+
type: "national"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
id: "day-after-christmas",
|
|
212
|
+
name: "Day after Christmas",
|
|
213
|
+
month: 12,
|
|
214
|
+
day: 26,
|
|
215
|
+
type: "religious",
|
|
216
|
+
christiansOnly: true
|
|
217
|
+
}
|
|
218
|
+
];
|
|
219
|
+
var ISLAMIC_HOLIDAYS = [
|
|
220
|
+
{
|
|
221
|
+
id: "eid-ul-fitr",
|
|
222
|
+
key: "eidUlFitr",
|
|
223
|
+
name: "Eid ul Fitr",
|
|
224
|
+
hijriMonth: 10,
|
|
225
|
+
hijriDay: 1,
|
|
226
|
+
days: 3
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
id: "eid-ul-adha",
|
|
230
|
+
key: "eidUlAdha",
|
|
231
|
+
name: "Eid ul Adha",
|
|
232
|
+
hijriMonth: 12,
|
|
233
|
+
hijriDay: 10,
|
|
234
|
+
days: 3
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
id: "ashura",
|
|
238
|
+
key: "ashura",
|
|
239
|
+
name: "Ashura",
|
|
240
|
+
hijriMonth: 1,
|
|
241
|
+
hijriDay: 9,
|
|
242
|
+
days: 2
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
id: "eid-milad-un-nabi",
|
|
246
|
+
key: "eidMiladUnNabi",
|
|
247
|
+
name: "Eid Milad un Nabi",
|
|
248
|
+
hijriMonth: 3,
|
|
249
|
+
hijriDay: 12,
|
|
250
|
+
days: 1
|
|
251
|
+
}
|
|
252
|
+
];
|
|
253
|
+
var OBSERVED = holidays_default;
|
|
254
|
+
function isoDate(date) {
|
|
255
|
+
return [
|
|
256
|
+
String(date.getFullYear()).padStart(4, "0"),
|
|
257
|
+
String(date.getMonth() + 1).padStart(2, "0"),
|
|
258
|
+
String(date.getDate()).padStart(2, "0")
|
|
259
|
+
].join("-");
|
|
260
|
+
}
|
|
261
|
+
function assertIsoDate(value) {
|
|
262
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
263
|
+
throw new RangeError(`Expected a YYYY-MM-DD date, received ${value}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function estimateIslamicDates(holiday, year, offset) {
|
|
267
|
+
const firstHijriYear = chunkCYJJ7KGC_cjs.toHijri(new Date(year, 0, 1)).year;
|
|
268
|
+
const dates = [];
|
|
269
|
+
for (let hijriYear = firstHijriYear; hijriYear <= firstHijriYear + 1; hijriYear += 1) {
|
|
270
|
+
const start = chunkCYJJ7KGC_cjs.fromHijri(
|
|
271
|
+
{ year: hijriYear, month: holiday.hijriMonth, day: holiday.hijriDay },
|
|
272
|
+
{ offset }
|
|
273
|
+
);
|
|
274
|
+
for (let i = 0; i < holiday.days; i += 1) {
|
|
275
|
+
const day = new Date(
|
|
276
|
+
start.getFullYear(),
|
|
277
|
+
start.getMonth(),
|
|
278
|
+
start.getDate() + i
|
|
279
|
+
);
|
|
280
|
+
if (day.getFullYear() === year) {
|
|
281
|
+
dates.push(isoDate(day));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return dates;
|
|
286
|
+
}
|
|
287
|
+
function getPakistanHolidays(year, options = {}) {
|
|
288
|
+
if (!Number.isInteger(year) || year < 1948 || year > 9999) {
|
|
289
|
+
throw new RangeError(`Expected a year from 1948, received ${String(year)}`);
|
|
290
|
+
}
|
|
291
|
+
const holidays = [];
|
|
292
|
+
for (const fixed of FIXED_HOLIDAYS) {
|
|
293
|
+
if (fixed.appliesIn && !fixed.appliesIn(year)) continue;
|
|
294
|
+
if (fixed.christiansOnly && !options.includeChristianHolidays) continue;
|
|
295
|
+
holidays.push({
|
|
296
|
+
id: fixed.id,
|
|
297
|
+
name: fixed.name,
|
|
298
|
+
date: isoDate(new Date(year, fixed.month - 1, fixed.day)),
|
|
299
|
+
type: fixed.type,
|
|
300
|
+
estimated: false,
|
|
301
|
+
...fixed.christiansOnly ? { christiansOnly: true } : {}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
const observed = OBSERVED[String(year)];
|
|
305
|
+
for (const islamic of ISLAMIC_HOLIDAYS) {
|
|
306
|
+
const announced = options.announced?.[islamic.id];
|
|
307
|
+
const recorded = observed?.[islamic.key];
|
|
308
|
+
let dates;
|
|
309
|
+
let estimated = false;
|
|
310
|
+
let source;
|
|
311
|
+
if (announced) {
|
|
312
|
+
announced.forEach(assertIsoDate);
|
|
313
|
+
dates = announced;
|
|
314
|
+
} else if (recorded) {
|
|
315
|
+
dates = recorded.dates;
|
|
316
|
+
source = recorded.source;
|
|
317
|
+
} else {
|
|
318
|
+
dates = estimateIslamicDates(islamic, year, options.hijriOffset ?? 0);
|
|
319
|
+
estimated = true;
|
|
320
|
+
}
|
|
321
|
+
for (const date of dates) {
|
|
322
|
+
holidays.push({
|
|
323
|
+
id: islamic.id,
|
|
324
|
+
name: islamic.name,
|
|
325
|
+
date,
|
|
326
|
+
type: "religious",
|
|
327
|
+
estimated,
|
|
328
|
+
...source ? { source } : {}
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return holidays.sort((a, b) => a.date.localeCompare(b.date));
|
|
333
|
+
}
|
|
334
|
+
function getHolidaysOn(date, options = {}) {
|
|
335
|
+
let iso;
|
|
336
|
+
if (typeof date === "string") {
|
|
337
|
+
assertIsoDate(date);
|
|
338
|
+
iso = date;
|
|
339
|
+
} else {
|
|
340
|
+
if (Number.isNaN(date.getTime())) {
|
|
341
|
+
throw new RangeError("Invalid Date");
|
|
342
|
+
}
|
|
343
|
+
iso = isoDate(date);
|
|
344
|
+
}
|
|
345
|
+
return getPakistanHolidays(Number(iso.slice(0, 4)), options).filter(
|
|
346
|
+
(holiday) => holiday.date === iso
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
function isPakistanHoliday(date, options = {}) {
|
|
350
|
+
return getHolidaysOn(date, options).length > 0;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
exports.getHolidaysOn = getHolidaysOn;
|
|
354
|
+
exports.getPakistanHolidays = getPakistanHolidays;
|
|
355
|
+
exports.isPakistanHoliday = isPakistanHoliday;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { validateLandline } from './chunk-T3E4B5MJ.js';
|
|
2
|
+
import { validatePhone } from './chunk-432ZYMYV.js';
|
|
3
|
+
import { validateSTRN, validateNTN } from './chunk-CEPNSHIC.js';
|
|
4
|
+
import { validateCNIC } from './chunk-EEVNLTB4.js';
|
|
5
|
+
import { validateIBAN } from './chunk-CQKK3S7A.js';
|
|
6
|
+
|
|
7
|
+
// src/adapters/rules.ts
|
|
8
|
+
var RULES = {
|
|
9
|
+
cnic: { test: validateCNIC, message: "Invalid CNIC number" },
|
|
10
|
+
phone: { test: validatePhone, message: "Invalid Pakistani mobile number" },
|
|
11
|
+
iban: { test: validateIBAN, message: "Invalid Pakistani IBAN" },
|
|
12
|
+
ntn: { test: validateNTN, message: "Invalid NTN" },
|
|
13
|
+
strn: { test: validateSTRN, message: "Invalid STRN" },
|
|
14
|
+
landline: {
|
|
15
|
+
test: validateLandline,
|
|
16
|
+
message: "Invalid Pakistani landline number"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { RULES };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { lazy, stripSeparators, toAsciiDigits } from './chunk-ENQ7O7VW.js';
|
|
2
|
+
|
|
3
|
+
// data/networks.json
|
|
4
|
+
var networks_default = [
|
|
5
|
+
{ prefix: "0300", network: "Jazz" },
|
|
6
|
+
{ prefix: "0301", network: "Jazz" },
|
|
7
|
+
{ prefix: "0302", network: "Jazz" },
|
|
8
|
+
{ prefix: "0303", network: "Jazz" },
|
|
9
|
+
{ prefix: "0304", network: "Jazz" },
|
|
10
|
+
{ prefix: "0305", network: "Jazz" },
|
|
11
|
+
{ prefix: "0306", network: "Jazz" },
|
|
12
|
+
{ prefix: "0307", network: "Jazz" },
|
|
13
|
+
{ prefix: "0308", network: "Jazz" },
|
|
14
|
+
{ prefix: "0309", network: "Jazz" },
|
|
15
|
+
{ prefix: "0320", network: "Jazz" },
|
|
16
|
+
{ prefix: "0321", network: "Jazz" },
|
|
17
|
+
{ prefix: "0322", network: "Jazz" },
|
|
18
|
+
{ prefix: "0323", network: "Jazz" },
|
|
19
|
+
{ prefix: "0324", network: "Jazz" },
|
|
20
|
+
{ prefix: "0325", network: "Jazz" },
|
|
21
|
+
{ prefix: "0326", network: "Jazz" },
|
|
22
|
+
{ prefix: "0327", network: "Jazz" },
|
|
23
|
+
{ prefix: "0328", network: "Jazz" },
|
|
24
|
+
{ prefix: "0329", network: "Jazz" },
|
|
25
|
+
{ prefix: "0310", network: "Zong" },
|
|
26
|
+
{ prefix: "0311", network: "Zong" },
|
|
27
|
+
{ prefix: "0312", network: "Zong" },
|
|
28
|
+
{ prefix: "0313", network: "Zong" },
|
|
29
|
+
{ prefix: "0314", network: "Zong" },
|
|
30
|
+
{ prefix: "0315", network: "Zong" },
|
|
31
|
+
{ prefix: "0316", network: "Zong" },
|
|
32
|
+
{ prefix: "0317", network: "Zong" },
|
|
33
|
+
{ prefix: "0318", network: "Zong" },
|
|
34
|
+
{ prefix: "0319", network: "Zong" },
|
|
35
|
+
{ prefix: "0370", network: "Zong" },
|
|
36
|
+
{ prefix: "0371", network: "Zong" },
|
|
37
|
+
{ prefix: "0330", network: "Ufone" },
|
|
38
|
+
{ prefix: "0331", network: "Ufone" },
|
|
39
|
+
{ prefix: "0332", network: "Ufone" },
|
|
40
|
+
{ prefix: "0333", network: "Ufone" },
|
|
41
|
+
{ prefix: "0334", network: "Ufone" },
|
|
42
|
+
{ prefix: "0335", network: "Ufone" },
|
|
43
|
+
{ prefix: "0336", network: "Ufone" },
|
|
44
|
+
{ prefix: "0337", network: "Ufone" },
|
|
45
|
+
{ prefix: "0338", network: "Ufone" },
|
|
46
|
+
{ prefix: "0339", network: "Ufone" },
|
|
47
|
+
{ prefix: "0340", network: "Telenor" },
|
|
48
|
+
{ prefix: "0341", network: "Telenor" },
|
|
49
|
+
{ prefix: "0342", network: "Telenor" },
|
|
50
|
+
{ prefix: "0343", network: "Telenor" },
|
|
51
|
+
{ prefix: "0344", network: "Telenor" },
|
|
52
|
+
{ prefix: "0345", network: "Telenor" },
|
|
53
|
+
{ prefix: "0346", network: "Telenor" },
|
|
54
|
+
{ prefix: "0347", network: "Telenor" },
|
|
55
|
+
{ prefix: "0348", network: "Telenor" },
|
|
56
|
+
{ prefix: "0349", network: "Telenor" },
|
|
57
|
+
{ prefix: "0355", network: "SCO" }
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
// src/internal/phone-utils.ts
|
|
61
|
+
var allocatedPrefixes = lazy(
|
|
62
|
+
() => new Set(
|
|
63
|
+
networks_default.map((entry) => entry.prefix)
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
function normalizePhoneDigits(phone) {
|
|
67
|
+
let digits = stripSeparators(toAsciiDigits(phone));
|
|
68
|
+
if (digits.startsWith("+")) {
|
|
69
|
+
digits = digits.slice(1);
|
|
70
|
+
} else if (digits.startsWith("00")) {
|
|
71
|
+
digits = digits.slice(2);
|
|
72
|
+
}
|
|
73
|
+
if (digits.startsWith("92") && digits.length > 10) {
|
|
74
|
+
digits = digits.slice(2);
|
|
75
|
+
}
|
|
76
|
+
if (digits.startsWith("0")) {
|
|
77
|
+
digits = digits.slice(1);
|
|
78
|
+
}
|
|
79
|
+
if (!/^3\d{9}$/.test(digits)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (!allocatedPrefixes().has(`0${digits.slice(0, 3)}`)) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return `92${digits}`;
|
|
86
|
+
}
|
|
87
|
+
function getPhonePrefix(phone) {
|
|
88
|
+
const digits = normalizePhoneDigits(phone);
|
|
89
|
+
if (digits === null) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return `0${digits.slice(2, 5)}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { getPhonePrefix, networks_default, normalizePhoneDigits };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
|
|
4
|
+
|
|
5
|
+
// data/networks.json
|
|
6
|
+
var networks_default = [
|
|
7
|
+
{ prefix: "0300", network: "Jazz" },
|
|
8
|
+
{ prefix: "0301", network: "Jazz" },
|
|
9
|
+
{ prefix: "0302", network: "Jazz" },
|
|
10
|
+
{ prefix: "0303", network: "Jazz" },
|
|
11
|
+
{ prefix: "0304", network: "Jazz" },
|
|
12
|
+
{ prefix: "0305", network: "Jazz" },
|
|
13
|
+
{ prefix: "0306", network: "Jazz" },
|
|
14
|
+
{ prefix: "0307", network: "Jazz" },
|
|
15
|
+
{ prefix: "0308", network: "Jazz" },
|
|
16
|
+
{ prefix: "0309", network: "Jazz" },
|
|
17
|
+
{ prefix: "0320", network: "Jazz" },
|
|
18
|
+
{ prefix: "0321", network: "Jazz" },
|
|
19
|
+
{ prefix: "0322", network: "Jazz" },
|
|
20
|
+
{ prefix: "0323", network: "Jazz" },
|
|
21
|
+
{ prefix: "0324", network: "Jazz" },
|
|
22
|
+
{ prefix: "0325", network: "Jazz" },
|
|
23
|
+
{ prefix: "0326", network: "Jazz" },
|
|
24
|
+
{ prefix: "0327", network: "Jazz" },
|
|
25
|
+
{ prefix: "0328", network: "Jazz" },
|
|
26
|
+
{ prefix: "0329", network: "Jazz" },
|
|
27
|
+
{ prefix: "0310", network: "Zong" },
|
|
28
|
+
{ prefix: "0311", network: "Zong" },
|
|
29
|
+
{ prefix: "0312", network: "Zong" },
|
|
30
|
+
{ prefix: "0313", network: "Zong" },
|
|
31
|
+
{ prefix: "0314", network: "Zong" },
|
|
32
|
+
{ prefix: "0315", network: "Zong" },
|
|
33
|
+
{ prefix: "0316", network: "Zong" },
|
|
34
|
+
{ prefix: "0317", network: "Zong" },
|
|
35
|
+
{ prefix: "0318", network: "Zong" },
|
|
36
|
+
{ prefix: "0319", network: "Zong" },
|
|
37
|
+
{ prefix: "0370", network: "Zong" },
|
|
38
|
+
{ prefix: "0371", network: "Zong" },
|
|
39
|
+
{ prefix: "0330", network: "Ufone" },
|
|
40
|
+
{ prefix: "0331", network: "Ufone" },
|
|
41
|
+
{ prefix: "0332", network: "Ufone" },
|
|
42
|
+
{ prefix: "0333", network: "Ufone" },
|
|
43
|
+
{ prefix: "0334", network: "Ufone" },
|
|
44
|
+
{ prefix: "0335", network: "Ufone" },
|
|
45
|
+
{ prefix: "0336", network: "Ufone" },
|
|
46
|
+
{ prefix: "0337", network: "Ufone" },
|
|
47
|
+
{ prefix: "0338", network: "Ufone" },
|
|
48
|
+
{ prefix: "0339", network: "Ufone" },
|
|
49
|
+
{ prefix: "0340", network: "Telenor" },
|
|
50
|
+
{ prefix: "0341", network: "Telenor" },
|
|
51
|
+
{ prefix: "0342", network: "Telenor" },
|
|
52
|
+
{ prefix: "0343", network: "Telenor" },
|
|
53
|
+
{ prefix: "0344", network: "Telenor" },
|
|
54
|
+
{ prefix: "0345", network: "Telenor" },
|
|
55
|
+
{ prefix: "0346", network: "Telenor" },
|
|
56
|
+
{ prefix: "0347", network: "Telenor" },
|
|
57
|
+
{ prefix: "0348", network: "Telenor" },
|
|
58
|
+
{ prefix: "0349", network: "Telenor" },
|
|
59
|
+
{ prefix: "0355", network: "SCO" }
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
// src/internal/phone-utils.ts
|
|
63
|
+
var allocatedPrefixes = chunkVPBMIYO2_cjs.lazy(
|
|
64
|
+
() => new Set(
|
|
65
|
+
networks_default.map((entry) => entry.prefix)
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
function normalizePhoneDigits(phone) {
|
|
69
|
+
let digits = chunkVPBMIYO2_cjs.stripSeparators(chunkVPBMIYO2_cjs.toAsciiDigits(phone));
|
|
70
|
+
if (digits.startsWith("+")) {
|
|
71
|
+
digits = digits.slice(1);
|
|
72
|
+
} else if (digits.startsWith("00")) {
|
|
73
|
+
digits = digits.slice(2);
|
|
74
|
+
}
|
|
75
|
+
if (digits.startsWith("92") && digits.length > 10) {
|
|
76
|
+
digits = digits.slice(2);
|
|
77
|
+
}
|
|
78
|
+
if (digits.startsWith("0")) {
|
|
79
|
+
digits = digits.slice(1);
|
|
80
|
+
}
|
|
81
|
+
if (!/^3\d{9}$/.test(digits)) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
if (!allocatedPrefixes().has(`0${digits.slice(0, 3)}`)) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return `92${digits}`;
|
|
88
|
+
}
|
|
89
|
+
function getPhonePrefix(phone) {
|
|
90
|
+
const digits = normalizePhoneDigits(phone);
|
|
91
|
+
if (digits === null) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return `0${digits.slice(2, 5)}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
exports.getPhonePrefix = getPhonePrefix;
|
|
98
|
+
exports.networks_default = networks_default;
|
|
99
|
+
exports.normalizePhoneDigits = normalizePhoneDigits;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkYLWZGSFY_cjs = require('./chunk-YLWZGSFY.cjs');
|
|
4
|
+
var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
|
|
5
|
+
|
|
6
|
+
// src/networks.ts
|
|
7
|
+
var prefixMap = chunkVPBMIYO2_cjs.lazy(
|
|
8
|
+
() => new Map(
|
|
9
|
+
chunkYLWZGSFY_cjs.networks_default.map((entry) => [
|
|
10
|
+
entry.prefix,
|
|
11
|
+
entry.network
|
|
12
|
+
])
|
|
13
|
+
)
|
|
14
|
+
);
|
|
15
|
+
function getNetwork(phone) {
|
|
16
|
+
const prefix = chunkYLWZGSFY_cjs.getPhonePrefix(phone);
|
|
17
|
+
if (prefix === null) {
|
|
18
|
+
return "Unknown";
|
|
19
|
+
}
|
|
20
|
+
return prefixMap().get(prefix) ?? "Unknown";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.getNetwork = getNetwork;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// src/hijri.ts
|
|
2
|
+
var HIJRI_MONTHS = [
|
|
3
|
+
"Muharram",
|
|
4
|
+
"Safar",
|
|
5
|
+
"Rabi al-Awwal",
|
|
6
|
+
"Rabi al-Thani",
|
|
7
|
+
"Jumada al-Awwal",
|
|
8
|
+
"Jumada al-Thani",
|
|
9
|
+
"Rajab",
|
|
10
|
+
"Shaaban",
|
|
11
|
+
"Ramadan",
|
|
12
|
+
"Shawwal",
|
|
13
|
+
"Dhu al-Qadah",
|
|
14
|
+
"Dhu al-Hijjah"
|
|
15
|
+
];
|
|
16
|
+
function toHijri(date, options = {}) {
|
|
17
|
+
assertValidDate(date);
|
|
18
|
+
const jdn = gregorianToJulianDayNumber(
|
|
19
|
+
date.getFullYear(),
|
|
20
|
+
date.getMonth() + 1,
|
|
21
|
+
date.getDate()
|
|
22
|
+
);
|
|
23
|
+
return julianDayNumberToHijri(jdn + resolveOffset(options));
|
|
24
|
+
}
|
|
25
|
+
function fromHijri(hijri, options = {}) {
|
|
26
|
+
assertValidHijri(hijri);
|
|
27
|
+
const jdn = hijriToJulianDayNumber(hijri.year, hijri.month, hijri.day) - resolveOffset(options);
|
|
28
|
+
const { year, month, day } = julianDayNumberToGregorian(jdn);
|
|
29
|
+
const result = new Date(year, month - 1, day);
|
|
30
|
+
result.setFullYear(year);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
function formatHijri(date, options = {}) {
|
|
34
|
+
const hijri = toHijri(date, options);
|
|
35
|
+
return `${hijri.day} ${HIJRI_MONTHS[hijri.month - 1]} ${hijri.year}`;
|
|
36
|
+
}
|
|
37
|
+
function getHijriMonthName(month) {
|
|
38
|
+
if (!Number.isInteger(month) || month < 1 || month > 12) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return HIJRI_MONTHS[month - 1] ?? null;
|
|
42
|
+
}
|
|
43
|
+
function isRamadan(date, options = {}) {
|
|
44
|
+
return toHijri(date, options).month === 9;
|
|
45
|
+
}
|
|
46
|
+
function assertValidDate(date) {
|
|
47
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
48
|
+
throw new RangeError("Invalid Date");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function assertValidHijri(hijri) {
|
|
52
|
+
const { year, month, day } = hijri;
|
|
53
|
+
if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day) || year < 1 || month < 1 || month > 12 || day < 1 || day > 30) {
|
|
54
|
+
throw new RangeError(
|
|
55
|
+
`Invalid Hijri date: ${String(year)}-${String(month)}-${String(day)}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function resolveOffset(options) {
|
|
60
|
+
const offset = options.offset ?? 0;
|
|
61
|
+
if (!Number.isInteger(offset)) {
|
|
62
|
+
throw new RangeError(
|
|
63
|
+
`Hijri offset must be an integer, received ${String(offset)}`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return offset;
|
|
67
|
+
}
|
|
68
|
+
function gregorianToJulianDayNumber(year, month, day) {
|
|
69
|
+
const a = Math.floor((14 - month) / 12);
|
|
70
|
+
const y = year + 4800 - a;
|
|
71
|
+
const m = month + 12 * a - 3;
|
|
72
|
+
return day + Math.floor((153 * m + 2) / 5) + 365 * y + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400) - 32045;
|
|
73
|
+
}
|
|
74
|
+
function julianDayNumberToGregorian(jdn) {
|
|
75
|
+
const a = jdn + 32044;
|
|
76
|
+
const b = Math.floor((4 * a + 3) / 146097);
|
|
77
|
+
const c = a - Math.floor(146097 * b / 4);
|
|
78
|
+
const d = Math.floor((4 * c + 3) / 1461);
|
|
79
|
+
const e = c - Math.floor(1461 * d / 4);
|
|
80
|
+
const m = Math.floor((5 * e + 2) / 153);
|
|
81
|
+
return {
|
|
82
|
+
day: e - Math.floor((153 * m + 2) / 5) + 1,
|
|
83
|
+
month: m + 3 - 12 * Math.floor(m / 10),
|
|
84
|
+
year: 100 * b + d - 4800 + Math.floor(m / 10)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function julianDayNumberToHijri(jdn) {
|
|
88
|
+
const l = jdn - 1948440 + 10632;
|
|
89
|
+
const n = Math.floor((l - 1) / 10631);
|
|
90
|
+
const l2 = l - 10631 * n + 354;
|
|
91
|
+
const j = Math.floor((10985 - l2) / 5316) * Math.floor(50 * l2 / 17719) + Math.floor(l2 / 5670) * Math.floor(43 * l2 / 15238);
|
|
92
|
+
const l3 = l2 - Math.floor((30 - j) / 15) * Math.floor(17719 * j / 50) - Math.floor(j / 16) * Math.floor(15238 * j / 43) + 29;
|
|
93
|
+
const month = Math.floor(24 * l3 / 709);
|
|
94
|
+
const day = l3 - Math.floor(709 * month / 24);
|
|
95
|
+
const year = 30 * n + j - 30;
|
|
96
|
+
return { year, month, day };
|
|
97
|
+
}
|
|
98
|
+
function hijriToJulianDayNumber(year, month, day) {
|
|
99
|
+
return Math.floor((11 * year + 3) / 30) + 354 * year + 30 * month - Math.floor((month - 1) / 2) + day + 1948440 - 385;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { formatHijri, fromHijri, getHijriMonthName, isRamadan, toHijri };
|