@bereasoftware/time-guard 2.6.1 → 2.7.1
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.en.md +232 -0
- package/README.md +259 -4
- package/dist/angular/index.cjs +148 -0
- package/dist/angular/index.d.ts +2 -0
- package/dist/angular/index.es.js +143 -0
- package/dist/angular.d.ts +59 -0
- package/dist/calendars/index.cjs +357 -2
- package/dist/calendars/index.es.js +99 -68
- package/dist/chunk-BbtWAPZS.cjs +36 -0
- package/dist/core-BFdo248T.cjs +1892 -0
- package/dist/core-CyBR5PPd.js +1809 -0
- package/dist/core.d.ts +224 -0
- package/dist/index.d.ts +9 -0
- package/dist/locales/african.locale.d.ts +7 -0
- package/dist/locales/index.cjs +7 -1
- package/dist/{types/locales → locales}/index.d.ts +2 -2
- package/dist/locales/index.es.js +3 -3
- package/dist/locales/south-american.locale.d.ts +7 -0
- package/dist/locales-B1mDDyn_.cjs +3537 -0
- package/dist/{locales-DSBvgSaw.js → locales-By7IK3Ep.js} +749 -33
- package/dist/native/index.cjs +48 -0
- package/dist/native/index.d.ts +2 -0
- package/dist/native/index.es.js +18 -0
- package/dist/native.d.ts +9 -0
- package/dist/plugins/advanced-format.cjs +105 -2
- package/dist/plugins/advanced-format.es.js +63 -45
- package/dist/plugins/duration.cjs +258 -2
- package/dist/plugins/duration.es.js +165 -61
- package/dist/plugins/relative-time.cjs +166 -2
- package/dist/plugins/relative-time.es.js +74 -37
- package/dist/qwik/index.cjs +104 -0
- package/dist/qwik/index.d.ts +2 -0
- package/dist/qwik/index.es.js +100 -0
- package/dist/qwik.d.ts +32 -0
- package/dist/react/index.cjs +112 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.es.js +103 -0
- package/dist/react.d.ts +46 -0
- package/dist/solid/index.cjs +127 -0
- package/dist/solid/index.d.ts +2 -0
- package/dist/solid/index.es.js +122 -0
- package/dist/solid.d.ts +53 -0
- package/dist/svelte/index.cjs +398 -0
- package/dist/svelte/index.d.ts +2 -0
- package/dist/svelte/index.es.js +393 -0
- package/dist/svelte.d.ts +88 -0
- package/dist/time-guard.cjs +7359 -4
- package/dist/time-guard.es.js +3625 -8085
- package/dist/time-guard.iife.js +13549 -4
- package/dist/time-guard.umd.js +13550 -4
- package/dist/types/index.d.ts +651 -127
- package/dist/vue/index.cjs +143 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.es.js +137 -0
- package/dist/vue.d.ts +35 -0
- package/package.json +107 -27
- package/dist/calendars/index.cjs.map +0 -1
- package/dist/calendars/index.es.js.map +0 -1
- package/dist/locales-DSBvgSaw.js.map +0 -1
- package/dist/locales-ybx7jS8G.cjs +0 -2
- package/dist/locales-ybx7jS8G.cjs.map +0 -1
- package/dist/plugins/advanced-format.cjs.map +0 -1
- package/dist/plugins/advanced-format.es.js.map +0 -1
- package/dist/plugins/duration.cjs.map +0 -1
- package/dist/plugins/duration.es.js.map +0 -1
- package/dist/plugins/relative-time.cjs.map +0 -1
- package/dist/plugins/relative-time.es.js.map +0 -1
- package/dist/time-guard.cjs.map +0 -1
- package/dist/time-guard.es.js.map +0 -1
- package/dist/time-guard.iife.js.map +0 -1
- package/dist/time-guard.umd.js.map +0 -1
- package/dist/types/types/index.d.ts +0 -641
- /package/dist/{types/adapters → adapters}/temporal.adapter.d.ts +0 -0
- /package/dist/{types/calendars → calendars}/calendar.manager.d.ts +0 -0
- /package/dist/{types/calendars → calendars}/index.d.ts +0 -0
- /package/dist/{types/formatters → formatters}/date.formatter.d.ts +0 -0
- /package/dist/{types/locales → locales}/additional.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/asian.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/english.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/european.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/locale.manager.d.ts +0 -0
- /package/dist/{types/locales → locales}/middle-eastern.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/nordic.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/romance.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/slavic.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/spanish.locale.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/advanced-format/index.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/advanced-format.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/duration/index.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/duration/types.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/duration.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/index.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/manager.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/relative-time/index.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/relative-time/types.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/relative-time.d.ts +0 -0
- /package/dist/{types/time-guard.d.ts → time-guard.d.ts} +0 -0
- /package/dist/{types/utils → utils}/duration-locale.d.ts +0 -0
package/dist/calendars/index.cjs
CHANGED
|
@@ -1,2 +1,357 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*! time-guard v2.7.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region src/calendars/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Islamic Calendar (Hijri)
|
|
6
|
+
* @experimental Uses simplified calculations. May not be accurate for all dates.
|
|
7
|
+
*/
|
|
8
|
+
var IslamicCalendar = class {
|
|
9
|
+
id = "islamic";
|
|
10
|
+
name = "Islamic Calendar (Hijri)";
|
|
11
|
+
locale = "ar";
|
|
12
|
+
monthNames = [
|
|
13
|
+
"Muharram",
|
|
14
|
+
"Safar",
|
|
15
|
+
"Rabi al-awwal",
|
|
16
|
+
"Rabi al-thani",
|
|
17
|
+
"Jumada al-awwal",
|
|
18
|
+
"Jumada al-thani",
|
|
19
|
+
"Rajab",
|
|
20
|
+
"Sha'ban",
|
|
21
|
+
"Ramadan",
|
|
22
|
+
"Shawwal",
|
|
23
|
+
"Dhu al-Qi'dah",
|
|
24
|
+
"Dhu al-Hijjah"
|
|
25
|
+
];
|
|
26
|
+
getMonthName(month) {
|
|
27
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
28
|
+
}
|
|
29
|
+
getWeekdayName(day, short = false) {
|
|
30
|
+
return (short ? [
|
|
31
|
+
"Ahd",
|
|
32
|
+
"Ith",
|
|
33
|
+
"Sel",
|
|
34
|
+
"Rab",
|
|
35
|
+
"Kha",
|
|
36
|
+
"Jum",
|
|
37
|
+
"Sab"
|
|
38
|
+
] : [
|
|
39
|
+
"Ahad",
|
|
40
|
+
"Ithnayn",
|
|
41
|
+
"Salasa",
|
|
42
|
+
"Rabi",
|
|
43
|
+
"Khamis",
|
|
44
|
+
"Jumah",
|
|
45
|
+
"Sabt"
|
|
46
|
+
])[Math.max(0, Math.min(6, day - 1))];
|
|
47
|
+
}
|
|
48
|
+
isLeapYear(year) {
|
|
49
|
+
return [
|
|
50
|
+
2,
|
|
51
|
+
5,
|
|
52
|
+
7,
|
|
53
|
+
10,
|
|
54
|
+
13,
|
|
55
|
+
16,
|
|
56
|
+
18,
|
|
57
|
+
21,
|
|
58
|
+
24,
|
|
59
|
+
26,
|
|
60
|
+
29
|
|
61
|
+
].includes(year % 30);
|
|
62
|
+
}
|
|
63
|
+
daysInMonth(year, month) {
|
|
64
|
+
if (month % 2 === 1) return 30;
|
|
65
|
+
if (month === 12 && this.isLeapYear(year)) return 30;
|
|
66
|
+
return 29;
|
|
67
|
+
}
|
|
68
|
+
daysInYear(year) {
|
|
69
|
+
return this.isLeapYear(year) ? 355 : 354;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Hebrew Calendar
|
|
74
|
+
* @experimental Uses simplified calculations. May not be accurate for all dates.
|
|
75
|
+
*/
|
|
76
|
+
var HebrewCalendar = class {
|
|
77
|
+
id = "hebrew";
|
|
78
|
+
name = "Hebrew Calendar";
|
|
79
|
+
locale = "he";
|
|
80
|
+
monthNames = [
|
|
81
|
+
"Tishrei",
|
|
82
|
+
"Cheshvan",
|
|
83
|
+
"Kislev",
|
|
84
|
+
"Tevet",
|
|
85
|
+
"Shevat",
|
|
86
|
+
"Adar",
|
|
87
|
+
"Nisan",
|
|
88
|
+
"Iyar",
|
|
89
|
+
"Sivan",
|
|
90
|
+
"Tammuz",
|
|
91
|
+
"Av",
|
|
92
|
+
"Elul"
|
|
93
|
+
];
|
|
94
|
+
getMonthName(month) {
|
|
95
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
96
|
+
}
|
|
97
|
+
getWeekdayName(day, short = false) {
|
|
98
|
+
return (short ? [
|
|
99
|
+
"Sun",
|
|
100
|
+
"Mon",
|
|
101
|
+
"Tue",
|
|
102
|
+
"Wed",
|
|
103
|
+
"Thu",
|
|
104
|
+
"Fri",
|
|
105
|
+
"Sat"
|
|
106
|
+
] : [
|
|
107
|
+
"Sunday",
|
|
108
|
+
"Monday",
|
|
109
|
+
"Tuesday",
|
|
110
|
+
"Wednesday",
|
|
111
|
+
"Thursday",
|
|
112
|
+
"Friday",
|
|
113
|
+
"Saturday"
|
|
114
|
+
])[Math.max(0, Math.min(6, day - 1))];
|
|
115
|
+
}
|
|
116
|
+
isLeapYear(year) {
|
|
117
|
+
return [
|
|
118
|
+
3,
|
|
119
|
+
6,
|
|
120
|
+
8,
|
|
121
|
+
11,
|
|
122
|
+
14,
|
|
123
|
+
17,
|
|
124
|
+
19
|
|
125
|
+
].includes(year % 19);
|
|
126
|
+
}
|
|
127
|
+
daysInMonth(_year, month) {
|
|
128
|
+
return [
|
|
129
|
+
30,
|
|
130
|
+
29,
|
|
131
|
+
30,
|
|
132
|
+
29,
|
|
133
|
+
30,
|
|
134
|
+
29,
|
|
135
|
+
30,
|
|
136
|
+
29,
|
|
137
|
+
30,
|
|
138
|
+
29,
|
|
139
|
+
30,
|
|
140
|
+
29
|
|
141
|
+
][Math.max(0, Math.min(11, month - 1))];
|
|
142
|
+
}
|
|
143
|
+
daysInYear(year) {
|
|
144
|
+
return this.isLeapYear(year) ? 384 : 354;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Chinese Calendar
|
|
149
|
+
* @experimental Uses simplified calculations. May not be accurate for all dates.
|
|
150
|
+
*/
|
|
151
|
+
var ChineseCalendar = class {
|
|
152
|
+
id = "chinese";
|
|
153
|
+
name = "Chinese Calendar";
|
|
154
|
+
locale = "zh";
|
|
155
|
+
monthNames = [
|
|
156
|
+
"正月",
|
|
157
|
+
"二月",
|
|
158
|
+
"三月",
|
|
159
|
+
"四月",
|
|
160
|
+
"五月",
|
|
161
|
+
"六月",
|
|
162
|
+
"七月",
|
|
163
|
+
"八月",
|
|
164
|
+
"九月",
|
|
165
|
+
"十月",
|
|
166
|
+
"冬月",
|
|
167
|
+
"腊月"
|
|
168
|
+
];
|
|
169
|
+
terrestrialBranches = [
|
|
170
|
+
"子",
|
|
171
|
+
"丑",
|
|
172
|
+
"寅",
|
|
173
|
+
"卯",
|
|
174
|
+
"辰",
|
|
175
|
+
"巳",
|
|
176
|
+
"午",
|
|
177
|
+
"未",
|
|
178
|
+
"申",
|
|
179
|
+
"酉",
|
|
180
|
+
"戌",
|
|
181
|
+
"亥"
|
|
182
|
+
];
|
|
183
|
+
getMonthName(month) {
|
|
184
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
185
|
+
}
|
|
186
|
+
getWeekdayName(day, short = false) {
|
|
187
|
+
return (short ? [
|
|
188
|
+
"日",
|
|
189
|
+
"一",
|
|
190
|
+
"二",
|
|
191
|
+
"三",
|
|
192
|
+
"四",
|
|
193
|
+
"五",
|
|
194
|
+
"六"
|
|
195
|
+
] : [
|
|
196
|
+
"星期日",
|
|
197
|
+
"星期一",
|
|
198
|
+
"星期二",
|
|
199
|
+
"星期三",
|
|
200
|
+
"星期四",
|
|
201
|
+
"星期五",
|
|
202
|
+
"星期六"
|
|
203
|
+
])[Math.max(0, Math.min(6, day - 1))];
|
|
204
|
+
}
|
|
205
|
+
isLeapYear(year) {
|
|
206
|
+
return year % 3 === 0;
|
|
207
|
+
}
|
|
208
|
+
daysInMonth(_year, month) {
|
|
209
|
+
return month % 2 === 0 ? 30 : 29;
|
|
210
|
+
}
|
|
211
|
+
daysInYear(year) {
|
|
212
|
+
return this.isLeapYear(year) ? 384 : 354;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get zodiac sign for year
|
|
216
|
+
*/
|
|
217
|
+
getZodiacSign(year) {
|
|
218
|
+
return this.terrestrialBranches[year % 12];
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Japanese Calendar
|
|
223
|
+
* @experimental Uses Gregorian rules post-1873. Historical dates may not be accurate.
|
|
224
|
+
*/
|
|
225
|
+
var JapaneseCalendar = class {
|
|
226
|
+
id = "japanese";
|
|
227
|
+
name = "Japanese Calendar";
|
|
228
|
+
locale = "ja";
|
|
229
|
+
monthNames = [
|
|
230
|
+
"1月",
|
|
231
|
+
"2月",
|
|
232
|
+
"3月",
|
|
233
|
+
"4月",
|
|
234
|
+
"5月",
|
|
235
|
+
"6月",
|
|
236
|
+
"7月",
|
|
237
|
+
"8月",
|
|
238
|
+
"9月",
|
|
239
|
+
"10月",
|
|
240
|
+
"11月",
|
|
241
|
+
"12月"
|
|
242
|
+
];
|
|
243
|
+
getMonthName(month) {
|
|
244
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
245
|
+
}
|
|
246
|
+
getWeekdayName(day, short = false) {
|
|
247
|
+
return (short ? [
|
|
248
|
+
"日",
|
|
249
|
+
"月",
|
|
250
|
+
"火",
|
|
251
|
+
"水",
|
|
252
|
+
"木",
|
|
253
|
+
"金",
|
|
254
|
+
"土"
|
|
255
|
+
] : [
|
|
256
|
+
"日曜日",
|
|
257
|
+
"月曜日",
|
|
258
|
+
"火曜日",
|
|
259
|
+
"水曜日",
|
|
260
|
+
"木曜日",
|
|
261
|
+
"金曜日",
|
|
262
|
+
"土曜日"
|
|
263
|
+
])[Math.max(0, Math.min(6, day - 1))];
|
|
264
|
+
}
|
|
265
|
+
isLeapYear(year) {
|
|
266
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
267
|
+
}
|
|
268
|
+
daysInMonth(year, month) {
|
|
269
|
+
const daysPerMonth = [
|
|
270
|
+
31,
|
|
271
|
+
28,
|
|
272
|
+
31,
|
|
273
|
+
30,
|
|
274
|
+
31,
|
|
275
|
+
30,
|
|
276
|
+
31,
|
|
277
|
+
31,
|
|
278
|
+
30,
|
|
279
|
+
31,
|
|
280
|
+
30,
|
|
281
|
+
31
|
|
282
|
+
];
|
|
283
|
+
if (month === 2 && this.isLeapYear(year)) return 29;
|
|
284
|
+
return daysPerMonth[Math.max(0, Math.min(11, month - 1))];
|
|
285
|
+
}
|
|
286
|
+
daysInYear(year) {
|
|
287
|
+
return this.isLeapYear(year) ? 366 : 365;
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Buddhist Calendar
|
|
292
|
+
* @experimental Uses Gregorian rules with BE year offset (CE + 543).
|
|
293
|
+
*/
|
|
294
|
+
var BuddhistCalendar = class {
|
|
295
|
+
id = "buddhist";
|
|
296
|
+
name = "Buddhist Calendar";
|
|
297
|
+
locale = "th";
|
|
298
|
+
monthNames = [
|
|
299
|
+
"January",
|
|
300
|
+
"February",
|
|
301
|
+
"March",
|
|
302
|
+
"April",
|
|
303
|
+
"May",
|
|
304
|
+
"June",
|
|
305
|
+
"July",
|
|
306
|
+
"August",
|
|
307
|
+
"September",
|
|
308
|
+
"October",
|
|
309
|
+
"November",
|
|
310
|
+
"December"
|
|
311
|
+
];
|
|
312
|
+
getMonthName(month) {
|
|
313
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
314
|
+
}
|
|
315
|
+
getWeekdayName(day) {
|
|
316
|
+
return [
|
|
317
|
+
"Sunday",
|
|
318
|
+
"Monday",
|
|
319
|
+
"Tuesday",
|
|
320
|
+
"Wednesday",
|
|
321
|
+
"Thursday",
|
|
322
|
+
"Friday",
|
|
323
|
+
"Saturday"
|
|
324
|
+
][Math.max(0, Math.min(6, day - 1))];
|
|
325
|
+
}
|
|
326
|
+
isLeapYear(year) {
|
|
327
|
+
const ceYear = year - 543;
|
|
328
|
+
return ceYear % 4 === 0 && ceYear % 100 !== 0 || ceYear % 400 === 0;
|
|
329
|
+
}
|
|
330
|
+
daysInMonth(year, month) {
|
|
331
|
+
const daysPerMonth = [
|
|
332
|
+
31,
|
|
333
|
+
28,
|
|
334
|
+
31,
|
|
335
|
+
30,
|
|
336
|
+
31,
|
|
337
|
+
30,
|
|
338
|
+
31,
|
|
339
|
+
31,
|
|
340
|
+
30,
|
|
341
|
+
31,
|
|
342
|
+
30,
|
|
343
|
+
31
|
|
344
|
+
];
|
|
345
|
+
if (month === 2 && this.isLeapYear(year)) return 29;
|
|
346
|
+
return daysPerMonth[Math.max(0, Math.min(11, month - 1))];
|
|
347
|
+
}
|
|
348
|
+
daysInYear(year) {
|
|
349
|
+
return this.isLeapYear(year) ? 366 : 365;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
//#endregion
|
|
353
|
+
exports.BuddhistCalendar = BuddhistCalendar;
|
|
354
|
+
exports.ChineseCalendar = ChineseCalendar;
|
|
355
|
+
exports.HebrewCalendar = HebrewCalendar;
|
|
356
|
+
exports.IslamicCalendar = IslamicCalendar;
|
|
357
|
+
exports.JapaneseCalendar = JapaneseCalendar;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
/*! time-guard v2.
|
|
1
|
+
/*! time-guard v2.7.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
|
|
2
2
|
//#region src/calendars/index.ts
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Islamic Calendar (Hijri)
|
|
5
|
+
* @experimental Uses simplified calculations. May not be accurate for all dates.
|
|
6
|
+
*/
|
|
7
|
+
var IslamicCalendar = class {
|
|
4
8
|
id = "islamic";
|
|
5
9
|
name = "Islamic Calendar (Hijri)";
|
|
6
10
|
locale = "ar";
|
|
@@ -18,11 +22,11 @@ var e = class {
|
|
|
18
22
|
"Dhu al-Qi'dah",
|
|
19
23
|
"Dhu al-Hijjah"
|
|
20
24
|
];
|
|
21
|
-
getMonthName(
|
|
22
|
-
return this.monthNames[Math.max(0, Math.min(11,
|
|
25
|
+
getMonthName(month) {
|
|
26
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
23
27
|
}
|
|
24
|
-
getWeekdayName(
|
|
25
|
-
return (
|
|
28
|
+
getWeekdayName(day, short = false) {
|
|
29
|
+
return (short ? [
|
|
26
30
|
"Ahd",
|
|
27
31
|
"Ith",
|
|
28
32
|
"Sel",
|
|
@@ -38,9 +42,9 @@ var e = class {
|
|
|
38
42
|
"Khamis",
|
|
39
43
|
"Jumah",
|
|
40
44
|
"Sabt"
|
|
41
|
-
])[Math.max(0, Math.min(6,
|
|
45
|
+
])[Math.max(0, Math.min(6, day - 1))];
|
|
42
46
|
}
|
|
43
|
-
isLeapYear(
|
|
47
|
+
isLeapYear(year) {
|
|
44
48
|
return [
|
|
45
49
|
2,
|
|
46
50
|
5,
|
|
@@ -53,15 +57,22 @@ var e = class {
|
|
|
53
57
|
24,
|
|
54
58
|
26,
|
|
55
59
|
29
|
|
56
|
-
].includes(
|
|
60
|
+
].includes(year % 30);
|
|
57
61
|
}
|
|
58
|
-
daysInMonth(
|
|
59
|
-
|
|
62
|
+
daysInMonth(year, month) {
|
|
63
|
+
if (month % 2 === 1) return 30;
|
|
64
|
+
if (month === 12 && this.isLeapYear(year)) return 30;
|
|
65
|
+
return 29;
|
|
60
66
|
}
|
|
61
|
-
daysInYear(
|
|
62
|
-
return this.isLeapYear(
|
|
67
|
+
daysInYear(year) {
|
|
68
|
+
return this.isLeapYear(year) ? 355 : 354;
|
|
63
69
|
}
|
|
64
|
-
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Hebrew Calendar
|
|
73
|
+
* @experimental Uses simplified calculations. May not be accurate for all dates.
|
|
74
|
+
*/
|
|
75
|
+
var HebrewCalendar = class {
|
|
65
76
|
id = "hebrew";
|
|
66
77
|
name = "Hebrew Calendar";
|
|
67
78
|
locale = "he";
|
|
@@ -79,11 +90,11 @@ var e = class {
|
|
|
79
90
|
"Av",
|
|
80
91
|
"Elul"
|
|
81
92
|
];
|
|
82
|
-
getMonthName(
|
|
83
|
-
return this.monthNames[Math.max(0, Math.min(11,
|
|
93
|
+
getMonthName(month) {
|
|
94
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
84
95
|
}
|
|
85
|
-
getWeekdayName(
|
|
86
|
-
return (
|
|
96
|
+
getWeekdayName(day, short = false) {
|
|
97
|
+
return (short ? [
|
|
87
98
|
"Sun",
|
|
88
99
|
"Mon",
|
|
89
100
|
"Tue",
|
|
@@ -99,9 +110,9 @@ var e = class {
|
|
|
99
110
|
"Thursday",
|
|
100
111
|
"Friday",
|
|
101
112
|
"Saturday"
|
|
102
|
-
])[Math.max(0, Math.min(6,
|
|
113
|
+
])[Math.max(0, Math.min(6, day - 1))];
|
|
103
114
|
}
|
|
104
|
-
isLeapYear(
|
|
115
|
+
isLeapYear(year) {
|
|
105
116
|
return [
|
|
106
117
|
3,
|
|
107
118
|
6,
|
|
@@ -110,9 +121,9 @@ var e = class {
|
|
|
110
121
|
14,
|
|
111
122
|
17,
|
|
112
123
|
19
|
|
113
|
-
].includes(
|
|
124
|
+
].includes(year % 19);
|
|
114
125
|
}
|
|
115
|
-
daysInMonth(
|
|
126
|
+
daysInMonth(_year, month) {
|
|
116
127
|
return [
|
|
117
128
|
30,
|
|
118
129
|
29,
|
|
@@ -126,12 +137,17 @@ var e = class {
|
|
|
126
137
|
29,
|
|
127
138
|
30,
|
|
128
139
|
29
|
|
129
|
-
][Math.max(0, Math.min(11,
|
|
140
|
+
][Math.max(0, Math.min(11, month - 1))];
|
|
130
141
|
}
|
|
131
|
-
daysInYear(
|
|
132
|
-
return this.isLeapYear(
|
|
142
|
+
daysInYear(year) {
|
|
143
|
+
return this.isLeapYear(year) ? 384 : 354;
|
|
133
144
|
}
|
|
134
|
-
}
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Chinese Calendar
|
|
148
|
+
* @experimental Uses simplified calculations. May not be accurate for all dates.
|
|
149
|
+
*/
|
|
150
|
+
var ChineseCalendar = class {
|
|
135
151
|
id = "chinese";
|
|
136
152
|
name = "Chinese Calendar";
|
|
137
153
|
locale = "zh";
|
|
@@ -163,11 +179,11 @@ var e = class {
|
|
|
163
179
|
"戌",
|
|
164
180
|
"亥"
|
|
165
181
|
];
|
|
166
|
-
getMonthName(
|
|
167
|
-
return this.monthNames[Math.max(0, Math.min(11,
|
|
182
|
+
getMonthName(month) {
|
|
183
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
168
184
|
}
|
|
169
|
-
getWeekdayName(
|
|
170
|
-
return (
|
|
185
|
+
getWeekdayName(day, short = false) {
|
|
186
|
+
return (short ? [
|
|
171
187
|
"日",
|
|
172
188
|
"一",
|
|
173
189
|
"二",
|
|
@@ -183,21 +199,29 @@ var e = class {
|
|
|
183
199
|
"星期四",
|
|
184
200
|
"星期五",
|
|
185
201
|
"星期六"
|
|
186
|
-
])[Math.max(0, Math.min(6,
|
|
202
|
+
])[Math.max(0, Math.min(6, day - 1))];
|
|
187
203
|
}
|
|
188
|
-
isLeapYear(
|
|
189
|
-
return
|
|
204
|
+
isLeapYear(year) {
|
|
205
|
+
return year % 3 === 0;
|
|
190
206
|
}
|
|
191
|
-
daysInMonth(
|
|
192
|
-
return
|
|
207
|
+
daysInMonth(_year, month) {
|
|
208
|
+
return month % 2 === 0 ? 30 : 29;
|
|
193
209
|
}
|
|
194
|
-
daysInYear(
|
|
195
|
-
return this.isLeapYear(
|
|
210
|
+
daysInYear(year) {
|
|
211
|
+
return this.isLeapYear(year) ? 384 : 354;
|
|
196
212
|
}
|
|
197
|
-
|
|
198
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Get zodiac sign for year
|
|
215
|
+
*/
|
|
216
|
+
getZodiacSign(year) {
|
|
217
|
+
return this.terrestrialBranches[year % 12];
|
|
199
218
|
}
|
|
200
|
-
}
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Japanese Calendar
|
|
222
|
+
* @experimental Uses Gregorian rules post-1873. Historical dates may not be accurate.
|
|
223
|
+
*/
|
|
224
|
+
var JapaneseCalendar = class {
|
|
201
225
|
id = "japanese";
|
|
202
226
|
name = "Japanese Calendar";
|
|
203
227
|
locale = "ja";
|
|
@@ -215,11 +239,11 @@ var e = class {
|
|
|
215
239
|
"11月",
|
|
216
240
|
"12月"
|
|
217
241
|
];
|
|
218
|
-
getMonthName(
|
|
219
|
-
return this.monthNames[Math.max(0, Math.min(11,
|
|
242
|
+
getMonthName(month) {
|
|
243
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
220
244
|
}
|
|
221
|
-
getWeekdayName(
|
|
222
|
-
return (
|
|
245
|
+
getWeekdayName(day, short = false) {
|
|
246
|
+
return (short ? [
|
|
223
247
|
"日",
|
|
224
248
|
"月",
|
|
225
249
|
"火",
|
|
@@ -235,13 +259,13 @@ var e = class {
|
|
|
235
259
|
"木曜日",
|
|
236
260
|
"金曜日",
|
|
237
261
|
"土曜日"
|
|
238
|
-
])[Math.max(0, Math.min(6,
|
|
262
|
+
])[Math.max(0, Math.min(6, day - 1))];
|
|
239
263
|
}
|
|
240
|
-
isLeapYear(
|
|
241
|
-
return
|
|
264
|
+
isLeapYear(year) {
|
|
265
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
242
266
|
}
|
|
243
|
-
daysInMonth(
|
|
244
|
-
|
|
267
|
+
daysInMonth(year, month) {
|
|
268
|
+
const daysPerMonth = [
|
|
245
269
|
31,
|
|
246
270
|
28,
|
|
247
271
|
31,
|
|
@@ -254,12 +278,19 @@ var e = class {
|
|
|
254
278
|
31,
|
|
255
279
|
30,
|
|
256
280
|
31
|
|
257
|
-
]
|
|
281
|
+
];
|
|
282
|
+
if (month === 2 && this.isLeapYear(year)) return 29;
|
|
283
|
+
return daysPerMonth[Math.max(0, Math.min(11, month - 1))];
|
|
258
284
|
}
|
|
259
|
-
daysInYear(
|
|
260
|
-
return this.isLeapYear(
|
|
285
|
+
daysInYear(year) {
|
|
286
|
+
return this.isLeapYear(year) ? 366 : 365;
|
|
261
287
|
}
|
|
262
|
-
}
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* Buddhist Calendar
|
|
291
|
+
* @experimental Uses Gregorian rules with BE year offset (CE + 543).
|
|
292
|
+
*/
|
|
293
|
+
var BuddhistCalendar = class {
|
|
263
294
|
id = "buddhist";
|
|
264
295
|
name = "Buddhist Calendar";
|
|
265
296
|
locale = "th";
|
|
@@ -277,10 +308,10 @@ var e = class {
|
|
|
277
308
|
"November",
|
|
278
309
|
"December"
|
|
279
310
|
];
|
|
280
|
-
getMonthName(
|
|
281
|
-
return this.monthNames[Math.max(0, Math.min(11,
|
|
311
|
+
getMonthName(month) {
|
|
312
|
+
return this.monthNames[Math.max(0, Math.min(11, month - 1))];
|
|
282
313
|
}
|
|
283
|
-
getWeekdayName(
|
|
314
|
+
getWeekdayName(day) {
|
|
284
315
|
return [
|
|
285
316
|
"Sunday",
|
|
286
317
|
"Monday",
|
|
@@ -289,14 +320,14 @@ var e = class {
|
|
|
289
320
|
"Thursday",
|
|
290
321
|
"Friday",
|
|
291
322
|
"Saturday"
|
|
292
|
-
][Math.max(0, Math.min(6,
|
|
323
|
+
][Math.max(0, Math.min(6, day - 1))];
|
|
293
324
|
}
|
|
294
|
-
isLeapYear(
|
|
295
|
-
|
|
296
|
-
return
|
|
325
|
+
isLeapYear(year) {
|
|
326
|
+
const ceYear = year - 543;
|
|
327
|
+
return ceYear % 4 === 0 && ceYear % 100 !== 0 || ceYear % 400 === 0;
|
|
297
328
|
}
|
|
298
|
-
daysInMonth(
|
|
299
|
-
|
|
329
|
+
daysInMonth(year, month) {
|
|
330
|
+
const daysPerMonth = [
|
|
300
331
|
31,
|
|
301
332
|
28,
|
|
302
333
|
31,
|
|
@@ -309,13 +340,13 @@ var e = class {
|
|
|
309
340
|
31,
|
|
310
341
|
30,
|
|
311
342
|
31
|
|
312
|
-
]
|
|
343
|
+
];
|
|
344
|
+
if (month === 2 && this.isLeapYear(year)) return 29;
|
|
345
|
+
return daysPerMonth[Math.max(0, Math.min(11, month - 1))];
|
|
313
346
|
}
|
|
314
|
-
daysInYear(
|
|
315
|
-
return this.isLeapYear(
|
|
347
|
+
daysInYear(year) {
|
|
348
|
+
return this.isLeapYear(year) ? 366 : 365;
|
|
316
349
|
}
|
|
317
350
|
};
|
|
318
351
|
//#endregion
|
|
319
|
-
export {
|
|
320
|
-
|
|
321
|
-
//# sourceMappingURL=index.es.js.map
|
|
352
|
+
export { BuddhistCalendar, ChineseCalendar, HebrewCalendar, IslamicCalendar, JapaneseCalendar };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*! time-guard v2.7.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
//#endregion
|
|
25
|
+
Object.defineProperty(exports, "__commonJSMin", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return __commonJSMin;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "__toESM", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function() {
|
|
34
|
+
return __toESM;
|
|
35
|
+
}
|
|
36
|
+
});
|