@coreify/tarikh 1.0.0 → 1.0.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.md +117 -131
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +20 -7
- package/dist/index.d.ts +20 -7
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +9 -6
- package/dist/react.d.ts +9 -6
- package/dist/react.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
# @coreify/tarikh
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@coreify/tarikh)
|
|
4
|
+
[](https://www.npmjs.com/package/@coreify/tarikh)
|
|
5
|
+
[](https://github.com/coreify/tarikh/blob/main/package/LICENSE)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
The first JavaScript date library with full Bangla calendar support.
|
|
8
|
+
|
|
9
|
+
Built for Bangla dates, Bengali calendar conversion, and culturally correct formatting.
|
|
10
|
+
|
|
11
|
+
## At a Glance
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
format("2026-04-14", {
|
|
15
|
+
mode: "bangla",
|
|
16
|
+
locale: "bn-BD",
|
|
17
|
+
format: "spoken"
|
|
18
|
+
});
|
|
19
|
+
// → "পহেলা বৈশাখ ১৪৩৩"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Demo
|
|
23
|
+
|
|
24
|
+
External demo: [tarikh.js.org](https://tarikh.js.org)
|
|
6
25
|
|
|
7
26
|
## Why this exists
|
|
8
27
|
|
|
@@ -27,14 +46,19 @@ npm install @coreify/tarikh
|
|
|
27
46
|
|
|
28
47
|
```ts
|
|
29
48
|
import {
|
|
30
|
-
|
|
31
|
-
formatBanglaCalendar,
|
|
49
|
+
format,
|
|
32
50
|
fromNow,
|
|
33
51
|
toBanglaCalendar
|
|
34
52
|
} from "@coreify/tarikh";
|
|
35
53
|
|
|
36
|
-
|
|
37
|
-
|
|
54
|
+
// Preferred entry points:
|
|
55
|
+
format(new Date(), { mode: "standard" });
|
|
56
|
+
format(new Date(), { mode: "bangla" });
|
|
57
|
+
format(new Date(), { mode: "hybrid" });
|
|
58
|
+
|
|
59
|
+
// Token-based output still works.
|
|
60
|
+
format(new Date(), { pattern: "DD MMM YYYY" });
|
|
61
|
+
// → "31 Mar 2026"
|
|
38
62
|
|
|
39
63
|
// Structured Bangla calendar conversion
|
|
40
64
|
// `monthIndex` stays numeric; `bn-BD` localizes `day`, `month`, and `year`.
|
|
@@ -44,23 +68,25 @@ toBanglaCalendar("2026-03-31");
|
|
|
44
68
|
toBanglaCalendar("2026-03-31", { locale: "bn-BD" });
|
|
45
69
|
// → { day: "১৭", month: "চৈত্র", monthIndex: 12, year: "১৪৩২" }
|
|
46
70
|
|
|
47
|
-
|
|
71
|
+
format("2026-03-31", { mode: "bangla" });
|
|
48
72
|
// → "17 Chaitra 1432"
|
|
49
73
|
|
|
50
|
-
|
|
74
|
+
format("2026-03-31", { mode: "bangla", locale: "bn-BD" });
|
|
51
75
|
// → "১৭ই চৈত্র ১৪৩২"
|
|
52
76
|
|
|
53
|
-
|
|
77
|
+
format("2026-04-14", { mode: "bangla", locale: "bn-BD" });
|
|
54
78
|
// → "১লা বৈশাখ ১৪৩৩"
|
|
55
79
|
|
|
56
|
-
|
|
80
|
+
format(new Date(2026, 2, 31, 15, 4), {
|
|
81
|
+
mode: "standard",
|
|
57
82
|
weekday: "short",
|
|
58
83
|
hour: "numeric",
|
|
59
84
|
minute: "2-digit"
|
|
60
85
|
});
|
|
61
86
|
// → "Tue, 31 Mar 2026, 15:04"
|
|
62
87
|
|
|
63
|
-
|
|
88
|
+
format(new Date(2026, 2, 31, 21, 4, 9), {
|
|
89
|
+
mode: "standard",
|
|
64
90
|
weekday: "long",
|
|
65
91
|
hour: "2-digit",
|
|
66
92
|
minute: "2-digit",
|
|
@@ -76,23 +102,32 @@ fromNow(new Date(), { numeric: "auto" });
|
|
|
76
102
|
// → "today"
|
|
77
103
|
```
|
|
78
104
|
|
|
105
|
+
Use `format()` for everything. Choose a mode (`standard`, `bangla`, `hybrid`) or pass a token pattern.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
// Show today's Bangla date in your app header
|
|
109
|
+
format(new Date(), { mode: "bangla", locale: "bn-BD" });
|
|
110
|
+
// → "১৭ চৈত্র ১৪৩২"
|
|
111
|
+
```
|
|
112
|
+
|
|
79
113
|
## Features
|
|
80
114
|
|
|
81
|
-
###
|
|
115
|
+
### Standard Formatting
|
|
82
116
|
|
|
83
117
|
```ts
|
|
84
|
-
import {
|
|
118
|
+
import { format } from "@coreify/tarikh";
|
|
85
119
|
|
|
86
|
-
|
|
120
|
+
format(new Date(), { mode: "standard" });
|
|
87
121
|
// → "31 Mar 2026"
|
|
88
122
|
|
|
89
|
-
|
|
123
|
+
format(new Date(), { mode: "standard", locale: "bn-BD" });
|
|
90
124
|
// → "৩১ মার্চ ২০২৬"
|
|
91
125
|
|
|
92
|
-
|
|
126
|
+
format(new Date(), { mode: "standard", month: "long", year: "2-digit" });
|
|
93
127
|
// → "31 March 26"
|
|
94
128
|
|
|
95
|
-
|
|
129
|
+
format(new Date(2026, 2, 31, 15, 4, 9), {
|
|
130
|
+
mode: "standard",
|
|
96
131
|
weekday: "long",
|
|
97
132
|
hour: "2-digit",
|
|
98
133
|
minute: "2-digit",
|
|
@@ -104,49 +139,68 @@ formatDate(new Date(2026, 2, 31, 15, 4, 9), {
|
|
|
104
139
|
|
|
105
140
|
**Options:** `locale` (`"en-BD"` | `"bn-BD"`), `month` (`"short"` | `"long"`), `year` (`"numeric"` | `"2-digit"`), `day` (`"numeric"` | `"2-digit"`), `weekday` (`"short"` | `"long"`), `hour` / `minute` / `second` (`"numeric"` | `"2-digit"`), `hour12` (`boolean`)
|
|
106
141
|
|
|
107
|
-
###
|
|
142
|
+
### Pattern Formatting
|
|
108
143
|
|
|
109
144
|
```ts
|
|
110
145
|
import { format } from "@coreify/tarikh";
|
|
111
146
|
|
|
112
|
-
format(new Date(), "DD MMM YYYY");
|
|
147
|
+
format(new Date(), { pattern: "DD MMM YYYY" });
|
|
113
148
|
// → "31 Mar 2026"
|
|
114
149
|
|
|
115
|
-
format(new Date(), "DD MMMM YYYY",
|
|
150
|
+
format(new Date(), { pattern: "DD MMMM YYYY", locale: "bn-BD" });
|
|
116
151
|
// → "৩১ মার্চ ২০২৬"
|
|
117
152
|
|
|
118
|
-
format(new Date(), "DD/MM/YYYY");
|
|
153
|
+
format(new Date(), { pattern: "DD/MM/YYYY" });
|
|
119
154
|
// → "31/03/2026"
|
|
120
155
|
|
|
121
|
-
format(new Date(2026, 2, 31, 15, 4, 9),
|
|
156
|
+
format(new Date(2026, 2, 31, 15, 4, 9), {
|
|
157
|
+
pattern: "ddd, D MMM YYYY HH:mm:ss"
|
|
158
|
+
});
|
|
122
159
|
// → "Tue, 31 Mar 2026 15:04:09"
|
|
123
160
|
|
|
124
|
-
format(new Date(2026, 2, 31, 9, 4),
|
|
161
|
+
format(new Date(2026, 2, 31, 9, 4), {
|
|
162
|
+
pattern: "ddd, D MMM YYYY h:mm a",
|
|
125
163
|
locale: "bn-BD"
|
|
126
164
|
});
|
|
127
165
|
// → "মঙ্গল, ৩১ মার্চ ২০২৬ ৯:০৪ পূর্বাহ্ণ"
|
|
128
166
|
|
|
129
|
-
format(new Date(2026, 2, 31, 21, 4, 9),
|
|
167
|
+
format(new Date(2026, 2, 31, 21, 4, 9), {
|
|
168
|
+
pattern: "dddd, D MMM YYYY hh:mm:ss A"
|
|
169
|
+
});
|
|
130
170
|
// → "Tuesday, 31 Mar 2026 09:04:09 PM"
|
|
131
171
|
```
|
|
132
172
|
|
|
173
|
+
`format()` is the primary API. Use `{ mode }` for date behavior or `{ pattern }` for token formatting. `mode` and `pattern` are mutually exclusive.
|
|
174
|
+
|
|
133
175
|
**Tokens:** `dddd`, `ddd`, `DD`, `D`, `MMMM`, `MMM`, `MM`, `M`, `YYYY`, `YY`, `HH`, `H`, `hh`, `h`, `mm`, `m`, `ss`, `s`, `A`, `a`
|
|
134
176
|
|
|
135
|
-
|
|
177
|
+
Use square brackets to keep literal text untouched by token replacement:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
format(new Date(2026, 2, 31, 15, 4), { pattern: "[Today at] h:mm a" });
|
|
181
|
+
// → "Today at 3:04 pm"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Bracket literals are not nestable; the first `]` closes the literal block.
|
|
185
|
+
|
|
186
|
+
## 🇧🇩 Bangla Calendar (Core Feature)
|
|
187
|
+
|
|
188
|
+
This is the reason `@coreify/tarikh` exists.
|
|
136
189
|
|
|
137
190
|
Convert Gregorian dates to the Bengali calendar (Bangladesh Revised Calendar, 1987).
|
|
138
191
|
|
|
192
|
+
- **Top feature:** `format("2026-04-14", { mode: "bangla", locale: "bn-BD", format: "spoken" })` returns `পহেলা বৈশাখ ১৪৩৩`.
|
|
139
193
|
- `toBanglaCalendar()` returns a structured object.
|
|
140
194
|
- Default output: English digits + Latin month names (`en-BD`).
|
|
141
195
|
- Locale-aware output: Bangla date words like `১লা`, `২রা`, `৩রা`, `৪ঠা`, `৫ই`, `১৯শে` plus Bangla month names (`bn-BD`).
|
|
142
196
|
- `monthIndex` remains numeric in both cases.
|
|
143
|
-
- `
|
|
197
|
+
- `format(..., { mode: "bangla", locale: "bn-BD", format: "spoken" })` returns spoken day words like `পহেলা`, `দোসরা`, `তেসরা`, `চৌঠা`.
|
|
144
198
|
- `formatBanglaCalendarDay(day, { format: "spoken" })` returns colloquial spoken forms for the first four days: `পহেলা`, `দোসরা`, `তেসরা`, `চৌঠা`.
|
|
145
199
|
- Pass `{ variant: "pohela" }` to keep the standard `পহেলা` spelling explicitly, or `{ variant: "poyla" }` to get `পয়লা` for day 1. The parser also accepts the common `পয়লা` spelling.
|
|
146
200
|
|
|
147
201
|
```ts
|
|
148
202
|
import {
|
|
149
|
-
|
|
203
|
+
format,
|
|
150
204
|
formatBanglaCalendarDay,
|
|
151
205
|
toBanglaCalendar
|
|
152
206
|
} from "@coreify/tarikh";
|
|
@@ -157,25 +211,30 @@ toBanglaCalendar("2026-03-31");
|
|
|
157
211
|
toBanglaCalendar("2026-03-31", { locale: "bn-BD" });
|
|
158
212
|
// → { day: "১৭", month: "চৈত্র", monthIndex: 12, year: "১৪৩২" }
|
|
159
213
|
|
|
160
|
-
|
|
214
|
+
format("2026-03-31", { mode: "bangla" });
|
|
161
215
|
// → "17 Chaitra 1432"
|
|
162
216
|
|
|
163
|
-
|
|
217
|
+
format("2026-03-31", { mode: "bangla", locale: "bn-BD" });
|
|
164
218
|
// → "১৭ই চৈত্র ১৪৩২"
|
|
165
219
|
|
|
166
|
-
|
|
220
|
+
format("2026-04-14", { mode: "bangla" });
|
|
167
221
|
// → "1 Baishakh 1433"
|
|
168
222
|
|
|
169
|
-
|
|
223
|
+
format("2026-04-14", { mode: "bangla", locale: "bn-BD", format: "spoken" });
|
|
170
224
|
// → "পহেলা বৈশাখ ১৪৩৩"
|
|
171
225
|
|
|
172
|
-
|
|
226
|
+
format("2026-04-14", {
|
|
227
|
+
mode: "bangla",
|
|
173
228
|
locale: "bn-BD",
|
|
174
229
|
format: "spoken",
|
|
175
230
|
variant: "poyla"
|
|
176
231
|
});
|
|
177
232
|
// → "পয়লা বৈশাখ ১৪৩৩"
|
|
178
233
|
|
|
234
|
+
// Show today's Bangla date in your app header
|
|
235
|
+
format(new Date(), { mode: "bangla", locale: "bn-BD" });
|
|
236
|
+
// → "১৭ চৈত্র ১৪৩২" (example; depends on the current date)
|
|
237
|
+
|
|
179
238
|
formatBanglaCalendarDay(21);
|
|
180
239
|
// → "২১শে"
|
|
181
240
|
|
|
@@ -194,12 +253,17 @@ formatBanglaCalendarDay(1, { format: "spoken", variant: "pohela" });
|
|
|
194
253
|
Mix English and Bangla independently for day, month, and year.
|
|
195
254
|
|
|
196
255
|
```ts
|
|
197
|
-
import {
|
|
256
|
+
import { format } from "@coreify/tarikh";
|
|
198
257
|
|
|
199
|
-
|
|
258
|
+
format(new Date(), { mode: "hybrid" });
|
|
200
259
|
// → "31 মার্চ 2026"
|
|
201
260
|
|
|
202
|
-
|
|
261
|
+
format(new Date(), {
|
|
262
|
+
mode: "hybrid",
|
|
263
|
+
digits: "bn",
|
|
264
|
+
month: "bn",
|
|
265
|
+
year: "en"
|
|
266
|
+
});
|
|
203
267
|
// → "৩১ মার্চ 2026"
|
|
204
268
|
```
|
|
205
269
|
|
|
@@ -344,92 +408,30 @@ import {
|
|
|
344
408
|
|
|
345
409
|
Optional entry point — only included if you import from `@coreify/tarikh/react`.
|
|
346
410
|
|
|
347
|
-
|
|
348
|
-
npm install @coreify/tarikh react
|
|
349
|
-
```
|
|
411
|
+
Primary React API:
|
|
350
412
|
|
|
351
|
-
|
|
413
|
+
Use `Tarikh` for the default formatter, then reach for the nested variants when you want relative time or Bangla calendar rendering.
|
|
352
414
|
|
|
353
415
|
```tsx
|
|
354
416
|
import { Tarikh } from "@coreify/tarikh/react";
|
|
355
417
|
|
|
356
418
|
<Tarikh value={new Date()} />
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
<Tarikh value={new Date()} locale="bn-BD" />
|
|
360
|
-
// → <time>৩১ মার্চ ২০২৬</time>
|
|
361
|
-
|
|
362
|
-
<Tarikh value={new Date()} month="long" />
|
|
363
|
-
// → <time>31 March 2026</time>
|
|
364
|
-
|
|
365
|
-
<Tarikh
|
|
366
|
-
value={new Date(2026, 2, 31, 15, 4)}
|
|
367
|
-
weekday="short"
|
|
368
|
-
hour="numeric"
|
|
369
|
-
minute="2-digit"
|
|
370
|
-
/>
|
|
371
|
-
// → <time>Tue, 31 Mar 2026, 15:04</time>
|
|
372
|
-
|
|
373
|
-
<Tarikh
|
|
374
|
-
value={new Date(2026, 2, 31, 15, 4, 9)}
|
|
375
|
-
weekday="long"
|
|
376
|
-
hour="2-digit"
|
|
377
|
-
minute="2-digit"
|
|
378
|
-
second="2-digit"
|
|
379
|
-
hour12
|
|
380
|
-
locale="bn-BD"
|
|
381
|
-
/>
|
|
382
|
-
// → <time>মঙ্গলবার, ৩১ মার্চ ২০২৬, ০৩:০৪:০৯ অপরাহ্ণ</time>
|
|
383
|
-
|
|
384
|
-
<Tarikh value="31 March 2026" />
|
|
385
|
-
// → <time dateTime="2026-03-31">31 Mar 2026</time>
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
### RelativeTime
|
|
389
|
-
|
|
390
|
-
```tsx
|
|
391
|
-
import { RelativeTime } from "@coreify/tarikh/react";
|
|
392
|
-
|
|
393
|
-
<RelativeTime value={someDate} />
|
|
394
|
-
// → <time>2 days ago</time>
|
|
395
|
-
|
|
396
|
-
<RelativeTime value={someDate} locale="bn-BD" />
|
|
397
|
-
// → <time>২ দিন আগে</time>
|
|
398
|
-
|
|
399
|
-
<RelativeTime value={someDate} numeric="auto" />
|
|
400
|
-
// → <time>yesterday</time> (for a 1-day past date)
|
|
401
|
-
|
|
402
|
-
<RelativeTime value={someDate} locale="bn-BD" numeric="auto" />
|
|
403
|
-
// → <time>আগামীকাল</time> (for a 1-day future date)
|
|
419
|
+
<Tarikh.Relative value={new Date()} />
|
|
420
|
+
<Tarikh.Bangla value={new Date()} locale="bn-BD" />
|
|
404
421
|
```
|
|
405
422
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
```tsx
|
|
409
|
-
import { BanglaDate } from "@coreify/tarikh/react";
|
|
410
|
-
|
|
411
|
-
<BanglaDate value={new Date()} />
|
|
412
|
-
// → <time>17 Chaitra 1432</time> (example; depends on date)
|
|
413
|
-
|
|
414
|
-
<BanglaDate value={new Date()} locale="bn-BD" />
|
|
415
|
-
// → <time>১৭ই চৈত্র ১৪৩২</time> (example; depends on date)
|
|
416
|
-
|
|
417
|
-
<BanglaDate
|
|
418
|
-
value={new Date()}
|
|
419
|
-
locale="bn-BD"
|
|
420
|
-
format="spoken"
|
|
421
|
-
variant="poyla"
|
|
422
|
-
/>
|
|
423
|
-
// → spoken day + Bangla month (e.g. পয়লা বৈশাখ … on Pohela Baishakh)
|
|
424
|
-
|
|
425
|
-
<BanglaDate value="31 March 2026" />
|
|
426
|
-
// → <time dateTime="2026-03-31">17 Chaitra 1432</time> (example; depends on date)
|
|
423
|
+
```bash
|
|
424
|
+
npm install @coreify/tarikh react
|
|
427
425
|
```
|
|
428
426
|
|
|
429
427
|
All components render semantic `<time>` elements with `dateTime` and `aria-label` attributes. They are SSR-safe, tree-shakeable, and have zero runtime dependencies beyond React.
|
|
430
428
|
|
|
429
|
+
`Tarikh` handles standard date formatting, `Tarikh.Relative` handles relative time, and `Tarikh.Bangla` handles Bangla calendar output.
|
|
430
|
+
|
|
431
431
|
## What `Intl.DateTimeFormat` cannot do
|
|
432
432
|
|
|
433
|
+
If you're building for Bangladesh, existing libraries are not enough.
|
|
434
|
+
|
|
433
435
|
| Feature | Intl | @coreify/tarikh |
|
|
434
436
|
| ------------------------------- | ------- | --------------- |
|
|
435
437
|
| Bangla calendar (বৈশাখ → চৈত্র) | No | Yes |
|
|
@@ -441,36 +443,20 @@ All components render semantic `<time>` elements with `dateTime` and `aria-label
|
|
|
441
443
|
|
|
442
444
|
## TypeScript
|
|
443
445
|
|
|
444
|
-
Fully typed with strict mode.
|
|
446
|
+
Fully typed with strict mode. Start with the primary types below; the package also exports the lower-level calendar and helper types for advanced use.
|
|
447
|
+
|
|
448
|
+
Type-level contract note: when using `pattern`, `mode` is intentionally disallowed in TypeScript.
|
|
445
449
|
|
|
446
450
|
```ts
|
|
447
451
|
import type {
|
|
448
|
-
DateInput,
|
|
449
|
-
DayFormat,
|
|
450
|
-
MonthFormat,
|
|
451
452
|
Locale,
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
BanglaCalendarOptions,
|
|
457
|
-
RelativeTimeOptions,
|
|
458
|
-
BanglaCalendarFormatOptions,
|
|
459
|
-
BanglaCalendarDayFormat,
|
|
460
|
-
BanglaCalendarDaySpokenVariant,
|
|
461
|
-
BanglaDayFormatOptions,
|
|
462
|
-
DateFormatOptions,
|
|
463
|
-
BanglaCalendarDate,
|
|
464
|
-
HybridDateFormatOptions
|
|
453
|
+
FormatMode,
|
|
454
|
+
FormatOptions,
|
|
455
|
+
DateInput,
|
|
456
|
+
RelativeTimeOptions
|
|
465
457
|
} from "@coreify/tarikh";
|
|
466
|
-
```
|
|
467
458
|
|
|
468
|
-
|
|
469
|
-
import type {
|
|
470
|
-
BanglaDateProps,
|
|
471
|
-
RelativeTimeProps,
|
|
472
|
-
TarikhProps
|
|
473
|
-
} from "@coreify/tarikh/react";
|
|
459
|
+
import type { TarikhProps } from "@coreify/tarikh/react";
|
|
474
460
|
```
|
|
475
461
|
|
|
476
462
|
## License
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=["0","1","2","3","4","5","6","7","8","9"],e=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],s=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],u=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],i=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],l=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],g=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],c=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],h=[31,31,31,31,31,30,30,30,30,30,30,30],d={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},f={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function m(t){return String(t).replace(/\d/g,t=>e[Number(t)]??t)}function D(n){return String(n).replace(/[০-৯]/g,n=>{const r=e.indexOf(n);return r>=0?t[r]??n:n})}var M={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function p(t){const e=t.trim(),o=e.toLowerCase(),a=M[o];if(void 0!==a)return a;for(let t=0;t<n.length;t++)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t++)if(r[t].toLowerCase()===o)return t;for(let t=0;t<s.length;t++)if(s[t]===e)return t;for(let t=0;t<u.length;t++)if(u[t]===e)return t;return-1}function y(t,e,n,r=0,o=0,a=0,s=0){const u=new Date(t,e,n,r,o,a,s);return u.getFullYear()!==t||u.getMonth()!==e||u.getDate()!==n||u.getHours()!==r||u.getMinutes()!==o||u.getSeconds()!==a||u.getMilliseconds()!==s?null:u}function b(t){return function(t){const e=t.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return e?y(Number(e[1]),Number(e[3])-1,Number(e[4])):null}(t)??function(t){const e=t.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),a=Number(e[4]??0),s=Number(e[5]??0),u=Number(e[6]??0),i=Number((e[7]??"0").padEnd(3,"0").slice(0,3)),l=e[8];if(void 0===l)return y(n,r-1,o,a,s,u,i);const g=l.match(/^([+-])(\d{2}):?(\d{2})$/),c="Z"===l?0:g?("+"===g[1]?1:-1)*(60*Number(g[2])+Number(g[3])):null;if(null===c)return null;const h=Date.UTC(n,r-1,o,a,s,u,i)-6e4*c,d=new Date(h),f=new Date(h+6e4*c);return f.getUTCFullYear()!==n||f.getUTCMonth()!==r-1||f.getUTCDate()!==o||f.getUTCHours()!==a||f.getUTCMinutes()!==s||f.getUTCSeconds()!==u||f.getUTCMilliseconds()!==i?null:d}(t)??function(t){const e=t.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!e)return null;const n=Number(e[1]),r=e[2].replace(/,$/,""),o=e[3],a=p(r);if(-1===a)return null;let s=Number(o);return 2===o.length&&(s+=s>=50?1900:2e3),y(s,a,n)}(t)??function(t){const e=t.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!e)return null;const n=e[1].replace(/,$/,""),r=Number(e[2]),o=e[3],a=p(n);if(-1===a)return null;let s=Number(o);return 2===o.length&&(s+=s>=50?1900:2e3),y(s,a,r)}(t)}function S(t){if(t instanceof Date){const e=t.getTime();if(Number.isNaN(e))throw new Error(`Invalid date input: ${String(t)}`);return new Date(e)}if("number"==typeof t){if(!Number.isFinite(t))throw new Error(`Invalid date input: ${String(t)}`);const e=new Date(t);if(Number.isNaN(e.getTime()))throw new Error(`Invalid date input: ${String(t)}`);return e}const e=b(D(t).trim());if(!e)throw new Error(`Invalid date input: ${String(t)}`);return e}function N(t,e){const n=S(t);return n.setDate(n.getDate()+e),n}function w(t,e){return new Date(t,e+1,0).getDate()}function $(t,e){const n=S(t),r=n.getFullYear(),o=n.getMonth()+e,a=r+Math.floor(o/12),s=(o%12+12)%12,u=Math.min(n.getDate(),w(a,s));return n.setFullYear(a,s,u),n}function x(t,e){const n=S(t),r=n.getFullYear()+e,o=Math.min(n.getDate(),w(r,n.getMonth()));return n.setFullYear(r,n.getMonth(),o),n}function Y(t){const e=[...h];return function(t){return(e=t+594)%4==0&&e%100!=0||e%400==0;var e}(t)&&(e[10]=31),e}function T(t,e){const n=e?.locale??"en-BD",r=S(t),o=r.getFullYear(),a=r.getMonth(),s=r.getDate(),u=new Date(o,3,14),i=a<3||3===a&&s<14,l=i?o-594:o-593,h=function(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor((r-n)/864e5)}(i?new Date(o-1,3,14):u,r)+1,d=Y(l);let f=h,D=0;for(let t=0;t<d.length;t++){const e=d[t];if(f<=e){D=t;break}f-=e}const M=D+1;return"bn-BD"===n?{day:m(f),month:g[D],monthIndex:M,year:m(l)}:{day:f,month:c[D],monthIndex:M,year:l}}function A(t,e,n){const r=function(t,e,n){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(n))throw new Error("Invalid Bangla calendar date.");if(e<1||e>12)throw new Error("Invalid Bangla calendar month index. Must be 1-12.");const r=Y(n),o=r[e-1];if(t<1||t>o)throw new Error(`Invalid Bangla calendar day. Month ${e} of year ${n} has ${o} days.`);return r}(t,e,n),o=new Date(n+593,3,14);let a=t-1;for(let t=0;t<e-1;t++)a+=r[t];const s=new Date(o);return s.setDate(s.getDate()+a),s}function H(t){const e=m(t);return 1===t?`${e}লা`:2===t||3===t?`${e}রা`:4===t?`${e}ঠা`:t>=19?`${e}শে`:`${e}ই`}function B(t,e){return"spoken"===(e?.format??"ordinal")?function(t,e="pohela"){switch(t){case 1:return"poyla"===e?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return H(t)}}(t,e?.variant):H(t)}function F(t,e){return"2-digit"===e?String(t).padStart(2,"0"):String(t)}function v(t,e,n){if("bn-BD"===e)return t<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=t<12?"AM":"PM";return n?r.toLowerCase():r}var E={baishakh:1,boishakh:1,boishak:1,boisakh:1,jaishtho:2,jaishtha:2,jaistha:2,joishtho:2,jyoishtho:2,jyoistho:2,jyeshtho:2,ashar:3,asadh:3,asharh:3,srabon:4,shraban:4,shrabon:4,sraban:4,bhadro:5,ashin:6,ashwin:6,ashshin:6,kartik:7,ograyon:8,ograyan:8,ogrohayon:8,ograhayon:8,agrahayan:8,aghrayan:8,pous:9,poush:9,mag:10,magh:10,falgoon:11,falgun:11,choitra:12,chaitra:12,choitro:12},_={"বৈশাখ":1,"জৈষ্ঠ":2,"জ্যৈষ্ঠ":2,"আষাঢ়":3,"আষাঢ়":3,"শ্রাবণ":4,"ভাদ্র":5,"আশ্বিন":6,"কার্তিক":7,"অগ্রহায়ণ":8,"অগ্রহায়ণ":8,"অঘ্রাণ":8,"অগ্রায়ণ":8,"অগ্রায়ণ":8,"পৌষ":9,"পৌস":9,"মাঘ":10,"ফাল্গুন":11,"চৈত্র":12};var L=1e3,I=36e5,j=24*I,k=[{threshold:7*j,singular:"week",plural:"weeks"},{threshold:j,singular:"day",plural:"days"},{threshold:I,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:L,singular:"second",plural:"seconds"}];function C(t,e){return new Date(t,e+1,0).getDate()}function O(t,e){let n=t.getFullYear()-e.getFullYear();const r=function(t,e){const n=t.getFullYear()+e,r=t.getMonth(),o=Math.min(t.getDate(),C(n,r));return new Date(n,r,o,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function G(t,e){let n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth());const r=function(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=n+Math.floor(r/12),a=(r%12+12)%12,s=Math.min(t.getDate(),C(o,a));return new Date(o,a,s,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function U(t,e,n,r,o){const a="bn-BD"===o,s=a?m(t):String(t),u=1===t?e:n;return a?r?`${s} ${u} আগে`:`${s} ${u} পরে`:r?`${s} ${u} ago`:`in ${s} ${u}`}function R(t,e,n){return"bn-BD"===n?"day"===t?e?"গতকাল":"আগামীকাল":"week"===t?e?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===t?e?"গত মাসে":"আগামী মাসে":e?"গত বছর":"আগামী বছর":"day"===t?e?"yesterday":"tomorrow":"week"===t?e?"last week":"next week":"month"===t?e?"last month":"next month":e?"last year":"next year"}exports.BANGLA_CALENDAR_MONTHS=g,exports.BANGLA_CALENDAR_MONTHS_EN=c,exports.BANGLA_CALENDAR_MONTH_DAYS=h,exports.BANGLA_DIGITS=e,exports.BANGLA_MONTHS_FULL=s,exports.BANGLA_MONTHS_SHORT=u,exports.BANGLA_WEEKDAYS_FULL=i,exports.BANGLA_WEEKDAYS_SHORT=l,exports.BOISHAKH_START_DAY=14,exports.BOISHAKH_START_MONTH=3,exports.ENGLISH_DIGITS=t,exports.ENGLISH_MONTHS_FULL=n,exports.ENGLISH_MONTHS_SHORT=r,exports.ENGLISH_WEEKDAYS_FULL=o,exports.ENGLISH_WEEKDAYS_SHORT=a,exports.RELATIVE_TIME_BN=f,exports.RELATIVE_TIME_EN=d,exports.addDays=N,exports.addMonths=$,exports.addYears=x,exports.endOfDay=function(t){const e=S(t);return e.setHours(23,59,59,999),e},exports.endOfMonth=function(t){const e=S(t);return e.setMonth(e.getMonth()+1,0),e.setHours(23,59,59,999),e},exports.endOfYear=function(t){const e=S(t);return e.setMonth(11,31),e.setHours(23,59,59,999),e},exports.format=function(t,e,g){const c=S(t),h=g?.locale??"en-BD",d="bn-BD"===h,f=c.getDate(),D=c.getMonth(),M=c.getFullYear(),p=d?s:n,y=d?u:r,b=d?i:o,N=d?l:a,w=c.getHours(),$=w%12||12,x={dddd:b[c.getDay()],ddd:N[c.getDay()],MMMM:p[D],MMM:y[D],MM:String(D+1).padStart(2,"0"),M:String(D+1),DD:String(f).padStart(2,"0"),D:String(f),HH:String(w).padStart(2,"0"),H:String(w),hh:String($).padStart(2,"0"),h:String($),mm:String(c.getMinutes()).padStart(2,"0"),m:String(c.getMinutes()),ss:String(c.getSeconds()).padStart(2,"0"),s:String(c.getSeconds()),A:v(w,h,!1),a:v(w,h,!0),YYYY:String(M),YY:String(M).slice(-2)},Y=e.replace(/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,t=>x[t]);return d?m(Y):Y},exports.formatBanglaCalendar=function(t,e){const n=e?.locale??"en-BD",r=e?.format??"ordinal",o=e?.variant,a=T(t,{locale:"en-BD"});if("bn-BD"===n){const t=a.monthIndex-1,e={format:r};return void 0!==o&&(e.variant=o),`${B(a.day,e)} ${g[t]} ${m(a.year)}`}return`${a.day} ${a.month} ${a.year}`},exports.formatBanglaCalendarDay=B,exports.formatDate=function(t,e){const g=S(t),c=e?.locale??"en-BD",h=e?.month??"short",d=e?.year??"numeric",f=e?.day??"numeric",D=e?.weekday,M=e?.hour,p=e?.minute,y=e?.second,b=void 0!==M||void 0!==p||void 0!==y,N="bn-BD"===c,w=g.getDate(),$=g.getMonth(),x=g.getFullYear(),Y=`${"2-digit"===f?String(w).padStart(2,"0"):String(w)} ${(N?"short"===h?u:s:"short"===h?r:n)[$]} ${"2-digit"===d?String(x).slice(-2):String(x)}`,T=void 0!==D?`${(N?"short"===D?l:i:"short"===D?a:o)[g.getDay()]}, `:"";let A="";if(b){const t=e?.hour12??!1,n=g.getHours(),r=p??(void 0!==y?"2-digit":void 0);A=`${F(t?n%12||12:n,M??"numeric")}${void 0!==r?`:${F(g.getMinutes(),r)}`:""}${void 0!==y?`:${F(g.getSeconds(),y)}`:""}${t?` ${v(n,c,!1)}`:""}`}const H=`${T}${Y}${A?`, ${A}`:""}`;return N?m(H):H},exports.formatHybridDate=function(t,e){const o=S(t),a=e?.digits??"en",i=e?.month??"bn",l=e?.year??"en",g=e?.day??a,c=e?.monthFormat??"long",h=o.getDate(),d=o.getMonth(),f=o.getFullYear(),D="bn"===i?"short"===c?u:s:"short"===c?r:n;return`${"bn"===g?m(h):String(h)} ${D[d]} ${"bn"===l?m(f):String(f)}`},exports.fromBanglaCalendar=A,exports.fromNow=function(t,e){const n=S(t),r=e?.locale??"en-BD",o=e?.numeric??"always",a="bn-BD"===r?f:d,s=Date.now()-n.getTime(),u=Math.abs(s),i=s>0,l=new Date,g=n.getFullYear()===l.getFullYear()&&n.getMonth()===l.getMonth()&&n.getDate()===l.getDate(),c=i?l:n,h=i?n:l;if(u<L)return a.justNow;if("auto"===o&&g)return function(t){return"bn-BD"===t?"আজ":"today"}(r);const m=O(c,h);if(m>=1){if("auto"===o&&1===m){const t=R("year",i,r);if(null!==t)return t}return U(m,a.year,a.years,i,r)}const D=G(c,h);if(D>=1){if("auto"===o&&1===D){const t=R("month",i,r);if(null!==t)return t}return U(D,a.month,a.months,i,r)}for(const t of k)if(u>=t.threshold){const e=Math.floor(u/t.threshold);if("auto"===o&&1===e&&("day"===t.singular||"week"===t.singular)){const e=R(t.singular,i,r);if(null!==e)return e}return U(e,a[t.singular],a[t.plural],i,r)}return a.justNow},exports.getBanglaMonth=function(t,e="long"){const n=t-1;if(n<0||n>11)throw new Error(`Invalid month number: ${t}. Must be 1-12.`);return"short"===e?u[n]:s[n]},exports.isToday=function(t){const e=S(t),n=new Date;return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.isTomorrow=function(t){const e=S(t),n=new Date;return n.setDate(n.getDate()+1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.isYesterday=function(t){const e=S(t),n=new Date;return n.setDate(n.getDate()-1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.parseDate=function(t,e){if(t instanceof Date)return Number.isNaN(t.getTime())?null:new Date(t.getTime());if("number"==typeof t){const e=new Date(t);return Number.isNaN(e.getTime())?null:e}const n=D(t).trim();return"bangla"===e?.calendar?function(t){const e=t.match(/^(\S+),?\s+(\S+),?\s+(\d{4})$/);if(!e)return null;const n=function(t){const e={"পহেলা":1,"পয়লা":1,"পয়লা":1,"দোসরা":2,"তেসরা":3,"চৌঠা":4}[t];if(void 0!==e)return e;const n=t.match(/^(\d{1,2})(?:লা|রা|ঠা|ই|শে)$/);if(n)return Number(n[1]);const r=Number(t);return Number.isInteger(r)&&r>=1&&r<=31?r:null}(e[1].replace(/,$/,""));if(null===n)return null;const r=function(t){const e=t.toLowerCase();for(let e=0;e<g.length;e++)if(g[e]===t)return e+1;const n=_[t];if(void 0!==n)return n;for(let t=0;t<c.length;t++)if(c[t].toLowerCase()===e)return t+1;const r=E[e];return void 0!==r?r:-1}(e[2].replace(/,$/,""));if(-1===r)return null;const o=Number(e[3]);try{return A(n,r,o)}catch{return null}}(n):b(n)},exports.startOfDay=function(t){const e=S(t);return e.setHours(0,0,0,0),e},exports.startOfMonth=function(t){const e=S(t);return e.setDate(1),e.setHours(0,0,0,0),e},exports.startOfYear=function(t){const e=S(t);return e.setMonth(0,1),e.setHours(0,0,0,0),e},exports.subDays=function(t,e){return N(t,-e)},exports.subMonths=function(t,e){return $(t,-e)},exports.subYears=function(t,e){return x(t,-e)},exports.toBanglaCalendar=T,exports.toBanglaDigits=m,exports.toDate=S,exports.toEnglishDigits=D;
|
|
1
|
+
"use strict";var t=["0","1","2","3","4","5","6","7","8","9"],e=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],s=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],u=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],i=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],l=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],d=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],c=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],g=[31,31,31,31,31,30,30,30,30,30,30,30],h={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},f={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function m(t){return String(t).replace(/\d/g,t=>e[Number(t)]??t)}function y(n){return String(n).replace(/[০-৯]/g,n=>{const r=e.indexOf(n);return r>=0?t[r]??n:n})}var D={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function p(t){const e=t.trim(),o=e.toLowerCase(),a=D[o];if(void 0!==a)return a;for(let t=0;t<n.length;t++)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t++)if(r[t].toLowerCase()===o)return t;for(let t=0;t<s.length;t++)if(s[t]===e)return t;for(let t=0;t<u.length;t++)if(u[t]===e)return t;return-1}function b(t,e,n,r=0,o=0,a=0,s=0){const u=new Date(t,e,n,r,o,a,s);return u.getFullYear()!==t||u.getMonth()!==e||u.getDate()!==n||u.getHours()!==r||u.getMinutes()!==o||u.getSeconds()!==a||u.getMilliseconds()!==s?null:u}function M(t){return function(t){const e=t.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return e?b(Number(e[1]),Number(e[3])-1,Number(e[4])):null}(t)??function(t){const e=t.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),a=Number(e[4]??0),s=Number(e[5]??0),u=Number(e[6]??0),i=Number((e[7]??"0").padEnd(3,"0").slice(0,3)),l=e[8];if(void 0===l)return b(n,r-1,o,a,s,u,i);const d=l.match(/^([+-])(\d{2}):?(\d{2})$/),c=d?Number(d[2]):null,g=d?Number(d[3]):null,h="Z"===l?0:d&&null!==c&&null!==g&&c<=23&&g<=59?("+"===d[1]?1:-1)*(60*c+g):null;if(null===h)return null;const f=Date.UTC(n,r-1,o,a,s,u,i)-6e4*h,m=new Date(f),y=new Date(f+6e4*h);return y.getUTCFullYear()!==n||y.getUTCMonth()!==r-1||y.getUTCDate()!==o||y.getUTCHours()!==a||y.getUTCMinutes()!==s||y.getUTCSeconds()!==u||y.getUTCMilliseconds()!==i?null:m}(t)??function(t){const e=t.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!e)return null;const n=Number(e[1]),r=e[2].replace(/,$/,""),o=e[3],a=p(r);if(-1===a)return null;let s=Number(o);return 2===o.length&&(s+=s>=50?1900:2e3),b(s,a,n)}(t)??function(t){const e=t.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!e)return null;const n=e[1].replace(/,$/,""),r=Number(e[2]),o=e[3],a=p(n);if(-1===a)return null;let s=Number(o);return 2===o.length&&(s+=s>=50?1900:2e3),b(s,a,r)}(t)}function w(t){if(t instanceof Date){const e=t.getTime();if(Number.isNaN(e))throw new Error(`Invalid date input: ${String(t)}`);return new Date(e)}if("number"==typeof t){if(!Number.isFinite(t))throw new Error(`Invalid date input: ${String(t)}`);const e=new Date(t);if(Number.isNaN(e.getTime()))throw new Error(`Invalid date input: ${String(t)}`);return e}const e=M(y(t).trim());if(!e)throw new Error(`Invalid date input: ${String(t)}`);return e}function N(t,e){const n=w(t);return n.setDate(n.getDate()+e),n}function S(t,e){return new Date(t,e+1,0).getDate()}function $(t,e){const n=w(t),r=n.getFullYear(),o=n.getMonth()+e,a=r+Math.floor(o/12),s=(o%12+12)%12,u=Math.min(n.getDate(),S(a,s));return n.setFullYear(a,s,u),n}function x(t,e){const n=w(t),r=n.getFullYear()+e,o=Math.min(n.getDate(),S(r,n.getMonth()));return n.setFullYear(r,n.getMonth(),o),n}function T(t){const e=[...g];return function(t){return(e=t+594)%4==0&&e%100!=0||e%400==0;var e}(t)&&(e[10]=31),e}function Y(t,e){const n=e?.locale??"en-BD",r=w(t),o=r.getFullYear(),a=r.getMonth(),s=r.getDate(),u=new Date(o,3,14),i=a<3||3===a&&s<14,l=i?o-594:o-593,g=function(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor((r-n)/864e5)}(i?new Date(o-1,3,14):u,r)+1,h=T(l);let f=g,y=0;for(let t=0;t<h.length;t++){const e=h[t];if(f<=e){y=t;break}f-=e}const D=y+1;return"bn-BD"===n?{day:m(f),month:d[y],monthIndex:D,year:m(l)}:{day:f,month:c[y],monthIndex:D,year:l}}function v(t,e,n){const r=function(t,e,n){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(n))throw new Error("Invalid Bangla calendar date.");if(e<1||e>12)throw new Error("Invalid Bangla calendar month index. Must be 1-12.");const r=T(n),o=r[e-1];if(t<1||t>o)throw new Error(`Invalid Bangla calendar day. Month ${e} of year ${n} has ${o} days.`);return r}(t,e,n),o=new Date(n+593,3,14);let a=t-1;for(let t=0;t<e-1;t++)a+=r[t];const s=new Date(o);return s.setDate(s.getDate()+a),s}function A(t){const e=m(t);return 1===t?`${e}লা`:2===t||3===t?`${e}রা`:4===t?`${e}ঠা`:t>=19?`${e}শে`:`${e}ই`}function E(t,e){return"spoken"===(e?.format??"ordinal")?function(t,e="pohela"){switch(t){case 1:return"poyla"===e?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return A(t)}}(t,e?.variant):A(t)}function H(t,e){return"2-digit"===e?String(t).padStart(2,"0"):String(t)}function B(t,e,n){const r=H(t,n);return"bn-BD"===e?m(r):r}function F(t,e,n){if(!e.includes(t))throw new TypeError(`Invalid ${n}: ${t}`)}function _(t,e,n){if("bn-BD"===e)return t<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=t<12?"AM":"PM";return n?r.toLowerCase():r}var I={baishakh:1,boishakh:1,boishak:1,boisakh:1,jaishtho:2,jaishtha:2,jaistha:2,joishtho:2,jyoishtho:2,jyoistho:2,jyeshtho:2,ashar:3,asadh:3,asharh:3,srabon:4,shraban:4,shrabon:4,sraban:4,bhadro:5,ashin:6,ashwin:6,ashshin:6,kartik:7,ograyon:8,ograyan:8,ogrohayon:8,ograhayon:8,agrahayan:8,aghrayan:8,pous:9,poush:9,mag:10,magh:10,falgoon:11,falgun:11,choitra:12,chaitra:12,choitro:12},L={"বৈশাখ":1,"জৈষ্ঠ":2,"জ্যৈষ্ঠ":2,"আষাঢ়":3,"আষাঢ়":3,"শ্রাবণ":4,"ভাদ্র":5,"আশ্বিন":6,"কার্তিক":7,"অগ্রহায়ণ":8,"অগ্রহায়ণ":8,"অঘ্রাণ":8,"অগ্রায়ণ":8,"অগ্রায়ণ":8,"পৌষ":9,"পৌস":9,"মাঘ":10,"ফাল্গুন":11,"চৈত্র":12};var k=1e3,j=36e5,O=24*j,C=[{threshold:7*O,singular:"week",plural:"weeks"},{threshold:O,singular:"day",plural:"days"},{threshold:j,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:k,singular:"second",plural:"seconds"}];function G(t,e){return new Date(t,e+1,0).getDate()}function U(t,e){let n=t.getFullYear()-e.getFullYear();const r=function(t,e){const n=t.getFullYear()+e,r=t.getMonth(),o=Math.min(t.getDate(),G(n,r));return new Date(n,r,o,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function R(t,e){let n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth());const r=function(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=n+Math.floor(r/12),a=(r%12+12)%12,s=Math.min(t.getDate(),G(o,a));return new Date(o,a,s,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function J(t,e,n,r,o){const a="bn-BD"===o,s=a?m(t):String(t),u=1===t?e:n;return a?r?`${s} ${u} আগে`:`${s} ${u} পরে`:r?`${s} ${u} ago`:`in ${s} ${u}`}function K(t,e,n){return"bn-BD"===n?"day"===t?e?"গতকাল":"আগামীকাল":"week"===t?e?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===t?e?"গত মাসে":"আগামী মাসে":e?"গত বছর":"আগামী বছর":"day"===t?e?"yesterday":"tomorrow":"week"===t?e?"last week":"next week":"month"===t?e?"last month":"next month":e?"last year":"next year"}exports.BANGLA_CALENDAR_MONTHS=d,exports.BANGLA_CALENDAR_MONTHS_EN=c,exports.BANGLA_CALENDAR_MONTH_DAYS=g,exports.BANGLA_DIGITS=e,exports.BANGLA_MONTHS_FULL=s,exports.BANGLA_MONTHS_SHORT=u,exports.BANGLA_WEEKDAYS_FULL=i,exports.BANGLA_WEEKDAYS_SHORT=l,exports.BOISHAKH_START_DAY=14,exports.BOISHAKH_START_MONTH=3,exports.ENGLISH_DIGITS=t,exports.ENGLISH_MONTHS_FULL=n,exports.ENGLISH_MONTHS_SHORT=r,exports.ENGLISH_WEEKDAYS_FULL=o,exports.ENGLISH_WEEKDAYS_SHORT=a,exports.RELATIVE_TIME_BN=f,exports.RELATIVE_TIME_EN=h,exports.addDays=N,exports.addMonths=$,exports.addYears=x,exports.endOfDay=function(t){const e=w(t);return e.setHours(23,59,59,999),e},exports.endOfMonth=function(t){const e=w(t);return e.setMonth(e.getMonth()+1,0),e.setHours(23,59,59,999),e},exports.endOfYear=function(t){const e=w(t);return e.setMonth(11,31),e.setHours(23,59,59,999),e},exports.format=function(t,e){if(null===e||"object"!=typeof e||Array.isArray(e))throw new TypeError("format() expects an options object");if("pattern"in e&&void 0!==e.pattern){if("mode"in e&&void 0!==e.mode)throw new TypeError("Do not pass `mode` when `pattern` is provided. `pattern` formatting does not use mode.");const d="locale"in e&&void 0!==e.locale?e.locale:"en-BD";return function(t,e,d="en-BD"){const c=w(t),g="bn-BD"===d,h=c.getDate(),f=c.getMonth(),m=c.getFullYear(),y=g?s:n,D=g?u:r,p=g?i:o,b=g?l:a,M=c.getHours(),N=M%12||12,S={dddd:p[c.getDay()],ddd:b[c.getDay()],MMMM:y[f],MMM:D[f],MM:B(f+1,d,"2-digit"),M:B(f+1,d,"numeric"),DD:B(h,d,"2-digit"),D:B(h,d,"numeric"),HH:B(M,d,"2-digit"),H:B(M,d,"numeric"),hh:B(N,d,"2-digit"),h:B(N,d,"numeric"),mm:B(c.getMinutes(),d,"2-digit"),m:B(c.getMinutes(),d,"numeric"),ss:B(c.getSeconds(),d,"2-digit"),s:B(c.getSeconds(),d,"numeric"),A:_(M,d,!1),a:_(M,d,!0),YYYY:B(m,d,"numeric"),YY:B(Number(String(m).slice(-2)),d,"2-digit")},$=/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,x=t=>t.replace($,t=>S[t]);let T="",Y=0;for(;Y<e.length;){const t=e.indexOf("[",Y);if(-1===t){T+=x(e.slice(Y));break}T+=x(e.slice(Y,t));const n=e.indexOf("]",t+1);if(-1===n){T+=e.slice(t);break}T+=e.slice(t+1,n),Y=n+1}return T}(t,e.pattern,d)}if(!("mode"in e)||void 0===e.mode)throw new TypeError("format() expects `mode` or `pattern`");const c=e.mode;switch(c){case"standard":return function(t,e){const d=w(t),c=e?.locale??"en-BD",g=e?.month??"short",h=e?.year??"numeric",f=e?.day??"numeric",y=e?.weekday,D=e?.hour,p=e?.minute,b=e?.second,M=void 0!==D||void 0!==p||void 0!==b,N="bn-BD"===c;F(g,["short","long"],"month format for standard mode"),F(h,["numeric","2-digit"],"year format for standard mode"),F(f,["numeric","2-digit"],"day format for standard mode"),void 0!==y&&F(y,["short","long"],"weekday format for standard mode"),void 0!==D&&F(D,["numeric","2-digit"],"hour format for standard mode"),void 0!==p&&F(p,["numeric","2-digit"],"minute format for standard mode"),void 0!==b&&F(b,["numeric","2-digit"],"second format for standard mode");const S=d.getDate(),$=d.getMonth(),x=d.getFullYear(),T=`${"2-digit"===f?String(S).padStart(2,"0"):String(S)} ${(N?"short"===g?u:s:"short"===g?r:n)[$]} ${"2-digit"===h?String(x).slice(-2):String(x)}`,Y=void 0!==y?`${(N?"short"===y?l:i:"short"===y?a:o)[d.getDay()]}, `:"";let v="";if(M){const t=e?.hour12??!1,n=d.getHours(),r=p??(void 0!==b?"2-digit":void 0);v=`${H(t?n%12||12:n,D??"numeric")}${void 0!==r?`:${H(d.getMinutes(),r)}`:""}${void 0!==b?`:${H(d.getSeconds(),b)}`:""}${t?` ${_(n,c,!1)}`:""}`}const A=`${Y}${T}${v?`, ${v}`:""}`;return N?m(A):A}(t,e);case"bangla":return function(t,e){const n=e?.locale??"en-BD",r=e?.format??"ordinal",o=e?.variant,a=Y(t,{locale:"en-BD"});if("bn-BD"===n){const t=a.monthIndex-1,e={format:r};return void 0!==o&&(e.variant=o),`${E(a.day,e)} ${d[t]} ${m(a.year)}`}return`${a.day} ${a.month} ${a.year}`}(t,e);case"hybrid":return function(t,e){const o=w(t),a=e?.digits??"en",i=e?.month??"bn",l=e?.year??"en",d=e?.day??a,c=e?.monthFormat??"long";F(a,["en","bn"],"digits language for hybrid mode"),F(i,["en","bn"],"month language for hybrid mode"),F(l,["en","bn"],"year language for hybrid mode"),F(d,["en","bn"],"day language for hybrid mode"),F(c,["short","long"],"month format for hybrid mode");const g=o.getDate(),h=o.getMonth(),f=o.getFullYear(),y="bn"===i?"short"===c?u:s:"short"===c?r:n,D="bn"===d?m(g):String(g),p=y[h],b="bn"===l?m(f):String(f);return`${D} ${p} ${b}`}(t,e);default:throw new TypeError(`Invalid format mode: ${String(c)}`)}},exports.formatBanglaCalendarDay=E,exports.fromBanglaCalendar=v,exports.fromNow=function(t,e){const n=w(t),r=e?.locale??"en-BD",o=e?.numeric??"always",a="bn-BD"===r?f:h,s=Date.now()-n.getTime(),u=Math.abs(s),i=s>0,l=new Date,d=n.getFullYear()===l.getFullYear()&&n.getMonth()===l.getMonth()&&n.getDate()===l.getDate(),c=i?l:n,g=i?n:l;if(u<k)return a.justNow;if("auto"===o&&d)return function(t){return"bn-BD"===t?"আজ":"today"}(r);const m=U(c,g);if(m>=1){if("auto"===o&&1===m){const t=K("year",i,r);if(null!==t)return t}return J(m,a.year,a.years,i,r)}const y=R(c,g);if(y>=1){if("auto"===o&&1===y){const t=K("month",i,r);if(null!==t)return t}return J(y,a.month,a.months,i,r)}for(const t of C)if(u>=t.threshold){const e=Math.floor(u/t.threshold);if("auto"===o&&1===e&&("day"===t.singular||"week"===t.singular)){const e=K(t.singular,i,r);if(null!==e)return e}return J(e,a[t.singular],a[t.plural],i,r)}return a.justNow},exports.getBanglaMonth=function(t,e="long"){const n=t-1;if(n<0||n>11)throw new Error(`Invalid month number: ${t}. Must be 1-12.`);return"short"===e?u[n]:s[n]},exports.isToday=function(t){const e=w(t),n=new Date;return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.isTomorrow=function(t){const e=w(t),n=new Date;return n.setDate(n.getDate()+1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.isYesterday=function(t){const e=w(t),n=new Date;return n.setDate(n.getDate()-1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.parseDate=function(t,e){if(t instanceof Date)return Number.isNaN(t.getTime())?null:new Date(t.getTime());if("number"==typeof t){const e=new Date(t);return Number.isNaN(e.getTime())?null:e}const n=y(t).trim();return"bangla"===e?.calendar?function(t){const e=t.match(/^(\S+),?\s+(\S+),?\s+(\d{4})$/);if(!e)return null;const n=function(t){const e={"পহেলা":1,"পয়লা":1,"পয়লা":1,"দোসরা":2,"তেসরা":3,"চৌঠা":4}[t];if(void 0!==e)return e;const n=t.match(/^(\d{1,2})(?:লা|রা|ঠা|ই|শে)$/);if(n)return Number(n[1]);const r=Number(t);return Number.isInteger(r)&&r>=1&&r<=31?r:null}(e[1].replace(/,$/,""));if(null===n)return null;const r=function(t){const e=t.toLowerCase();for(let e=0;e<d.length;e++)if(d[e]===t)return e+1;const n=L[t];if(void 0!==n)return n;for(let t=0;t<c.length;t++)if(c[t].toLowerCase()===e)return t+1;const r=I[e];return void 0!==r?r:-1}(e[2].replace(/,$/,""));if(-1===r)return null;const o=Number(e[3]);try{return v(n,r,o)}catch{return null}}(n):M(n)},exports.startOfDay=function(t){const e=w(t);return e.setHours(0,0,0,0),e},exports.startOfMonth=function(t){const e=w(t);return e.setDate(1),e.setHours(0,0,0,0),e},exports.startOfYear=function(t){const e=w(t);return e.setMonth(0,1),e.setHours(0,0,0,0),e},exports.subDays=function(t,e){return N(t,-e)},exports.subMonths=function(t,e){return $(t,-e)},exports.subYears=function(t,e){return x(t,-e)},exports.toBanglaCalendar=Y,exports.toBanglaDigits=m,exports.toDate=w,exports.toEnglishDigits=y;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,7 @@ type YearFormat = "numeric" | "2-digit";
|
|
|
5
5
|
type DayFormat = "numeric" | "2-digit";
|
|
6
6
|
type WeekdayFormat = "short" | "long";
|
|
7
7
|
type TimeFormat = "numeric" | "2-digit";
|
|
8
|
+
type FormatMode = "standard" | "bangla" | "hybrid";
|
|
8
9
|
type DateInput = Date | string | number;
|
|
9
10
|
interface DateFormatOptions {
|
|
10
11
|
locale?: Locale;
|
|
@@ -17,9 +18,24 @@ interface DateFormatOptions {
|
|
|
17
18
|
second?: TimeFormat;
|
|
18
19
|
hour12?: boolean;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
type PatternFormatOptions = {
|
|
22
|
+
pattern: string;
|
|
21
23
|
locale?: Locale;
|
|
22
|
-
|
|
24
|
+
mode?: never;
|
|
25
|
+
};
|
|
26
|
+
type StandardFormatOptions = DateFormatOptions & {
|
|
27
|
+
mode: "standard";
|
|
28
|
+
pattern?: never;
|
|
29
|
+
};
|
|
30
|
+
type BanglaFormatOptions = BanglaCalendarFormatOptions & {
|
|
31
|
+
mode: "bangla";
|
|
32
|
+
pattern?: never;
|
|
33
|
+
};
|
|
34
|
+
type HybridFormatOptions = HybridDateFormatOptions & {
|
|
35
|
+
mode: "hybrid";
|
|
36
|
+
pattern?: never;
|
|
37
|
+
};
|
|
38
|
+
type FormatOptions = PatternFormatOptions | StandardFormatOptions | BanglaFormatOptions | HybridFormatOptions;
|
|
23
39
|
interface HybridDateFormatOptions {
|
|
24
40
|
digits?: Language;
|
|
25
41
|
month?: Language;
|
|
@@ -125,10 +141,7 @@ declare function toBanglaDigits(input: number | string): string;
|
|
|
125
141
|
declare function toEnglishDigits(input: number | string): string;
|
|
126
142
|
|
|
127
143
|
declare function formatBanglaCalendarDay(day: number, options?: BanglaDayFormatOptions): string;
|
|
128
|
-
declare function
|
|
129
|
-
declare function format(input: DateInput, template: string, options?: TokenFormatOptions): string;
|
|
130
|
-
declare function formatBanglaCalendar(input: DateInput, options?: BanglaCalendarFormatOptions): string;
|
|
131
|
-
declare function formatHybridDate(input: DateInput, options?: HybridDateFormatOptions): string;
|
|
144
|
+
declare function format(input: DateInput, options: FormatOptions): string;
|
|
132
145
|
|
|
133
146
|
declare function parseDate(input: DateInput, options?: DateParseOptions): Date | null;
|
|
134
147
|
|
|
@@ -152,4 +165,4 @@ declare function startOfYear(input: DateInput): Date;
|
|
|
152
165
|
declare function endOfYear(input: DateInput): Date;
|
|
153
166
|
declare function getBanglaMonth(month: number, format?: MonthFormat): string;
|
|
154
167
|
|
|
155
|
-
export { BANGLA_CALENDAR_MONTHS, BANGLA_CALENDAR_MONTHS_EN, BANGLA_CALENDAR_MONTH_DAYS, BANGLA_DIGITS, BANGLA_MONTHS_FULL, BANGLA_MONTHS_SHORT, BANGLA_WEEKDAYS_FULL, BANGLA_WEEKDAYS_SHORT, BOISHAKH_START_DAY, BOISHAKH_START_MONTH, type BanglaCalendarDate, type BanglaCalendarDateLocalized, type BanglaCalendarDayFormat, type BanglaCalendarDaySpokenVariant, type BanglaCalendarFormatOptions, type BanglaCalendarOptions, type BanglaDayFormatOptions, type DateFormatOptions, type DateInput, type DateParseOptions, type DayFormat, ENGLISH_DIGITS, ENGLISH_MONTHS_FULL, ENGLISH_MONTHS_SHORT, ENGLISH_WEEKDAYS_FULL, ENGLISH_WEEKDAYS_SHORT, type HybridDateFormatOptions, type Language, type Locale, type MonthFormat, RELATIVE_TIME_BN, RELATIVE_TIME_EN, type RelativeTimeOptions, type TimeFormat, type
|
|
168
|
+
export { BANGLA_CALENDAR_MONTHS, BANGLA_CALENDAR_MONTHS_EN, BANGLA_CALENDAR_MONTH_DAYS, BANGLA_DIGITS, BANGLA_MONTHS_FULL, BANGLA_MONTHS_SHORT, BANGLA_WEEKDAYS_FULL, BANGLA_WEEKDAYS_SHORT, BOISHAKH_START_DAY, BOISHAKH_START_MONTH, type BanglaCalendarDate, type BanglaCalendarDateLocalized, type BanglaCalendarDayFormat, type BanglaCalendarDaySpokenVariant, type BanglaCalendarFormatOptions, type BanglaCalendarOptions, type BanglaDayFormatOptions, type DateFormatOptions, type DateInput, type DateParseOptions, type DayFormat, ENGLISH_DIGITS, ENGLISH_MONTHS_FULL, ENGLISH_MONTHS_SHORT, ENGLISH_WEEKDAYS_FULL, ENGLISH_WEEKDAYS_SHORT, type FormatMode, type FormatOptions, type HybridDateFormatOptions, type Language, type Locale, type MonthFormat, RELATIVE_TIME_BN, RELATIVE_TIME_EN, type RelativeTimeOptions, type TimeFormat, type WeekdayFormat, type YearFormat, addDays, addMonths, addYears, endOfDay, endOfMonth, endOfYear, format, formatBanglaCalendarDay, fromBanglaCalendar, fromNow, getBanglaMonth, isToday, isTomorrow, isYesterday, parseDate, startOfDay, startOfMonth, startOfYear, subDays, subMonths, subYears, toBanglaCalendar, toBanglaDigits, toDate, toEnglishDigits };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ type YearFormat = "numeric" | "2-digit";
|
|
|
5
5
|
type DayFormat = "numeric" | "2-digit";
|
|
6
6
|
type WeekdayFormat = "short" | "long";
|
|
7
7
|
type TimeFormat = "numeric" | "2-digit";
|
|
8
|
+
type FormatMode = "standard" | "bangla" | "hybrid";
|
|
8
9
|
type DateInput = Date | string | number;
|
|
9
10
|
interface DateFormatOptions {
|
|
10
11
|
locale?: Locale;
|
|
@@ -17,9 +18,24 @@ interface DateFormatOptions {
|
|
|
17
18
|
second?: TimeFormat;
|
|
18
19
|
hour12?: boolean;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
type PatternFormatOptions = {
|
|
22
|
+
pattern: string;
|
|
21
23
|
locale?: Locale;
|
|
22
|
-
|
|
24
|
+
mode?: never;
|
|
25
|
+
};
|
|
26
|
+
type StandardFormatOptions = DateFormatOptions & {
|
|
27
|
+
mode: "standard";
|
|
28
|
+
pattern?: never;
|
|
29
|
+
};
|
|
30
|
+
type BanglaFormatOptions = BanglaCalendarFormatOptions & {
|
|
31
|
+
mode: "bangla";
|
|
32
|
+
pattern?: never;
|
|
33
|
+
};
|
|
34
|
+
type HybridFormatOptions = HybridDateFormatOptions & {
|
|
35
|
+
mode: "hybrid";
|
|
36
|
+
pattern?: never;
|
|
37
|
+
};
|
|
38
|
+
type FormatOptions = PatternFormatOptions | StandardFormatOptions | BanglaFormatOptions | HybridFormatOptions;
|
|
23
39
|
interface HybridDateFormatOptions {
|
|
24
40
|
digits?: Language;
|
|
25
41
|
month?: Language;
|
|
@@ -125,10 +141,7 @@ declare function toBanglaDigits(input: number | string): string;
|
|
|
125
141
|
declare function toEnglishDigits(input: number | string): string;
|
|
126
142
|
|
|
127
143
|
declare function formatBanglaCalendarDay(day: number, options?: BanglaDayFormatOptions): string;
|
|
128
|
-
declare function
|
|
129
|
-
declare function format(input: DateInput, template: string, options?: TokenFormatOptions): string;
|
|
130
|
-
declare function formatBanglaCalendar(input: DateInput, options?: BanglaCalendarFormatOptions): string;
|
|
131
|
-
declare function formatHybridDate(input: DateInput, options?: HybridDateFormatOptions): string;
|
|
144
|
+
declare function format(input: DateInput, options: FormatOptions): string;
|
|
132
145
|
|
|
133
146
|
declare function parseDate(input: DateInput, options?: DateParseOptions): Date | null;
|
|
134
147
|
|
|
@@ -152,4 +165,4 @@ declare function startOfYear(input: DateInput): Date;
|
|
|
152
165
|
declare function endOfYear(input: DateInput): Date;
|
|
153
166
|
declare function getBanglaMonth(month: number, format?: MonthFormat): string;
|
|
154
167
|
|
|
155
|
-
export { BANGLA_CALENDAR_MONTHS, BANGLA_CALENDAR_MONTHS_EN, BANGLA_CALENDAR_MONTH_DAYS, BANGLA_DIGITS, BANGLA_MONTHS_FULL, BANGLA_MONTHS_SHORT, BANGLA_WEEKDAYS_FULL, BANGLA_WEEKDAYS_SHORT, BOISHAKH_START_DAY, BOISHAKH_START_MONTH, type BanglaCalendarDate, type BanglaCalendarDateLocalized, type BanglaCalendarDayFormat, type BanglaCalendarDaySpokenVariant, type BanglaCalendarFormatOptions, type BanglaCalendarOptions, type BanglaDayFormatOptions, type DateFormatOptions, type DateInput, type DateParseOptions, type DayFormat, ENGLISH_DIGITS, ENGLISH_MONTHS_FULL, ENGLISH_MONTHS_SHORT, ENGLISH_WEEKDAYS_FULL, ENGLISH_WEEKDAYS_SHORT, type HybridDateFormatOptions, type Language, type Locale, type MonthFormat, RELATIVE_TIME_BN, RELATIVE_TIME_EN, type RelativeTimeOptions, type TimeFormat, type
|
|
168
|
+
export { BANGLA_CALENDAR_MONTHS, BANGLA_CALENDAR_MONTHS_EN, BANGLA_CALENDAR_MONTH_DAYS, BANGLA_DIGITS, BANGLA_MONTHS_FULL, BANGLA_MONTHS_SHORT, BANGLA_WEEKDAYS_FULL, BANGLA_WEEKDAYS_SHORT, BOISHAKH_START_DAY, BOISHAKH_START_MONTH, type BanglaCalendarDate, type BanglaCalendarDateLocalized, type BanglaCalendarDayFormat, type BanglaCalendarDaySpokenVariant, type BanglaCalendarFormatOptions, type BanglaCalendarOptions, type BanglaDayFormatOptions, type DateFormatOptions, type DateInput, type DateParseOptions, type DayFormat, ENGLISH_DIGITS, ENGLISH_MONTHS_FULL, ENGLISH_MONTHS_SHORT, ENGLISH_WEEKDAYS_FULL, ENGLISH_WEEKDAYS_SHORT, type FormatMode, type FormatOptions, type HybridDateFormatOptions, type Language, type Locale, type MonthFormat, RELATIVE_TIME_BN, RELATIVE_TIME_EN, type RelativeTimeOptions, type TimeFormat, type WeekdayFormat, type YearFormat, addDays, addMonths, addYears, endOfDay, endOfMonth, endOfYear, format, formatBanglaCalendarDay, fromBanglaCalendar, fromNow, getBanglaMonth, isToday, isTomorrow, isYesterday, parseDate, startOfDay, startOfMonth, startOfYear, subDays, subMonths, subYears, toBanglaCalendar, toBanglaDigits, toDate, toEnglishDigits };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=["0","1","2","3","4","5","6","7","8","9"],e=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],u=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],s=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],i=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],l=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],c=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],g=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],h=[31,31,31,31,31,30,30,30,30,30,30,30],d=3,f=14,m={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},D={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function y(t){return String(t).replace(/\d/g,t=>e[Number(t)]??t)}function M(n){return String(n).replace(/[০-৯]/g,n=>{const r=e.indexOf(n);return r>=0?t[r]??n:n})}var b={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function w(t){const e=t.trim(),o=e.toLowerCase(),a=b[o];if(void 0!==a)return a;for(let t=0;t<n.length;t++)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t++)if(r[t].toLowerCase()===o)return t;for(let t=0;t<u.length;t++)if(u[t]===e)return t;for(let t=0;t<s.length;t++)if(s[t]===e)return t;return-1}function $(t,e,n,r=0,o=0,a=0,u=0){const s=new Date(t,e,n,r,o,a,u);return s.getFullYear()!==t||s.getMonth()!==e||s.getDate()!==n||s.getHours()!==r||s.getMinutes()!==o||s.getSeconds()!==a||s.getMilliseconds()!==u?null:s}function S(t){return function(t){const e=t.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return e?$(Number(e[1]),Number(e[3])-1,Number(e[4])):null}(t)??function(t){const e=t.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),a=Number(e[4]??0),u=Number(e[5]??0),s=Number(e[6]??0),i=Number((e[7]??"0").padEnd(3,"0").slice(0,3)),l=e[8];if(void 0===l)return $(n,r-1,o,a,u,s,i);const c=l.match(/^([+-])(\d{2}):?(\d{2})$/),g="Z"===l?0:c?("+"===c[1]?1:-1)*(60*Number(c[2])+Number(c[3])):null;if(null===g)return null;const h=Date.UTC(n,r-1,o,a,u,s,i)-6e4*g,d=new Date(h),f=new Date(h+6e4*g);return f.getUTCFullYear()!==n||f.getUTCMonth()!==r-1||f.getUTCDate()!==o||f.getUTCHours()!==a||f.getUTCMinutes()!==u||f.getUTCSeconds()!==s||f.getUTCMilliseconds()!==i?null:d}(t)??function(t){const e=t.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!e)return null;const n=Number(e[1]),r=e[2].replace(/,$/,""),o=e[3],a=w(r);if(-1===a)return null;let u=Number(o);return 2===o.length&&(u+=u>=50?1900:2e3),$(u,a,n)}(t)??function(t){const e=t.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!e)return null;const n=e[1].replace(/,$/,""),r=Number(e[2]),o=e[3],a=w(n);if(-1===a)return null;let u=Number(o);return 2===o.length&&(u+=u>=50?1900:2e3),$(u,a,r)}(t)}function p(t){if(t instanceof Date){const e=t.getTime();if(Number.isNaN(e))throw new Error(`Invalid date input: ${String(t)}`);return new Date(e)}if("number"==typeof t){if(!Number.isFinite(t))throw new Error(`Invalid date input: ${String(t)}`);const e=new Date(t);if(Number.isNaN(e.getTime()))throw new Error(`Invalid date input: ${String(t)}`);return e}const e=S(M(t).trim());if(!e)throw new Error(`Invalid date input: ${String(t)}`);return e}function N(t){const e=p(t),n=new Date;return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function Y(t){const e=p(t),n=new Date;return n.setDate(n.getDate()-1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function v(t){const e=p(t),n=new Date;return n.setDate(n.getDate()+1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function F(t){const e=p(t);return e.setHours(0,0,0,0),e}function j(t){const e=p(t);return e.setHours(23,59,59,999),e}function k(t,e){const n=p(t);return n.setDate(n.getDate()+e),n}function T(t,e){return k(t,-e)}function B(t,e){return new Date(t,e+1,0).getDate()}function H(t,e){const n=p(t),r=n.getFullYear(),o=n.getMonth()+e,a=r+Math.floor(o/12),u=(o%12+12)%12,s=Math.min(n.getDate(),B(a,u));return n.setFullYear(a,u,s),n}function C(t,e){return H(t,-e)}function I(t,e){const n=p(t),r=n.getFullYear()+e,o=Math.min(n.getDate(),B(r,n.getMonth()));return n.setFullYear(r,n.getMonth(),o),n}function A(t,e){return I(t,-e)}function U(t){const e=p(t);return e.setDate(1),e.setHours(0,0,0,0),e}function x(t){const e=p(t);return e.setMonth(e.getMonth()+1,0),e.setHours(23,59,59,999),e}function E(t){const e=p(t);return e.setMonth(0,1),e.setHours(0,0,0,0),e}function J(t){const e=p(t);return e.setMonth(11,31),e.setHours(23,59,59,999),e}function L(t,e="long"){const n=t-1;if(n<0||n>11)throw new Error(`Invalid month number: ${t}. Must be 1-12.`);return"short"===e?s[n]:u[n]}function O(t){const e=[...h];return function(t){return(e=t+594)%4==0&&e%100!=0||e%400==0;var e}(t)&&(e[10]=31),e}function P(t,e){const n=e?.locale??"en-BD",r=p(t),o=r.getFullYear(),a=r.getMonth(),u=r.getDate(),s=new Date(o,3,14),i=a<3||3===a&&u<14,l=i?o-594:o-593,h=function(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor((r-n)/864e5)}(i?new Date(o-1,3,14):s,r)+1,d=O(l);let f=h,m=0;for(let t=0;t<d.length;t++){const e=d[t];if(f<=e){m=t;break}f-=e}const D=m+1;return"bn-BD"===n?{day:y(f),month:c[m],monthIndex:D,year:y(l)}:{day:f,month:g[m],monthIndex:D,year:l}}function W(t,e,n){const r=function(t,e,n){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(n))throw new Error("Invalid Bangla calendar date.");if(e<1||e>12)throw new Error("Invalid Bangla calendar month index. Must be 1-12.");const r=O(n),o=r[e-1];if(t<1||t>o)throw new Error(`Invalid Bangla calendar day. Month ${e} of year ${n} has ${o} days.`);return r}(t,e,n),o=new Date(n+593,3,14);let a=t-1;for(let t=0;t<e-1;t++)a+=r[t];const u=new Date(o);return u.setDate(u.getDate()+a),u}function Z(t){const e=y(t);return 1===t?`${e}লা`:2===t||3===t?`${e}রা`:4===t?`${e}ঠা`:t>=19?`${e}শে`:`${e}ই`}function K(t,e){return"spoken"===(e?.format??"ordinal")?function(t,e="pohela"){switch(t){case 1:return"poyla"===e?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return Z(t)}}(t,e?.variant):Z(t)}function q(t,e){return"2-digit"===e?String(t).padStart(2,"0"):String(t)}function z(t,e,n){if("bn-BD"===e)return t<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=t<12?"AM":"PM";return n?r.toLowerCase():r}function G(t,e){const c=p(t),g=e?.locale??"en-BD",h=e?.month??"short",d=e?.year??"numeric",f=e?.day??"numeric",m=e?.weekday,D=e?.hour,M=e?.minute,b=e?.second,w=void 0!==D||void 0!==M||void 0!==b,$="bn-BD"===g,S=c.getDate(),N=c.getMonth(),Y=c.getFullYear(),v=`${"2-digit"===f?String(S).padStart(2,"0"):String(S)} ${($?"short"===h?s:u:"short"===h?r:n)[N]} ${"2-digit"===d?String(Y).slice(-2):String(Y)}`,F=void 0!==m?`${($?"short"===m?l:i:"short"===m?a:o)[c.getDay()]}, `:"";let j="";if(w){const t=e?.hour12??!1,n=c.getHours(),r=M??(void 0!==b?"2-digit":void 0);j=`${q(t?n%12||12:n,D??"numeric")}${void 0!==r?`:${q(c.getMinutes(),r)}`:""}${void 0!==b?`:${q(c.getSeconds(),b)}`:""}${t?` ${z(n,g,!1)}`:""}`}const k=`${F}${v}${j?`, ${j}`:""}`;return $?y(k):k}function Q(t,e,c){const g=p(t),h=c?.locale??"en-BD",d="bn-BD"===h,f=g.getDate(),m=g.getMonth(),D=g.getFullYear(),M=d?u:n,b=d?s:r,w=d?i:o,$=d?l:a,S=g.getHours(),N=S%12||12,Y={dddd:w[g.getDay()],ddd:$[g.getDay()],MMMM:M[m],MMM:b[m],MM:String(m+1).padStart(2,"0"),M:String(m+1),DD:String(f).padStart(2,"0"),D:String(f),HH:String(S).padStart(2,"0"),H:String(S),hh:String(N).padStart(2,"0"),h:String(N),mm:String(g.getMinutes()).padStart(2,"0"),m:String(g.getMinutes()),ss:String(g.getSeconds()).padStart(2,"0"),s:String(g.getSeconds()),A:z(S,h,!1),a:z(S,h,!0),YYYY:String(D),YY:String(D).slice(-2)},v=e.replace(/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,t=>Y[t]);return d?y(v):v}function R(t,e){const n=e?.locale??"en-BD",r=e?.format??"ordinal",o=e?.variant,a=P(t,{locale:"en-BD"});if("bn-BD"===n){const t=a.monthIndex-1,e={format:r};return void 0!==o&&(e.variant=o),`${K(a.day,e)} ${c[t]} ${y(a.year)}`}return`${a.day} ${a.month} ${a.year}`}function V(t,e){const o=p(t),a=e?.digits??"en",i=e?.month??"bn",l=e?.year??"en",c=e?.day??a,g=e?.monthFormat??"long",h=o.getDate(),d=o.getMonth(),f=o.getFullYear(),m="bn"===i?"short"===g?s:u:"short"===g?r:n;return`${"bn"===c?y(h):String(h)} ${m[d]} ${"bn"===l?y(f):String(f)}`}var X={baishakh:1,boishakh:1,boishak:1,boisakh:1,jaishtho:2,jaishtha:2,jaistha:2,joishtho:2,jyoishtho:2,jyoistho:2,jyeshtho:2,ashar:3,asadh:3,asharh:3,srabon:4,shraban:4,shrabon:4,sraban:4,bhadro:5,ashin:6,ashwin:6,ashshin:6,kartik:7,ograyon:8,ograyan:8,ogrohayon:8,ograhayon:8,agrahayan:8,aghrayan:8,pous:9,poush:9,mag:10,magh:10,falgoon:11,falgun:11,choitra:12,chaitra:12,choitro:12},_={"বৈশাখ":1,"জৈষ্ঠ":2,"জ্যৈষ্ঠ":2,"আষাঢ়":3,"আষাঢ়":3,"শ্রাবণ":4,"ভাদ্র":5,"আশ্বিন":6,"কার্তিক":7,"অগ্রহায়ণ":8,"অগ্রহায়ণ":8,"অঘ্রাণ":8,"অগ্রায়ণ":8,"অগ্রায়ণ":8,"পৌষ":9,"পৌস":9,"মাঘ":10,"ফাল্গুন":11,"চৈত্র":12};function tt(t,e){if(t instanceof Date)return Number.isNaN(t.getTime())?null:new Date(t.getTime());if("number"==typeof t){const e=new Date(t);return Number.isNaN(e.getTime())?null:e}const n=M(t).trim();return"bangla"===e?.calendar?function(t){const e=t.match(/^(\S+),?\s+(\S+),?\s+(\d{4})$/);if(!e)return null;const n=function(t){const e={"পহেলা":1,"পয়লা":1,"পয়লা":1,"দোসরা":2,"তেসরা":3,"চৌঠা":4}[t];if(void 0!==e)return e;const n=t.match(/^(\d{1,2})(?:লা|রা|ঠা|ই|শে)$/);if(n)return Number(n[1]);const r=Number(t);return Number.isInteger(r)&&r>=1&&r<=31?r:null}(e[1].replace(/,$/,""));if(null===n)return null;const r=function(t){const e=t.toLowerCase();for(let e=0;e<c.length;e++)if(c[e]===t)return e+1;const n=_[t];if(void 0!==n)return n;for(let t=0;t<g.length;t++)if(g[t].toLowerCase()===e)return t+1;const r=X[e];return void 0!==r?r:-1}(e[2].replace(/,$/,""));if(-1===r)return null;const o=Number(e[3]);try{return W(n,r,o)}catch{return null}}(n):S(n)}var et=1e3,nt=36e5,rt=24*nt,ot=[{threshold:7*rt,singular:"week",plural:"weeks"},{threshold:rt,singular:"day",plural:"days"},{threshold:nt,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:et,singular:"second",plural:"seconds"}];function at(t,e){return new Date(t,e+1,0).getDate()}function ut(t,e){let n=t.getFullYear()-e.getFullYear();const r=function(t,e){const n=t.getFullYear()+e,r=t.getMonth(),o=Math.min(t.getDate(),at(n,r));return new Date(n,r,o,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function st(t,e){let n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth());const r=function(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=n+Math.floor(r/12),a=(r%12+12)%12,u=Math.min(t.getDate(),at(o,a));return new Date(o,a,u,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function it(t,e,n,r,o){const a="bn-BD"===o,u=a?y(t):String(t),s=1===t?e:n;return a?r?`${u} ${s} আগে`:`${u} ${s} পরে`:r?`${u} ${s} ago`:`in ${u} ${s}`}function lt(t,e,n){return"bn-BD"===n?"day"===t?e?"গতকাল":"আগামীকাল":"week"===t?e?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===t?e?"গত মাসে":"আগামী মাসে":e?"গত বছর":"আগামী বছর":"day"===t?e?"yesterday":"tomorrow":"week"===t?e?"last week":"next week":"month"===t?e?"last month":"next month":e?"last year":"next year"}function ct(t,e){const n=p(t),r=e?.locale??"en-BD",o=e?.numeric??"always",a="bn-BD"===r?D:m,u=Date.now()-n.getTime(),s=Math.abs(u),i=u>0,l=new Date,c=n.getFullYear()===l.getFullYear()&&n.getMonth()===l.getMonth()&&n.getDate()===l.getDate(),g=i?l:n,h=i?n:l;if(s<et)return a.justNow;if("auto"===o&&c)return function(t){return"bn-BD"===t?"আজ":"today"}(r);const d=ut(g,h);if(d>=1){if("auto"===o&&1===d){const t=lt("year",i,r);if(null!==t)return t}return it(d,a.year,a.years,i,r)}const f=st(g,h);if(f>=1){if("auto"===o&&1===f){const t=lt("month",i,r);if(null!==t)return t}return it(f,a.month,a.months,i,r)}for(const t of ot)if(s>=t.threshold){const e=Math.floor(s/t.threshold);if("auto"===o&&1===e&&("day"===t.singular||"week"===t.singular)){const e=lt(t.singular,i,r);if(null!==e)return e}return it(e,a[t.singular],a[t.plural],i,r)}return a.justNow}export{c as BANGLA_CALENDAR_MONTHS,g as BANGLA_CALENDAR_MONTHS_EN,h as BANGLA_CALENDAR_MONTH_DAYS,e as BANGLA_DIGITS,u as BANGLA_MONTHS_FULL,s as BANGLA_MONTHS_SHORT,i as BANGLA_WEEKDAYS_FULL,l as BANGLA_WEEKDAYS_SHORT,f as BOISHAKH_START_DAY,d as BOISHAKH_START_MONTH,t as ENGLISH_DIGITS,n as ENGLISH_MONTHS_FULL,r as ENGLISH_MONTHS_SHORT,o as ENGLISH_WEEKDAYS_FULL,a as ENGLISH_WEEKDAYS_SHORT,D as RELATIVE_TIME_BN,m as RELATIVE_TIME_EN,k as addDays,H as addMonths,I as addYears,j as endOfDay,x as endOfMonth,J as endOfYear,Q as format,R as formatBanglaCalendar,K as formatBanglaCalendarDay,G as formatDate,V as formatHybridDate,W as fromBanglaCalendar,ct as fromNow,L as getBanglaMonth,N as isToday,v as isTomorrow,Y as isYesterday,tt as parseDate,F as startOfDay,U as startOfMonth,E as startOfYear,T as subDays,C as subMonths,A as subYears,P as toBanglaCalendar,y as toBanglaDigits,p as toDate,M as toEnglishDigits};
|
|
1
|
+
var t=["0","1","2","3","4","5","6","7","8","9"],e=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],u=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],i=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],s=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],l=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],c=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],d=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],g=[31,31,31,31,31,30,30,30,30,30,30,30],h=3,f=14,m={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},y={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function b(t){return String(t).replace(/\d/g,t=>e[Number(t)]??t)}function D(n){return String(n).replace(/[০-৯]/g,n=>{const r=e.indexOf(n);return r>=0?t[r]??n:n})}var M={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function w(t){const e=t.trim(),o=e.toLowerCase(),a=M[o];if(void 0!==a)return a;for(let t=0;t<n.length;t++)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t++)if(r[t].toLowerCase()===o)return t;for(let t=0;t<u.length;t++)if(u[t]===e)return t;for(let t=0;t<i.length;t++)if(i[t]===e)return t;return-1}function p(t,e,n,r=0,o=0,a=0,u=0){const i=new Date(t,e,n,r,o,a,u);return i.getFullYear()!==t||i.getMonth()!==e||i.getDate()!==n||i.getHours()!==r||i.getMinutes()!==o||i.getSeconds()!==a||i.getMilliseconds()!==u?null:i}function $(t){return function(t){const e=t.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return e?p(Number(e[1]),Number(e[3])-1,Number(e[4])):null}(t)??function(t){const e=t.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),a=Number(e[4]??0),u=Number(e[5]??0),i=Number(e[6]??0),s=Number((e[7]??"0").padEnd(3,"0").slice(0,3)),l=e[8];if(void 0===l)return p(n,r-1,o,a,u,i,s);const c=l.match(/^([+-])(\d{2}):?(\d{2})$/),d=c?Number(c[2]):null,g=c?Number(c[3]):null,h="Z"===l?0:c&&null!==d&&null!==g&&d<=23&&g<=59?("+"===c[1]?1:-1)*(60*d+g):null;if(null===h)return null;const f=Date.UTC(n,r-1,o,a,u,i,s)-6e4*h,m=new Date(f),y=new Date(f+6e4*h);return y.getUTCFullYear()!==n||y.getUTCMonth()!==r-1||y.getUTCDate()!==o||y.getUTCHours()!==a||y.getUTCMinutes()!==u||y.getUTCSeconds()!==i||y.getUTCMilliseconds()!==s?null:m}(t)??function(t){const e=t.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!e)return null;const n=Number(e[1]),r=e[2].replace(/,$/,""),o=e[3],a=w(r);if(-1===a)return null;let u=Number(o);return 2===o.length&&(u+=u>=50?1900:2e3),p(u,a,n)}(t)??function(t){const e=t.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!e)return null;const n=e[1].replace(/,$/,""),r=Number(e[2]),o=e[3],a=w(n);if(-1===a)return null;let u=Number(o);return 2===o.length&&(u+=u>=50?1900:2e3),p(u,a,r)}(t)}function v(t){if(t instanceof Date){const e=t.getTime();if(Number.isNaN(e))throw new Error(`Invalid date input: ${String(t)}`);return new Date(e)}if("number"==typeof t){if(!Number.isFinite(t))throw new Error(`Invalid date input: ${String(t)}`);const e=new Date(t);if(Number.isNaN(e.getTime()))throw new Error(`Invalid date input: ${String(t)}`);return e}const e=$(D(t).trim());if(!e)throw new Error(`Invalid date input: ${String(t)}`);return e}function N(t){const e=v(t),n=new Date;return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function Y(t){const e=v(t),n=new Date;return n.setDate(n.getDate()-1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function S(t){const e=v(t),n=new Date;return n.setDate(n.getDate()+1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function F(t){const e=v(t);return e.setHours(0,0,0,0),e}function k(t){const e=v(t);return e.setHours(23,59,59,999),e}function j(t,e){const n=v(t);return n.setDate(n.getDate()+e),n}function T(t,e){return j(t,-e)}function B(t,e){return new Date(t,e+1,0).getDate()}function H(t,e){const n=v(t),r=n.getFullYear(),o=n.getMonth()+e,a=r+Math.floor(o/12),u=(o%12+12)%12,i=Math.min(n.getDate(),B(a,u));return n.setFullYear(a,u,i),n}function C(t,e){return H(t,-e)}function I(t,e){const n=v(t),r=n.getFullYear()+e,o=Math.min(n.getDate(),B(r,n.getMonth()));return n.setFullYear(r,n.getMonth(),o),n}function E(t,e){return I(t,-e)}function x(t){const e=v(t);return e.setDate(1),e.setHours(0,0,0,0),e}function A(t){const e=v(t);return e.setMonth(e.getMonth()+1,0),e.setHours(23,59,59,999),e}function U(t){const e=v(t);return e.setMonth(0,1),e.setHours(0,0,0,0),e}function J(t){const e=v(t);return e.setMonth(11,31),e.setHours(23,59,59,999),e}function L(t,e="long"){const n=t-1;if(n<0||n>11)throw new Error(`Invalid month number: ${t}. Must be 1-12.`);return"short"===e?i[n]:u[n]}function O(t){const e=[...g];return function(t){return(e=t+594)%4==0&&e%100!=0||e%400==0;var e}(t)&&(e[10]=31),e}function P(t,e){const n=e?.locale??"en-BD",r=v(t),o=r.getFullYear(),a=r.getMonth(),u=r.getDate(),i=new Date(o,3,14),s=a<3||3===a&&u<14,l=s?o-594:o-593,g=function(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor((r-n)/864e5)}(s?new Date(o-1,3,14):i,r)+1,h=O(l);let f=g,m=0;for(let t=0;t<h.length;t++){const e=h[t];if(f<=e){m=t;break}f-=e}const y=m+1;return"bn-BD"===n?{day:b(f),month:c[m],monthIndex:y,year:b(l)}:{day:f,month:d[m],monthIndex:y,year:l}}function W(t,e,n){const r=function(t,e,n){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(n))throw new Error("Invalid Bangla calendar date.");if(e<1||e>12)throw new Error("Invalid Bangla calendar month index. Must be 1-12.");const r=O(n),o=r[e-1];if(t<1||t>o)throw new Error(`Invalid Bangla calendar day. Month ${e} of year ${n} has ${o} days.`);return r}(t,e,n),o=new Date(n+593,3,14);let a=t-1;for(let t=0;t<e-1;t++)a+=r[t];const u=new Date(o);return u.setDate(u.getDate()+a),u}function Z(t){const e=b(t);return 1===t?`${e}লা`:2===t||3===t?`${e}রা`:4===t?`${e}ঠা`:t>=19?`${e}শে`:`${e}ই`}function K(t,e){return"spoken"===(e?.format??"ordinal")?function(t,e="pohela"){switch(t){case 1:return"poyla"===e?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return Z(t)}}(t,e?.variant):Z(t)}function q(t,e){return"2-digit"===e?String(t).padStart(2,"0"):String(t)}function z(t,e,n){const r=q(t,n);return"bn-BD"===e?b(r):r}function G(t,e,n){if(!e.includes(t))throw new TypeError(`Invalid ${n}: ${t}`)}function Q(t,e,n){if("bn-BD"===e)return t<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=t<12?"AM":"PM";return n?r.toLowerCase():r}function R(t,e){if(null===e||"object"!=typeof e||Array.isArray(e))throw new TypeError("format() expects an options object");if("pattern"in e&&void 0!==e.pattern){if("mode"in e&&void 0!==e.mode)throw new TypeError("Do not pass `mode` when `pattern` is provided. `pattern` formatting does not use mode.");const c="locale"in e&&void 0!==e.locale?e.locale:"en-BD";return function(t,e,c="en-BD"){const d=v(t),g="bn-BD"===c,h=d.getDate(),f=d.getMonth(),m=d.getFullYear(),y=g?u:n,b=g?i:r,D=g?s:o,M=g?l:a,w=d.getHours(),p=w%12||12,$={dddd:D[d.getDay()],ddd:M[d.getDay()],MMMM:y[f],MMM:b[f],MM:z(f+1,c,"2-digit"),M:z(f+1,c,"numeric"),DD:z(h,c,"2-digit"),D:z(h,c,"numeric"),HH:z(w,c,"2-digit"),H:z(w,c,"numeric"),hh:z(p,c,"2-digit"),h:z(p,c,"numeric"),mm:z(d.getMinutes(),c,"2-digit"),m:z(d.getMinutes(),c,"numeric"),ss:z(d.getSeconds(),c,"2-digit"),s:z(d.getSeconds(),c,"numeric"),A:Q(w,c,!1),a:Q(w,c,!0),YYYY:z(m,c,"numeric"),YY:z(Number(String(m).slice(-2)),c,"2-digit")},N=/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,Y=t=>t.replace(N,t=>$[t]);let S="",F=0;for(;F<e.length;){const t=e.indexOf("[",F);if(-1===t){S+=Y(e.slice(F));break}S+=Y(e.slice(F,t));const n=e.indexOf("]",t+1);if(-1===n){S+=e.slice(t);break}S+=e.slice(t+1,n),F=n+1}return S}(t,e.pattern,c)}if(!("mode"in e)||void 0===e.mode)throw new TypeError("format() expects `mode` or `pattern`");const d=e.mode;switch(d){case"standard":return function(t,e){const c=v(t),d=e?.locale??"en-BD",g=e?.month??"short",h=e?.year??"numeric",f=e?.day??"numeric",m=e?.weekday,y=e?.hour,D=e?.minute,M=e?.second,w=void 0!==y||void 0!==D||void 0!==M,p="bn-BD"===d;G(g,["short","long"],"month format for standard mode"),G(h,["numeric","2-digit"],"year format for standard mode"),G(f,["numeric","2-digit"],"day format for standard mode"),void 0!==m&&G(m,["short","long"],"weekday format for standard mode"),void 0!==y&&G(y,["numeric","2-digit"],"hour format for standard mode"),void 0!==D&&G(D,["numeric","2-digit"],"minute format for standard mode"),void 0!==M&&G(M,["numeric","2-digit"],"second format for standard mode");const $=c.getDate(),N=c.getMonth(),Y=c.getFullYear(),S=`${"2-digit"===f?String($).padStart(2,"0"):String($)} ${(p?"short"===g?i:u:"short"===g?r:n)[N]} ${"2-digit"===h?String(Y).slice(-2):String(Y)}`,F=void 0!==m?`${(p?"short"===m?l:s:"short"===m?a:o)[c.getDay()]}, `:"";let k="";if(w){const t=e?.hour12??!1,n=c.getHours(),r=D??(void 0!==M?"2-digit":void 0);k=`${q(t?n%12||12:n,y??"numeric")}${void 0!==r?`:${q(c.getMinutes(),r)}`:""}${void 0!==M?`:${q(c.getSeconds(),M)}`:""}${t?` ${Q(n,d,!1)}`:""}`}const j=`${F}${S}${k?`, ${k}`:""}`;return p?b(j):j}(t,e);case"bangla":return function(t,e){const n=e?.locale??"en-BD",r=e?.format??"ordinal",o=e?.variant,a=P(t,{locale:"en-BD"});if("bn-BD"===n){const t=a.monthIndex-1,e={format:r};return void 0!==o&&(e.variant=o),`${K(a.day,e)} ${c[t]} ${b(a.year)}`}return`${a.day} ${a.month} ${a.year}`}(t,e);case"hybrid":return function(t,e){const o=v(t),a=e?.digits??"en",s=e?.month??"bn",l=e?.year??"en",c=e?.day??a,d=e?.monthFormat??"long";G(a,["en","bn"],"digits language for hybrid mode"),G(s,["en","bn"],"month language for hybrid mode"),G(l,["en","bn"],"year language for hybrid mode"),G(c,["en","bn"],"day language for hybrid mode"),G(d,["short","long"],"month format for hybrid mode");const g=o.getDate(),h=o.getMonth(),f=o.getFullYear(),m="bn"===s?"short"===d?i:u:"short"===d?r:n,y="bn"===c?b(g):String(g),D=m[h],M="bn"===l?b(f):String(f);return`${y} ${D} ${M}`}(t,e);default:throw new TypeError(`Invalid format mode: ${String(d)}`)}}var V={baishakh:1,boishakh:1,boishak:1,boisakh:1,jaishtho:2,jaishtha:2,jaistha:2,joishtho:2,jyoishtho:2,jyoistho:2,jyeshtho:2,ashar:3,asadh:3,asharh:3,srabon:4,shraban:4,shrabon:4,sraban:4,bhadro:5,ashin:6,ashwin:6,ashshin:6,kartik:7,ograyon:8,ograyan:8,ogrohayon:8,ograhayon:8,agrahayan:8,aghrayan:8,pous:9,poush:9,mag:10,magh:10,falgoon:11,falgun:11,choitra:12,chaitra:12,choitro:12},X={"বৈশাখ":1,"জৈষ্ঠ":2,"জ্যৈষ্ঠ":2,"আষাঢ়":3,"আষাঢ়":3,"শ্রাবণ":4,"ভাদ্র":5,"আশ্বিন":6,"কার্তিক":7,"অগ্রহায়ণ":8,"অগ্রহায়ণ":8,"অঘ্রাণ":8,"অগ্রায়ণ":8,"অগ্রায়ণ":8,"পৌষ":9,"পৌস":9,"মাঘ":10,"ফাল্গুন":11,"চৈত্র":12};function _(t,e){if(t instanceof Date)return Number.isNaN(t.getTime())?null:new Date(t.getTime());if("number"==typeof t){const e=new Date(t);return Number.isNaN(e.getTime())?null:e}const n=D(t).trim();return"bangla"===e?.calendar?function(t){const e=t.match(/^(\S+),?\s+(\S+),?\s+(\d{4})$/);if(!e)return null;const n=function(t){const e={"পহেলা":1,"পয়লা":1,"পয়লা":1,"দোসরা":2,"তেসরা":3,"চৌঠা":4}[t];if(void 0!==e)return e;const n=t.match(/^(\d{1,2})(?:লা|রা|ঠা|ই|শে)$/);if(n)return Number(n[1]);const r=Number(t);return Number.isInteger(r)&&r>=1&&r<=31?r:null}(e[1].replace(/,$/,""));if(null===n)return null;const r=function(t){const e=t.toLowerCase();for(let e=0;e<c.length;e++)if(c[e]===t)return e+1;const n=X[t];if(void 0!==n)return n;for(let t=0;t<d.length;t++)if(d[t].toLowerCase()===e)return t+1;const r=V[e];return void 0!==r?r:-1}(e[2].replace(/,$/,""));if(-1===r)return null;const o=Number(e[3]);try{return W(n,r,o)}catch{return null}}(n):$(n)}var tt=1e3,et=36e5,nt=24*et,rt=[{threshold:7*nt,singular:"week",plural:"weeks"},{threshold:nt,singular:"day",plural:"days"},{threshold:et,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:tt,singular:"second",plural:"seconds"}];function ot(t,e){return new Date(t,e+1,0).getDate()}function at(t,e){let n=t.getFullYear()-e.getFullYear();const r=function(t,e){const n=t.getFullYear()+e,r=t.getMonth(),o=Math.min(t.getDate(),ot(n,r));return new Date(n,r,o,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function ut(t,e){let n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth());const r=function(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=n+Math.floor(r/12),a=(r%12+12)%12,u=Math.min(t.getDate(),ot(o,a));return new Date(o,a,u,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function it(t,e,n,r,o){const a="bn-BD"===o,u=a?b(t):String(t),i=1===t?e:n;return a?r?`${u} ${i} আগে`:`${u} ${i} পরে`:r?`${u} ${i} ago`:`in ${u} ${i}`}function st(t,e,n){return"bn-BD"===n?"day"===t?e?"গতকাল":"আগামীকাল":"week"===t?e?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===t?e?"গত মাসে":"আগামী মাসে":e?"গত বছর":"আগামী বছর":"day"===t?e?"yesterday":"tomorrow":"week"===t?e?"last week":"next week":"month"===t?e?"last month":"next month":e?"last year":"next year"}function lt(t,e){const n=v(t),r=e?.locale??"en-BD",o=e?.numeric??"always",a="bn-BD"===r?y:m,u=Date.now()-n.getTime(),i=Math.abs(u),s=u>0,l=new Date,c=n.getFullYear()===l.getFullYear()&&n.getMonth()===l.getMonth()&&n.getDate()===l.getDate(),d=s?l:n,g=s?n:l;if(i<tt)return a.justNow;if("auto"===o&&c)return function(t){return"bn-BD"===t?"আজ":"today"}(r);const h=at(d,g);if(h>=1){if("auto"===o&&1===h){const t=st("year",s,r);if(null!==t)return t}return it(h,a.year,a.years,s,r)}const f=ut(d,g);if(f>=1){if("auto"===o&&1===f){const t=st("month",s,r);if(null!==t)return t}return it(f,a.month,a.months,s,r)}for(const t of rt)if(i>=t.threshold){const e=Math.floor(i/t.threshold);if("auto"===o&&1===e&&("day"===t.singular||"week"===t.singular)){const e=st(t.singular,s,r);if(null!==e)return e}return it(e,a[t.singular],a[t.plural],s,r)}return a.justNow}export{c as BANGLA_CALENDAR_MONTHS,d as BANGLA_CALENDAR_MONTHS_EN,g as BANGLA_CALENDAR_MONTH_DAYS,e as BANGLA_DIGITS,u as BANGLA_MONTHS_FULL,i as BANGLA_MONTHS_SHORT,s as BANGLA_WEEKDAYS_FULL,l as BANGLA_WEEKDAYS_SHORT,f as BOISHAKH_START_DAY,h as BOISHAKH_START_MONTH,t as ENGLISH_DIGITS,n as ENGLISH_MONTHS_FULL,r as ENGLISH_MONTHS_SHORT,o as ENGLISH_WEEKDAYS_FULL,a as ENGLISH_WEEKDAYS_SHORT,y as RELATIVE_TIME_BN,m as RELATIVE_TIME_EN,j as addDays,H as addMonths,I as addYears,k as endOfDay,A as endOfMonth,J as endOfYear,R as format,K as formatBanglaCalendarDay,W as fromBanglaCalendar,lt as fromNow,L as getBanglaMonth,N as isToday,S as isTomorrow,Y as isYesterday,_ as parseDate,F as startOfDay,x as startOfMonth,U as startOfYear,T as subDays,C as subMonths,E as subYears,P as toBanglaCalendar,b as toBanglaDigits,v as toDate,D as toEnglishDigits};
|
package/dist/react.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("react"),t=["0","1","2","3","4","5","6","7","8","9"],n=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],r=["January","February","March","April","May","June","July","August","September","October","November","December"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],u=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],l=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],s=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],c=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],d=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],g=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],h=[31,31,31,31,31,30,30,30,30,30,30,30],m={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},f={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function y(e){return String(e).replace(/\d/g,e=>n[Number(e)]??e)}function b(e){return String(e).replace(/[০-৯]/g,e=>{const r=n.indexOf(e);return r>=0?t[r]??e:e})}var v={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function w(e){const t=e.trim(),n=t.toLowerCase(),o=v[n];if(void 0!==o)return o;for(let e=0;e<r.length;e++)if(r[e].toLowerCase()===n)return e;for(let e=0;e<a.length;e++)if(a[e].toLowerCase()===n)return e;for(let e=0;e<i.length;e++)if(i[e]===t)return e;for(let e=0;e<l.length;e++)if(l[e]===t)return e;return-1}function $(e,t,n,r=0,a=0,o=0,u=0){const i=new Date(e,t,n,r,a,o,u);return i.getFullYear()!==e||i.getMonth()!==t||i.getDate()!==n||i.getHours()!==r||i.getMinutes()!==a||i.getSeconds()!==o||i.getMilliseconds()!==u?null:i}function D(e){return function(e){const t=e.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return t?$(Number(t[1]),Number(t[3])-1,Number(t[4])):null}(e)??function(e){const t=e.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!t)return null;const n=Number(t[1]),r=Number(t[2]),a=Number(t[3]),o=Number(t[4]??0),u=Number(t[5]??0),i=Number(t[6]??0),l=Number((t[7]??"0").padEnd(3,"0").slice(0,3)),s=t[8];if(void 0===s)return $(n,r-1,a,o,u,i,l);const c=s.match(/^([+-])(\d{2}):?(\d{2})$/),d="Z"===s?0:c?("+"===c[1]?1:-1)*(60*Number(c[2])+Number(c[3])):null;if(null===d)return null;const g=Date.UTC(n,r-1,a,o,u,i,l)-6e4*d,h=new Date(g),m=new Date(g+6e4*d);return m.getUTCFullYear()!==n||m.getUTCMonth()!==r-1||m.getUTCDate()!==a||m.getUTCHours()!==o||m.getUTCMinutes()!==u||m.getUTCSeconds()!==i||m.getUTCMilliseconds()!==l?null:h}(e)??function(e){const t=e.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!t)return null;const n=Number(t[1]),r=t[2].replace(/,$/,""),a=t[3],o=w(r);if(-1===o)return null;let u=Number(a);return 2===a.length&&(u+=u>=50?1900:2e3),$(u,o,n)}(e)??function(e){const t=e.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!t)return null;const n=t[1].replace(/,$/,""),r=Number(t[2]),a=t[3],o=w(n);if(-1===o)return null;let u=Number(a);return 2===a.length&&(u+=u>=50?1900:2e3),$(u,o,r)}(e)}function p(e){if(e instanceof Date){const t=e.getTime();if(Number.isNaN(t))throw new Error(`Invalid date input: ${String(e)}`);return new Date(t)}if("number"==typeof e){if(!Number.isFinite(e))throw new Error(`Invalid date input: ${String(e)}`);const t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid date input: ${String(e)}`);return t}const t=D(b(e).trim());if(!t)throw new Error(`Invalid date input: ${String(e)}`);return t}function N(e,t){const n=p(e),r=n.getFullYear(),a=n.getMonth(),o=n.getDate(),u=new Date(r,3,14),i=a<3||3===a&&o<14,l=i?r-594:r-593,s=function(e,t){const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)}(i?new Date(r-1,3,14):u,n)+1,c=function(e){const t=[...h];return function(e){return(t=e+594)%4==0&&t%100!=0||t%400==0;var t}(e)&&(t[10]=31),t}(l);let d=s,m=0;for(let e=0;e<c.length;e++){const t=c[e];if(d<=t){m=e;break}d-=t}return{day:d,month:g[m],monthIndex:m+1,year:l}}function M(e){const t=y(e);return 1===e?`${t}লা`:2===e||3===e?`${t}রা`:4===e?`${t}ঠা`:e>=19?`${t}শে`:`${t}ই`}function S(e,t){return"spoken"===(t?.format??"ordinal")?function(e,t="pohela"){switch(e){case 1:return"poyla"===t?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return M(e)}}(e,t?.variant):M(e)}function T(e,t){return"2-digit"===t?String(e).padStart(2,"0"):String(e)}var k=1e3,F=36e5,j=24*F,C=[{threshold:7*j,singular:"week",plural:"weeks"},{threshold:j,singular:"day",plural:"days"},{threshold:F,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:k,singular:"second",plural:"seconds"}];function Y(e,t){return new Date(e,t+1,0).getDate()}function B(e,t){let n=e.getFullYear()-t.getFullYear();const r=function(e,t){const n=e.getFullYear()+t,r=e.getMonth(),a=Math.min(e.getDate(),Y(n,r));return new Date(n,r,a,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function U(e,t){let n=12*(e.getFullYear()-t.getFullYear())+(e.getMonth()-t.getMonth());const r=function(e,t){const n=e.getFullYear(),r=e.getMonth()+t,a=n+Math.floor(r/12),o=(r%12+12)%12,u=Math.min(e.getDate(),Y(a,o));return new Date(a,o,u,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function x(e,t,n,r,a){const o="bn-BD"===a,u=o?y(e):String(e),i=1===e?t:n;return o?r?`${u} ${i} আগে`:`${u} ${i} পরে`:r?`${u} ${i} ago`:`in ${u} ${i}`}function A(e,t,n){return"bn-BD"===n?"day"===e?t?"গতকাল":"আগামীকাল":"week"===e?t?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===e?t?"গত মাসে":"আগামী মাসে":t?"গত বছর":"আগামী বছর":"day"===e?t?"yesterday":"tomorrow":"week"===e?t?"last week":"next week":"month"===e?t?"last month":"next month":t?"last year":"next year"}function E(e){return"string"==typeof e&&!/(?:T|\s)\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:?\d{2})?$/i.test(e.trim())&&null!==function(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:new Date(e.getTime());if("number"==typeof e){const t=new Date(e);return Number.isNaN(t.getTime())?null:t}return D(b(e).trim())}(e)}function I(e,t){return E(e)?function(e){return`${String(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}(t):t.toISOString()}var J=e.forwardRef(function({value:t,locale:n,month:d,year:g,day:h,weekday:m,hour:f,minute:b,second:v,hour12:w,srLabel:$,"aria-label":D,...N},M){const S=p(t),k=function(e,t){const n=p(e),d=t?.locale??"en-BD",g=t?.month??"short",h=t?.year??"numeric",m=t?.day??"numeric",f=t?.weekday,b=t?.hour,v=t?.minute,w=t?.second,$=void 0!==b||void 0!==v||void 0!==w,D="bn-BD"===d,N=n.getDate(),M=n.getMonth(),S=n.getFullYear(),k=`${"2-digit"===m?String(N).padStart(2,"0"):String(N)} ${(D?"short"===g?l:i:"short"===g?a:r)[M]} ${"2-digit"===h?String(S).slice(-2):String(S)}`,F=void 0!==f?`${(D?"short"===f?c:s:"short"===f?u:o)[n.getDay()]}, `:"";let j="";if($){const e=t?.hour12??!1,r=n.getHours(),a=v??(void 0!==w?"2-digit":void 0),o=T(e?r%12||12:r,b??"numeric"),u=void 0!==a?`:${T(n.getMinutes(),a)}`:"",i=void 0!==w?`:${T(n.getSeconds(),w)}`:"",l=e?` ${function(e,t){if("bn-BD"===t)return e<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const n=e<12?"AM":"PM";return!1?n.toLowerCase():n}(r,d)}`:"";j=`${o}${u}${i}${l}`}const C=`${F}${k}${j?`, ${j}`:""}`;return D?y(C):C}(S,{...void 0!==n&&{locale:n},...void 0!==d&&{month:d},...void 0!==g&&{year:g},...void 0!==h&&{day:h},...void 0!==m&&{weekday:m},...void 0!==f&&{hour:f},...void 0!==b&&{minute:b},...void 0!==v&&{second:v},...void 0!==w&&{hour12:w}}),F=I(t,S),j=$??D??k;return e.createElement("time",{...N,ref:M,dateTime:F,"aria-label":j},k)});J.displayName="Tarikh";var L=e.forwardRef(function({value:t,locale:n,numeric:r,srLabel:a,"aria-label":o,...u},i){const l=p(t),s={...void 0!==n&&{locale:n},...void 0!==r&&{numeric:r}},c=function(e,t){const n=p(e),r=t?.locale??"en-BD",a=t?.numeric??"always",o="bn-BD"===r?f:m,u=Date.now()-n.getTime(),i=Math.abs(u),l=u>0,s=new Date,c=n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()&&n.getDate()===s.getDate(),d=l?s:n,g=l?n:s;if(i<k)return o.justNow;if("auto"===a&&c)return function(e){return"bn-BD"===e?"আজ":"today"}(r);const h=B(d,g);if(h>=1){if("auto"===a&&1===h){const e=A("year",l,r);if(null!==e)return e}return x(h,o.year,o.years,l,r)}const y=U(d,g);if(y>=1){if("auto"===a&&1===y){const e=A("month",l,r);if(null!==e)return e}return x(y,o.month,o.months,l,r)}for(const e of C)if(i>=e.threshold){const t=Math.floor(i/e.threshold);if("auto"===a&&1===t&&("day"===e.singular||"week"===e.singular)){const t=A(e.singular,l,r);if(null!==t)return t}return x(t,o[e.singular],o[e.plural],l,r)}return o.justNow}(l,Object.keys(s).length>0?s:void 0),d=I(t,l),g=a??o??c;return e.createElement("time",{...u,ref:i,dateTime:d,"aria-label":g},c)});L.displayName="RelativeTime";var O=e.forwardRef(function({value:t,locale:n,format:r,variant:a,srLabel:o,"aria-label":u,...i},l){const s=p(t),c={...void 0!==n&&{locale:n},...void 0!==r&&{format:r},...void 0!==a&&{variant:a}},g=function(e,t){const n=t?.locale??"en-BD",r=t?.format??"ordinal",a=t?.variant,o=N(e);if("bn-BD"===n){const e=o.monthIndex-1,t={format:r};return void 0!==a&&(t.variant=a),`${S(o.day,t)} ${d[e]} ${y(o.year)}`}return`${o.day} ${o.month} ${o.year}`}(s,Object.keys(c).length>0?c:void 0),h=I(t,s),m=o??u??g;return e.createElement("time",{...i,ref:l,dateTime:h,"aria-label":m},g)});O.displayName="BanglaDate",exports.BanglaDate=O,exports.RelativeTime=L,exports.Tarikh=J;
|
|
2
|
+
"use strict";var e=require("react"),t=["0","1","2","3","4","5","6","7","8","9"],n=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],r=["January","February","March","April","May","June","July","August","September","October","November","December"],o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],a=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],u=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],d=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],s=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],l=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],c=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],m=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],g=[31,31,31,31,31,30,30,30,30,30,30,30],f={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},h={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function y(e){return String(e).replace(/\d/g,e=>n[Number(e)]??e)}function b(e){return String(e).replace(/[০-৯]/g,e=>{const r=n.indexOf(e);return r>=0?t[r]??e:e})}var w={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function v(e){const t=e.trim(),n=t.toLowerCase(),a=w[n];if(void 0!==a)return a;for(let e=0;e<r.length;e++)if(r[e].toLowerCase()===n)return e;for(let e=0;e<o.length;e++)if(o[e].toLowerCase()===n)return e;for(let e=0;e<u.length;e++)if(u[e]===t)return e;for(let e=0;e<d.length;e++)if(d[e]===t)return e;return-1}function p(e,t,n,r=0,o=0,a=0,i=0){const u=new Date(e,t,n,r,o,a,i);return u.getFullYear()!==e||u.getMonth()!==t||u.getDate()!==n||u.getHours()!==r||u.getMinutes()!==o||u.getSeconds()!==a||u.getMilliseconds()!==i?null:u}function M(e){return function(e){const t=e.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return t?p(Number(t[1]),Number(t[3])-1,Number(t[4])):null}(e)??function(e){const t=e.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!t)return null;const n=Number(t[1]),r=Number(t[2]),o=Number(t[3]),a=Number(t[4]??0),i=Number(t[5]??0),u=Number(t[6]??0),d=Number((t[7]??"0").padEnd(3,"0").slice(0,3)),s=t[8];if(void 0===s)return p(n,r-1,o,a,i,u,d);const l=s.match(/^([+-])(\d{2}):?(\d{2})$/),c=l?Number(l[2]):null,m=l?Number(l[3]):null,g="Z"===s?0:l&&null!==c&&null!==m&&c<=23&&m<=59?("+"===l[1]?1:-1)*(60*c+m):null;if(null===g)return null;const f=Date.UTC(n,r-1,o,a,i,u,d)-6e4*g,h=new Date(f),y=new Date(f+6e4*g);return y.getUTCFullYear()!==n||y.getUTCMonth()!==r-1||y.getUTCDate()!==o||y.getUTCHours()!==a||y.getUTCMinutes()!==i||y.getUTCSeconds()!==u||y.getUTCMilliseconds()!==d?null:h}(e)??function(e){const t=e.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!t)return null;const n=Number(t[1]),r=t[2].replace(/,$/,""),o=t[3],a=v(r);if(-1===a)return null;let i=Number(o);return 2===o.length&&(i+=i>=50?1900:2e3),p(i,a,n)}(e)??function(e){const t=e.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!t)return null;const n=t[1].replace(/,$/,""),r=Number(t[2]),o=t[3],a=v(n);if(-1===a)return null;let i=Number(o);return 2===o.length&&(i+=i>=50?1900:2e3),p(i,a,r)}(e)}function D(e){if(e instanceof Date){const t=e.getTime();if(Number.isNaN(t))throw new Error(`Invalid date input: ${String(e)}`);return new Date(t)}if("number"==typeof e){if(!Number.isFinite(e))throw new Error(`Invalid date input: ${String(e)}`);const t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid date input: ${String(e)}`);return t}const t=M(b(e).trim());if(!t)throw new Error(`Invalid date input: ${String(e)}`);return t}function $(e,t){const n=D(e),r=n.getFullYear(),o=n.getMonth(),a=n.getDate(),i=new Date(r,3,14),u=o<3||3===o&&a<14,d=u?r-594:r-593,s=function(e,t){const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)}(u?new Date(r-1,3,14):i,n)+1,l=function(e){const t=[...g];return function(e){return(t=e+594)%4==0&&t%100!=0||t%400==0;var t}(e)&&(t[10]=31),t}(d);let c=s,f=0;for(let e=0;e<l.length;e++){const t=l[e];if(c<=t){f=e;break}c-=t}return{day:c,month:m[f],monthIndex:f+1,year:d}}function S(e){const t=y(e);return 1===e?`${t}লা`:2===e||3===e?`${t}রা`:4===e?`${t}ঠা`:e>=19?`${t}শে`:`${t}ই`}function N(e,t){return"spoken"===(t?.format??"ordinal")?function(e,t="pohela"){switch(e){case 1:return"poyla"===t?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return S(e)}}(e,t?.variant):S(e)}function T(e,t){return"2-digit"===t?String(e).padStart(2,"0"):String(e)}function Y(e,t,n){const r=T(e,n);return"bn-BD"===t?y(r):r}function k(e,t,n){if(!t.includes(e))throw new TypeError(`Invalid ${n}: ${e}`)}function F(e,t,n){if("bn-BD"===t)return e<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=e<12?"AM":"PM";return n?r.toLowerCase():r}function j(e,t){if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError("format() expects an options object");if("pattern"in t&&void 0!==t.pattern){if("mode"in t&&void 0!==t.mode)throw new TypeError("Do not pass `mode` when `pattern` is provided. `pattern` formatting does not use mode.");const n="locale"in t&&void 0!==t.locale?t.locale:"en-BD";return function(e,t,n="en-BD"){const c=D(e),m="bn-BD"===n,g=c.getDate(),f=c.getMonth(),h=c.getFullYear(),y=m?u:r,b=m?d:o,w=m?s:a,v=m?l:i,p=c.getHours(),M=p%12||12,$={dddd:w[c.getDay()],ddd:v[c.getDay()],MMMM:y[f],MMM:b[f],MM:Y(f+1,n,"2-digit"),M:Y(f+1,n,"numeric"),DD:Y(g,n,"2-digit"),D:Y(g,n,"numeric"),HH:Y(p,n,"2-digit"),H:Y(p,n,"numeric"),hh:Y(M,n,"2-digit"),h:Y(M,n,"numeric"),mm:Y(c.getMinutes(),n,"2-digit"),m:Y(c.getMinutes(),n,"numeric"),ss:Y(c.getSeconds(),n,"2-digit"),s:Y(c.getSeconds(),n,"numeric"),A:F(p,n,!1),a:F(p,n,!0),YYYY:Y(h,n,"numeric"),YY:Y(Number(String(h).slice(-2)),n,"2-digit")},S=/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,N=e=>e.replace(S,e=>$[e]);let T="",k=0;for(;k<t.length;){const e=t.indexOf("[",k);if(-1===e){T+=N(t.slice(k));break}T+=N(t.slice(k,e));const n=t.indexOf("]",e+1);if(-1===n){T+=t.slice(e);break}T+=t.slice(e+1,n),k=n+1}return T}(e,t.pattern,n)}if(!("mode"in t)||void 0===t.mode)throw new TypeError("format() expects `mode` or `pattern`");const n=t.mode;switch(n){case"standard":return function(e,t){const n=D(e),c=t?.locale??"en-BD",m=t?.month??"short",g=t?.year??"numeric",f=t?.day??"numeric",h=t?.weekday,b=t?.hour,w=t?.minute,v=t?.second,p=void 0!==b||void 0!==w||void 0!==v,M="bn-BD"===c;k(m,["short","long"],"month format for standard mode"),k(g,["numeric","2-digit"],"year format for standard mode"),k(f,["numeric","2-digit"],"day format for standard mode"),void 0!==h&&k(h,["short","long"],"weekday format for standard mode"),void 0!==b&&k(b,["numeric","2-digit"],"hour format for standard mode"),void 0!==w&&k(w,["numeric","2-digit"],"minute format for standard mode"),void 0!==v&&k(v,["numeric","2-digit"],"second format for standard mode");const $=n.getDate(),S=n.getMonth(),N=n.getFullYear(),Y=`${"2-digit"===f?String($).padStart(2,"0"):String($)} ${(M?"short"===m?d:u:"short"===m?o:r)[S]} ${"2-digit"===g?String(N).slice(-2):String(N)}`,j=void 0!==h?`${(M?"short"===h?l:s:"short"===h?i:a)[n.getDay()]}, `:"";let B="";if(p){const e=t?.hour12??!1,r=n.getHours(),o=w??(void 0!==v?"2-digit":void 0);B=`${T(e?r%12||12:r,b??"numeric")}${void 0!==o?`:${T(n.getMinutes(),o)}`:""}${void 0!==v?`:${T(n.getSeconds(),v)}`:""}${e?` ${F(r,c,!1)}`:""}`}const C=`${j}${Y}${B?`, ${B}`:""}`;return M?y(C):C}(e,t);case"bangla":return function(e,t){const n=t?.locale??"en-BD",r=t?.format??"ordinal",o=t?.variant,a=$(e);if("bn-BD"===n){const e=a.monthIndex-1,t={format:r};return void 0!==o&&(t.variant=o),`${N(a.day,t)} ${c[e]} ${y(a.year)}`}return`${a.day} ${a.month} ${a.year}`}(e,t);case"hybrid":return function(e,t){const n=D(e),a=t?.digits??"en",i=t?.month??"bn",s=t?.year??"en",l=t?.day??a,c=t?.monthFormat??"long";k(a,["en","bn"],"digits language for hybrid mode"),k(i,["en","bn"],"month language for hybrid mode"),k(s,["en","bn"],"year language for hybrid mode"),k(l,["en","bn"],"day language for hybrid mode"),k(c,["short","long"],"month format for hybrid mode");const m=n.getDate(),g=n.getMonth(),f=n.getFullYear(),h="bn"===i?"short"===c?d:u:"short"===c?o:r,b="bn"===l?y(m):String(m),w=h[g],v="bn"===s?y(f):String(f);return`${b} ${w} ${v}`}(e,t);default:throw new TypeError(`Invalid format mode: ${String(n)}`)}}var B=1e3,C=36e5,E=24*C,A=[{threshold:7*E,singular:"week",plural:"weeks"},{threshold:E,singular:"day",plural:"days"},{threshold:C,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:B,singular:"second",plural:"seconds"}];function H(e,t){return new Date(e,t+1,0).getDate()}function x(e,t){let n=e.getFullYear()-t.getFullYear();const r=function(e,t){const n=e.getFullYear()+t,r=e.getMonth(),o=Math.min(e.getDate(),H(n,r));return new Date(n,r,o,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function U(e,t){let n=12*(e.getFullYear()-t.getFullYear())+(e.getMonth()-t.getMonth());const r=function(e,t){const n=e.getFullYear(),r=e.getMonth()+t,o=n+Math.floor(r/12),a=(r%12+12)%12,i=Math.min(e.getDate(),H(o,a));return new Date(o,a,i,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function I(e,t,n,r,o){const a="bn-BD"===o,i=a?y(e):String(e),u=1===e?t:n;return a?r?`${i} ${u} আগে`:`${i} ${u} পরে`:r?`${i} ${u} ago`:`in ${i} ${u}`}function J(e,t,n){return"bn-BD"===n?"day"===e?t?"গতকাল":"আগামীকাল":"week"===e?t?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===e?t?"গত মাসে":"আগামী মাসে":t?"গত বছর":"আগামী বছর":"day"===e?t?"yesterday":"tomorrow":"week"===e?t?"last week":"next week":"month"===e?t?"last month":"next month":t?"last year":"next year"}function L(e){return"string"==typeof e&&!/(?:T|\s)\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i.test(e.trim())&&null!==function(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:new Date(e.getTime());if("number"==typeof e){const t=new Date(e);return Number.isNaN(t.getTime())?null:t}return M(b(e).trim())}(e)}function O(e,t){return L(e)?function(e){return`${String(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}(t):t.toISOString()}var R=e.forwardRef(function({value:t,locale:n,month:r,year:o,day:a,weekday:i,hour:u,minute:d,second:s,hour12:l,srLabel:c,"aria-label":m,...g},f){const h=D(t),y=j(h,{mode:"standard",...{...void 0!==n&&{locale:n},...void 0!==r&&{month:r},...void 0!==o&&{year:o},...void 0!==a&&{day:a},...void 0!==i&&{weekday:i},...void 0!==u&&{hour:u},...void 0!==d&&{minute:d},...void 0!==s&&{second:s},...void 0!==l&&{hour12:l}}}),b=O(t,h),w=c??m??y;return e.createElement("time",{...g,ref:f,dateTime:b,"aria-label":w},y)});R.displayName="Tarikh";var Z=e.forwardRef(function({value:t,locale:n,numeric:r,srLabel:o,"aria-label":a,...i},u){const d=D(t),s={...void 0!==n&&{locale:n},...void 0!==r&&{numeric:r}},l=function(e,t){const n=D(e),r=t?.locale??"en-BD",o=t?.numeric??"always",a="bn-BD"===r?h:f,i=Date.now()-n.getTime(),u=Math.abs(i),d=i>0,s=new Date,l=n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()&&n.getDate()===s.getDate(),c=d?s:n,m=d?n:s;if(u<B)return a.justNow;if("auto"===o&&l)return function(e){return"bn-BD"===e?"আজ":"today"}(r);const g=x(c,m);if(g>=1){if("auto"===o&&1===g){const e=J("year",d,r);if(null!==e)return e}return I(g,a.year,a.years,d,r)}const y=U(c,m);if(y>=1){if("auto"===o&&1===y){const e=J("month",d,r);if(null!==e)return e}return I(y,a.month,a.months,d,r)}for(const e of A)if(u>=e.threshold){const t=Math.floor(u/e.threshold);if("auto"===o&&1===t&&("day"===e.singular||"week"===e.singular)){const t=J(e.singular,d,r);if(null!==t)return t}return I(t,a[e.singular],a[e.plural],d,r)}return a.justNow}(d,Object.keys(s).length>0?s:void 0),c=O(t,d),m=o??a??l;return e.createElement("time",{...i,ref:u,dateTime:c,"aria-label":m},l)});Z.displayName="RelativeTime";var P=e.forwardRef(function({value:t,locale:n,format:r,variant:o,srLabel:a,"aria-label":i,...u},d){const s=D(t),l=j(s,{mode:"bangla",...{...void 0!==n&&{locale:n},...void 0!==r&&{format:r},...void 0!==o&&{variant:o}}}),c=O(t,s),m=a??i??l;return e.createElement("time",{...u,ref:d,dateTime:c,"aria-label":m},l)});P.displayName="BanglaDate",R.Relative=Z,R.Bangla=P,exports.Tarikh=R;
|
package/dist/react.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ComponentPropsWithoutRef } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
3
2
|
|
|
4
3
|
type Locale = "en-BD" | "bn-BD";
|
|
5
4
|
type MonthFormat = "short" | "long";
|
|
@@ -45,8 +44,12 @@ interface BanglaDateProps extends Omit<ComponentPropsWithoutRef<"time">, "childr
|
|
|
45
44
|
srLabel?: string;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
type TarikhCompoundComponent = ForwardRefExoticComponent<TarikhProps & RefAttributes<HTMLTimeElement>> & {
|
|
48
|
+
Relative: typeof RelativeTimeComponent;
|
|
49
|
+
Bangla: typeof BanglaDateComponent;
|
|
50
|
+
};
|
|
51
|
+
declare const Tarikh: TarikhCompoundComponent;
|
|
52
|
+
declare const RelativeTimeComponent: ForwardRefExoticComponent<RelativeTimeProps & RefAttributes<HTMLTimeElement>>;
|
|
53
|
+
declare const BanglaDateComponent: ForwardRefExoticComponent<BanglaDateProps & RefAttributes<HTMLTimeElement>>;
|
|
51
54
|
|
|
52
|
-
export {
|
|
55
|
+
export { type BanglaDateProps, type RelativeTimeProps, Tarikh, type TarikhProps };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ComponentPropsWithoutRef } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
3
2
|
|
|
4
3
|
type Locale = "en-BD" | "bn-BD";
|
|
5
4
|
type MonthFormat = "short" | "long";
|
|
@@ -45,8 +44,12 @@ interface BanglaDateProps extends Omit<ComponentPropsWithoutRef<"time">, "childr
|
|
|
45
44
|
srLabel?: string;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
type TarikhCompoundComponent = ForwardRefExoticComponent<TarikhProps & RefAttributes<HTMLTimeElement>> & {
|
|
48
|
+
Relative: typeof RelativeTimeComponent;
|
|
49
|
+
Bangla: typeof BanglaDateComponent;
|
|
50
|
+
};
|
|
51
|
+
declare const Tarikh: TarikhCompoundComponent;
|
|
52
|
+
declare const RelativeTimeComponent: ForwardRefExoticComponent<RelativeTimeProps & RefAttributes<HTMLTimeElement>>;
|
|
53
|
+
declare const BanglaDateComponent: ForwardRefExoticComponent<BanglaDateProps & RefAttributes<HTMLTimeElement>>;
|
|
51
54
|
|
|
52
|
-
export {
|
|
55
|
+
export { type BanglaDateProps, type RelativeTimeProps, Tarikh, type TarikhProps };
|
package/dist/react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{forwardRef as e,createElement as t}from"react";var n=["0","1","2","3","4","5","6","7","8","9"],r=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],a=["January","February","March","April","May","June","July","August","September","October","November","December"],o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],s=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],c=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],d=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],g=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],h=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],m=[31,31,31,31,31,30,30,30,30,30,30,30],f={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},y={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function b(e){return String(e).replace(/\d/g,e=>r[Number(e)]??e)}function v(e){return String(e).replace(/[০-৯]/g,e=>{const t=r.indexOf(e);return t>=0?n[t]??e:e})}var w={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function $(e){const t=e.trim(),n=t.toLowerCase(),r=w[n];if(void 0!==r)return r;for(let e=0;e<a.length;e++)if(a[e].toLowerCase()===n)return e;for(let e=0;e<o.length;e++)if(o[e].toLowerCase()===n)return e;for(let e=0;e<l.length;e++)if(l[e]===t)return e;for(let e=0;e<s.length;e++)if(s[e]===t)return e;return-1}function D(e,t,n,r=0,a=0,o=0,u=0){const i=new Date(e,t,n,r,a,o,u);return i.getFullYear()!==e||i.getMonth()!==t||i.getDate()!==n||i.getHours()!==r||i.getMinutes()!==a||i.getSeconds()!==o||i.getMilliseconds()!==u?null:i}function p(e){return function(e){const t=e.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return t?D(Number(t[1]),Number(t[3])-1,Number(t[4])):null}(e)??function(e){const t=e.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!t)return null;const n=Number(t[1]),r=Number(t[2]),a=Number(t[3]),o=Number(t[4]??0),u=Number(t[5]??0),i=Number(t[6]??0),l=Number((t[7]??"0").padEnd(3,"0").slice(0,3)),s=t[8];if(void 0===s)return D(n,r-1,a,o,u,i,l);const c=s.match(/^([+-])(\d{2}):?(\d{2})$/),d="Z"===s?0:c?("+"===c[1]?1:-1)*(60*Number(c[2])+Number(c[3])):null;if(null===d)return null;const g=Date.UTC(n,r-1,a,o,u,i,l)-6e4*d,h=new Date(g),m=new Date(g+6e4*d);return m.getUTCFullYear()!==n||m.getUTCMonth()!==r-1||m.getUTCDate()!==a||m.getUTCHours()!==o||m.getUTCMinutes()!==u||m.getUTCSeconds()!==i||m.getUTCMilliseconds()!==l?null:h}(e)??function(e){const t=e.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!t)return null;const n=Number(t[1]),r=t[2].replace(/,$/,""),a=t[3],o=$(r);if(-1===o)return null;let u=Number(a);return 2===a.length&&(u+=u>=50?1900:2e3),D(u,o,n)}(e)??function(e){const t=e.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!t)return null;const n=t[1].replace(/,$/,""),r=Number(t[2]),a=t[3],o=$(n);if(-1===o)return null;let u=Number(a);return 2===a.length&&(u+=u>=50?1900:2e3),D(u,o,r)}(e)}function N(e){if(e instanceof Date){const t=e.getTime();if(Number.isNaN(t))throw new Error(`Invalid date input: ${String(e)}`);return new Date(t)}if("number"==typeof e){if(!Number.isFinite(e))throw new Error(`Invalid date input: ${String(e)}`);const t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid date input: ${String(e)}`);return t}const t=p(v(e).trim());if(!t)throw new Error(`Invalid date input: ${String(e)}`);return t}function M(e,t){const n=N(e),r=n.getFullYear(),a=n.getMonth(),o=n.getDate(),u=new Date(r,3,14),i=a<3||3===a&&o<14,l=i?r-594:r-593,s=function(e,t){const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)}(i?new Date(r-1,3,14):u,n)+1,c=function(e){const t=[...m];return function(e){return(t=e+594)%4==0&&t%100!=0||t%400==0;var t}(e)&&(t[10]=31),t}(l);let d=s,g=0;for(let e=0;e<c.length;e++){const t=c[e];if(d<=t){g=e;break}d-=t}return{day:d,month:h[g],monthIndex:g+1,year:l}}function S(e){const t=b(e);return 1===e?`${t}লা`:2===e||3===e?`${t}রা`:4===e?`${t}ঠা`:e>=19?`${t}শে`:`${t}ই`}function T(e,t){return"spoken"===(t?.format??"ordinal")?function(e,t="pohela"){switch(e){case 1:return"poyla"===t?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return S(e)}}(e,t?.variant):S(e)}function k(e,t){return"2-digit"===t?String(e).padStart(2,"0"):String(e)}var F=1e3,j=36e5,C=24*j,Y=[{threshold:7*C,singular:"week",plural:"weeks"},{threshold:C,singular:"day",plural:"days"},{threshold:j,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:F,singular:"second",plural:"seconds"}];function B(e,t){return new Date(e,t+1,0).getDate()}function U(e,t){let n=e.getFullYear()-t.getFullYear();const r=function(e,t){const n=e.getFullYear()+t,r=e.getMonth(),a=Math.min(e.getDate(),B(n,r));return new Date(n,r,a,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function A(e,t){let n=12*(e.getFullYear()-t.getFullYear())+(e.getMonth()-t.getMonth());const r=function(e,t){const n=e.getFullYear(),r=e.getMonth()+t,a=n+Math.floor(r/12),o=(r%12+12)%12,u=Math.min(e.getDate(),B(a,o));return new Date(a,o,u,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function x(e,t,n,r,a){const o="bn-BD"===a,u=o?b(e):String(e),i=1===e?t:n;return o?r?`${u} ${i} আগে`:`${u} ${i} পরে`:r?`${u} ${i} ago`:`in ${u} ${i}`}function I(e,t,n){return"bn-BD"===n?"day"===e?t?"গতকাল":"আগামীকাল":"week"===e?t?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===e?t?"গত মাসে":"আগামী মাসে":t?"গত বছর":"আগামী বছর":"day"===e?t?"yesterday":"tomorrow":"week"===e?t?"last week":"next week":"month"===e?t?"last month":"next month":t?"last year":"next year"}function J(e){return"string"==typeof e&&!/(?:T|\s)\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:?\d{2})?$/i.test(e.trim())&&null!==function(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:new Date(e.getTime());if("number"==typeof e){const t=new Date(e);return Number.isNaN(t.getTime())?null:t}return p(v(e).trim())}(e)}function L(e,t){return J(e)?function(e){return`${String(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}(t):t.toISOString()}var O=e(function({value:e,locale:n,month:r,year:g,day:h,weekday:m,hour:f,minute:y,second:v,hour12:w,srLabel:$,"aria-label":D,...p},M){const S=N(e),T=function(e,t){const n=N(e),r=t?.locale??"en-BD",g=t?.month??"short",h=t?.year??"numeric",m=t?.day??"numeric",f=t?.weekday,y=t?.hour,v=t?.minute,w=t?.second,$=void 0!==y||void 0!==v||void 0!==w,D="bn-BD"===r,p=n.getDate(),M=n.getMonth(),S=n.getFullYear(),T=`${"2-digit"===m?String(p).padStart(2,"0"):String(p)} ${(D?"short"===g?s:l:"short"===g?o:a)[M]} ${"2-digit"===h?String(S).slice(-2):String(S)}`,F=void 0!==f?`${(D?"short"===f?d:c:"short"===f?i:u)[n.getDay()]}, `:"";let j="";if($){const e=t?.hour12??!1,a=n.getHours(),o=v??(void 0!==w?"2-digit":void 0),u=k(e?a%12||12:a,y??"numeric"),i=void 0!==o?`:${k(n.getMinutes(),o)}`:"",l=void 0!==w?`:${k(n.getSeconds(),w)}`:"",s=e?` ${function(e,t){if("bn-BD"===t)return e<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const n=e<12?"AM":"PM";return!1?n.toLowerCase():n}(a,r)}`:"";j=`${u}${i}${l}${s}`}const C=`${F}${T}${j?`, ${j}`:""}`;return D?b(C):C}(S,{...void 0!==n&&{locale:n},...void 0!==r&&{month:r},...void 0!==g&&{year:g},...void 0!==h&&{day:h},...void 0!==m&&{weekday:m},...void 0!==f&&{hour:f},...void 0!==y&&{minute:y},...void 0!==v&&{second:v},...void 0!==w&&{hour12:w}}),F=L(e,S);return t("time",{...p,ref:M,dateTime:F,"aria-label":$??D??T},T)});O.displayName="Tarikh";var E=e(function({value:e,locale:n,numeric:r,srLabel:a,"aria-label":o,...u},i){const l=N(e),s={...void 0!==n&&{locale:n},...void 0!==r&&{numeric:r}},c=function(e,t){const n=N(e),r=t?.locale??"en-BD",a=t?.numeric??"always",o="bn-BD"===r?y:f,u=Date.now()-n.getTime(),i=Math.abs(u),l=u>0,s=new Date,c=n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()&&n.getDate()===s.getDate(),d=l?s:n,g=l?n:s;if(i<F)return o.justNow;if("auto"===a&&c)return function(e){return"bn-BD"===e?"আজ":"today"}(r);const h=U(d,g);if(h>=1){if("auto"===a&&1===h){const e=I("year",l,r);if(null!==e)return e}return x(h,o.year,o.years,l,r)}const m=A(d,g);if(m>=1){if("auto"===a&&1===m){const e=I("month",l,r);if(null!==e)return e}return x(m,o.month,o.months,l,r)}for(const e of Y)if(i>=e.threshold){const t=Math.floor(i/e.threshold);if("auto"===a&&1===t&&("day"===e.singular||"week"===e.singular)){const t=I(e.singular,l,r);if(null!==t)return t}return x(t,o[e.singular],o[e.plural],l,r)}return o.justNow}(l,Object.keys(s).length>0?s:void 0),d=L(e,l);return t("time",{...u,ref:i,dateTime:d,"aria-label":a??o??c},c)});E.displayName="RelativeTime";var H=e(function({value:e,locale:n,format:r,variant:a,srLabel:o,"aria-label":u,...i},l){const s=N(e),c={...void 0!==n&&{locale:n},...void 0!==r&&{format:r},...void 0!==a&&{variant:a}},d=function(e,t){const n=t?.locale??"en-BD",r=t?.format??"ordinal",a=t?.variant,o=M(e);if("bn-BD"===n){const e=o.monthIndex-1,t={format:r};return void 0!==a&&(t.variant=a),`${T(o.day,t)} ${g[e]} ${b(o.year)}`}return`${o.day} ${o.month} ${o.year}`}(s,Object.keys(c).length>0?c:void 0),h=L(e,s);return t("time",{...i,ref:l,dateTime:h,"aria-label":o??u??d},d)});H.displayName="BanglaDate";export{H as BanglaDate,E as RelativeTime,O as Tarikh};
|
|
2
|
+
import{forwardRef as e,createElement as t}from"react";var n=["0","1","2","3","4","5","6","7","8","9"],r=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],o=["January","February","March","April","May","June","July","August","September","October","November","December"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],u=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],s=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],l=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],c=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],m=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],g=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],h=[31,31,31,31,31,30,30,30,30,30,30,30],f={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},y={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function b(e){return String(e).replace(/\d/g,e=>r[Number(e)]??e)}function v(e){return String(e).replace(/[০-৯]/g,e=>{const t=r.indexOf(e);return t>=0?n[t]??e:e})}var w={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function p(e){const t=e.trim(),n=t.toLowerCase(),r=w[n];if(void 0!==r)return r;for(let e=0;e<o.length;e++)if(o[e].toLowerCase()===n)return e;for(let e=0;e<a.length;e++)if(a[e].toLowerCase()===n)return e;for(let e=0;e<d.length;e++)if(d[e]===t)return e;for(let e=0;e<s.length;e++)if(s[e]===t)return e;return-1}function M(e,t,n,r=0,o=0,a=0,i=0){const u=new Date(e,t,n,r,o,a,i);return u.getFullYear()!==e||u.getMonth()!==t||u.getDate()!==n||u.getHours()!==r||u.getMinutes()!==o||u.getSeconds()!==a||u.getMilliseconds()!==i?null:u}function D(e){return function(e){const t=e.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return t?M(Number(t[1]),Number(t[3])-1,Number(t[4])):null}(e)??function(e){const t=e.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!t)return null;const n=Number(t[1]),r=Number(t[2]),o=Number(t[3]),a=Number(t[4]??0),i=Number(t[5]??0),u=Number(t[6]??0),d=Number((t[7]??"0").padEnd(3,"0").slice(0,3)),s=t[8];if(void 0===s)return M(n,r-1,o,a,i,u,d);const l=s.match(/^([+-])(\d{2}):?(\d{2})$/),c=l?Number(l[2]):null,m=l?Number(l[3]):null,g="Z"===s?0:l&&null!==c&&null!==m&&c<=23&&m<=59?("+"===l[1]?1:-1)*(60*c+m):null;if(null===g)return null;const h=Date.UTC(n,r-1,o,a,i,u,d)-6e4*g,f=new Date(h),y=new Date(h+6e4*g);return y.getUTCFullYear()!==n||y.getUTCMonth()!==r-1||y.getUTCDate()!==o||y.getUTCHours()!==a||y.getUTCMinutes()!==i||y.getUTCSeconds()!==u||y.getUTCMilliseconds()!==d?null:f}(e)??function(e){const t=e.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!t)return null;const n=Number(t[1]),r=t[2].replace(/,$/,""),o=t[3],a=p(r);if(-1===a)return null;let i=Number(o);return 2===o.length&&(i+=i>=50?1900:2e3),M(i,a,n)}(e)??function(e){const t=e.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!t)return null;const n=t[1].replace(/,$/,""),r=Number(t[2]),o=t[3],a=p(n);if(-1===a)return null;let i=Number(o);return 2===o.length&&(i+=i>=50?1900:2e3),M(i,a,r)}(e)}function $(e){if(e instanceof Date){const t=e.getTime();if(Number.isNaN(t))throw new Error(`Invalid date input: ${String(e)}`);return new Date(t)}if("number"==typeof e){if(!Number.isFinite(e))throw new Error(`Invalid date input: ${String(e)}`);const t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid date input: ${String(e)}`);return t}const t=D(v(e).trim());if(!t)throw new Error(`Invalid date input: ${String(e)}`);return t}function S(e,t){const n=$(e),r=n.getFullYear(),o=n.getMonth(),a=n.getDate(),i=new Date(r,3,14),u=o<3||3===o&&a<14,d=u?r-594:r-593,s=function(e,t){const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)}(u?new Date(r-1,3,14):i,n)+1,l=function(e){const t=[...h];return function(e){return(t=e+594)%4==0&&t%100!=0||t%400==0;var t}(e)&&(t[10]=31),t}(d);let c=s,m=0;for(let e=0;e<l.length;e++){const t=l[e];if(c<=t){m=e;break}c-=t}return{day:c,month:g[m],monthIndex:m+1,year:d}}function N(e){const t=b(e);return 1===e?`${t}লা`:2===e||3===e?`${t}রা`:4===e?`${t}ঠা`:e>=19?`${t}শে`:`${t}ই`}function T(e,t){return"spoken"===(t?.format??"ordinal")?function(e,t="pohela"){switch(e){case 1:return"poyla"===t?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return N(e)}}(e,t?.variant):N(e)}function Y(e,t){return"2-digit"===t?String(e).padStart(2,"0"):String(e)}function k(e,t,n){const r=Y(e,n);return"bn-BD"===t?b(r):r}function F(e,t,n){if(!t.includes(e))throw new TypeError(`Invalid ${n}: ${e}`)}function j(e,t,n){if("bn-BD"===t)return e<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=e<12?"AM":"PM";return n?r.toLowerCase():r}function B(e,t){if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError("format() expects an options object");if("pattern"in t&&void 0!==t.pattern){if("mode"in t&&void 0!==t.mode)throw new TypeError("Do not pass `mode` when `pattern` is provided. `pattern` formatting does not use mode.");const n="locale"in t&&void 0!==t.locale?t.locale:"en-BD";return function(e,t,n="en-BD"){const r=$(e),m="bn-BD"===n,g=r.getDate(),h=r.getMonth(),f=r.getFullYear(),y=m?d:o,b=m?s:a,v=m?l:i,w=m?c:u,p=r.getHours(),M=p%12||12,D={dddd:v[r.getDay()],ddd:w[r.getDay()],MMMM:y[h],MMM:b[h],MM:k(h+1,n,"2-digit"),M:k(h+1,n,"numeric"),DD:k(g,n,"2-digit"),D:k(g,n,"numeric"),HH:k(p,n,"2-digit"),H:k(p,n,"numeric"),hh:k(M,n,"2-digit"),h:k(M,n,"numeric"),mm:k(r.getMinutes(),n,"2-digit"),m:k(r.getMinutes(),n,"numeric"),ss:k(r.getSeconds(),n,"2-digit"),s:k(r.getSeconds(),n,"numeric"),A:j(p,n,!1),a:j(p,n,!0),YYYY:k(f,n,"numeric"),YY:k(Number(String(f).slice(-2)),n,"2-digit")},S=/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,N=e=>e.replace(S,e=>D[e]);let T="",Y=0;for(;Y<t.length;){const e=t.indexOf("[",Y);if(-1===e){T+=N(t.slice(Y));break}T+=N(t.slice(Y,e));const n=t.indexOf("]",e+1);if(-1===n){T+=t.slice(e);break}T+=t.slice(e+1,n),Y=n+1}return T}(e,t.pattern,n)}if(!("mode"in t)||void 0===t.mode)throw new TypeError("format() expects `mode` or `pattern`");const n=t.mode;switch(n){case"standard":return function(e,t){const n=$(e),r=t?.locale??"en-BD",m=t?.month??"short",g=t?.year??"numeric",h=t?.day??"numeric",f=t?.weekday,y=t?.hour,v=t?.minute,w=t?.second,p=void 0!==y||void 0!==v||void 0!==w,M="bn-BD"===r;F(m,["short","long"],"month format for standard mode"),F(g,["numeric","2-digit"],"year format for standard mode"),F(h,["numeric","2-digit"],"day format for standard mode"),void 0!==f&&F(f,["short","long"],"weekday format for standard mode"),void 0!==y&&F(y,["numeric","2-digit"],"hour format for standard mode"),void 0!==v&&F(v,["numeric","2-digit"],"minute format for standard mode"),void 0!==w&&F(w,["numeric","2-digit"],"second format for standard mode");const D=n.getDate(),S=n.getMonth(),N=n.getFullYear(),T=`${"2-digit"===h?String(D).padStart(2,"0"):String(D)} ${(M?"short"===m?s:d:"short"===m?a:o)[S]} ${"2-digit"===g?String(N).slice(-2):String(N)}`,k=void 0!==f?`${(M?"short"===f?c:l:"short"===f?u:i)[n.getDay()]}, `:"";let B="";if(p){const e=t?.hour12??!1,o=n.getHours(),a=v??(void 0!==w?"2-digit":void 0);B=`${Y(e?o%12||12:o,y??"numeric")}${void 0!==a?`:${Y(n.getMinutes(),a)}`:""}${void 0!==w?`:${Y(n.getSeconds(),w)}`:""}${e?` ${j(o,r,!1)}`:""}`}const C=`${k}${T}${B?`, ${B}`:""}`;return M?b(C):C}(e,t);case"bangla":return function(e,t){const n=t?.locale??"en-BD",r=t?.format??"ordinal",o=t?.variant,a=S(e);if("bn-BD"===n){const e=a.monthIndex-1,t={format:r};return void 0!==o&&(t.variant=o),`${T(a.day,t)} ${m[e]} ${b(a.year)}`}return`${a.day} ${a.month} ${a.year}`}(e,t);case"hybrid":return function(e,t){const n=$(e),r=t?.digits??"en",i=t?.month??"bn",u=t?.year??"en",l=t?.day??r,c=t?.monthFormat??"long";F(r,["en","bn"],"digits language for hybrid mode"),F(i,["en","bn"],"month language for hybrid mode"),F(u,["en","bn"],"year language for hybrid mode"),F(l,["en","bn"],"day language for hybrid mode"),F(c,["short","long"],"month format for hybrid mode");const m=n.getDate(),g=n.getMonth(),h=n.getFullYear(),f="bn"===i?"short"===c?s:d:"short"===c?a:o,y="bn"===l?b(m):String(m),v=f[g],w="bn"===u?b(h):String(h);return`${y} ${v} ${w}`}(e,t);default:throw new TypeError(`Invalid format mode: ${String(n)}`)}}var C=1e3,A=36e5,H=24*A,x=[{threshold:7*H,singular:"week",plural:"weeks"},{threshold:H,singular:"day",plural:"days"},{threshold:A,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:C,singular:"second",plural:"seconds"}];function E(e,t){return new Date(e,t+1,0).getDate()}function U(e,t){let n=e.getFullYear()-t.getFullYear();const r=function(e,t){const n=e.getFullYear()+t,r=e.getMonth(),o=Math.min(e.getDate(),E(n,r));return new Date(n,r,o,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function I(e,t){let n=12*(e.getFullYear()-t.getFullYear())+(e.getMonth()-t.getMonth());const r=function(e,t){const n=e.getFullYear(),r=e.getMonth()+t,o=n+Math.floor(r/12),a=(r%12+12)%12,i=Math.min(e.getDate(),E(o,a));return new Date(o,a,i,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function J(e,t,n,r,o){const a="bn-BD"===o,i=a?b(e):String(e),u=1===e?t:n;return a?r?`${i} ${u} আগে`:`${i} ${u} পরে`:r?`${i} ${u} ago`:`in ${i} ${u}`}function L(e,t,n){return"bn-BD"===n?"day"===e?t?"গতকাল":"আগামীকাল":"week"===e?t?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===e?t?"গত মাসে":"আগামী মাসে":t?"গত বছর":"আগামী বছর":"day"===e?t?"yesterday":"tomorrow":"week"===e?t?"last week":"next week":"month"===e?t?"last month":"next month":t?"last year":"next year"}function O(e){return"string"==typeof e&&!/(?:T|\s)\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i.test(e.trim())&&null!==function(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:new Date(e.getTime());if("number"==typeof e){const t=new Date(e);return Number.isNaN(t.getTime())?null:t}return D(v(e).trim())}(e)}function Z(e,t){return O(e)?function(e){return`${String(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}(t):t.toISOString()}var P=e(function({value:e,locale:n,month:r,year:o,day:a,weekday:i,hour:u,minute:d,second:s,hour12:l,srLabel:c,"aria-label":m,...g},h){const f=$(e),y=B(f,{mode:"standard",...{...void 0!==n&&{locale:n},...void 0!==r&&{month:r},...void 0!==o&&{year:o},...void 0!==a&&{day:a},...void 0!==i&&{weekday:i},...void 0!==u&&{hour:u},...void 0!==d&&{minute:d},...void 0!==s&&{second:s},...void 0!==l&&{hour12:l}}}),b=Z(e,f);return t("time",{...g,ref:h,dateTime:b,"aria-label":c??m??y},y)});P.displayName="Tarikh";var R=e(function({value:e,locale:n,numeric:r,srLabel:o,"aria-label":a,...i},u){const d=$(e),s={...void 0!==n&&{locale:n},...void 0!==r&&{numeric:r}},l=function(e,t){const n=$(e),r=t?.locale??"en-BD",o=t?.numeric??"always",a="bn-BD"===r?y:f,i=Date.now()-n.getTime(),u=Math.abs(i),d=i>0,s=new Date,l=n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()&&n.getDate()===s.getDate(),c=d?s:n,m=d?n:s;if(u<C)return a.justNow;if("auto"===o&&l)return function(e){return"bn-BD"===e?"আজ":"today"}(r);const g=U(c,m);if(g>=1){if("auto"===o&&1===g){const e=L("year",d,r);if(null!==e)return e}return J(g,a.year,a.years,d,r)}const h=I(c,m);if(h>=1){if("auto"===o&&1===h){const e=L("month",d,r);if(null!==e)return e}return J(h,a.month,a.months,d,r)}for(const e of x)if(u>=e.threshold){const t=Math.floor(u/e.threshold);if("auto"===o&&1===t&&("day"===e.singular||"week"===e.singular)){const t=L(e.singular,d,r);if(null!==t)return t}return J(t,a[e.singular],a[e.plural],d,r)}return a.justNow}(d,Object.keys(s).length>0?s:void 0),c=Z(e,d);return t("time",{...i,ref:u,dateTime:c,"aria-label":o??a??l},l)});R.displayName="RelativeTime";var W=e(function({value:e,locale:n,format:r,variant:o,srLabel:a,"aria-label":i,...u},d){const s=$(e),l=B(s,{mode:"bangla",...{...void 0!==n&&{locale:n},...void 0!==r&&{format:r},...void 0!==o&&{variant:o}}}),c=Z(e,s);return t("time",{...u,ref:d,dateTime:c,"aria-label":a??i??l},l)});W.displayName="BanglaDate",P.Relative=R,P.Bangla=W;export{P as Tarikh};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreify/tarikh",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A modern Bangladesh-first date toolkit for formatting, Bangla calendar, and localization in JavaScript, TypeScript, and React apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|