bn-calendar 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/dist/index.cjs +1169 -0
- package/dist/index.d.cts +656 -0
- package/dist/index.d.mts +656 -0
- package/dist/index.mjs +1166 -0
- package/dist/types-1mlac5Hi.d.mts +313 -0
- package/dist/types-DJR_67-s.d.cts +313 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +100 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
import { A as NumberRange, _ as BnCalendarConfig, a as $BnEn, c as BanglaDate, f as BanglaDayName, g as BanglaYear, h as BanglaSeasonName, k as Enumerate, l as BanglaDateFormat, m as BanglaMonthName, p as BanglaMonth, v as BnCalendarVariant } from "./types-1mlac5Hi.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/BanglaCalendar.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* @class Represents a date in the Bangla calendar system with support for different variants.
|
|
6
|
+
* - This class provides functionality to create, manipulate, convert dates between the Bangla and Gregorian calendar systems.
|
|
7
|
+
* - It supports two Bangla calendar variants: `'revised-2019'` (default) and `'revised-1966'`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Create from current date
|
|
11
|
+
* const today = new BanglaCalendar();
|
|
12
|
+
*
|
|
13
|
+
* // Create from Bangla date string (Bangla digit)
|
|
14
|
+
* const date0 = new BanglaCalendar('১৪৩২-১১-০৮');
|
|
15
|
+
*
|
|
16
|
+
* // Create from Gregorian date
|
|
17
|
+
* const date1 = new BanglaCalendar('2023-04-14'); // Latin digit
|
|
18
|
+
* const date2 = new BanglaCalendar(new Date('2023-04-14')); // Date object
|
|
19
|
+
*
|
|
20
|
+
* // Create with specific Bangla date using Latin digits
|
|
21
|
+
* const date3 = new BanglaCalendar(1430, 1, 1);
|
|
22
|
+
*
|
|
23
|
+
* // Create with specific Bangla date using Bangla digits
|
|
24
|
+
* const date4 = new BanglaCalendar('১৪৩০', '১', '১');
|
|
25
|
+
*
|
|
26
|
+
* // Create with specific variant
|
|
27
|
+
* const date5 = new BanglaCalendar('১৪৩০', '১', '১', { variant: 'revised-1966' });
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* - The Bangla calendar year starts on `April 14th (১ বৈশাখ)` in the Gregorian calendar.
|
|
31
|
+
* - The class automatically handles leap years according to the selected variant.
|
|
32
|
+
*/
|
|
33
|
+
declare class BanglaCalendar {
|
|
34
|
+
#private;
|
|
35
|
+
/** Bangla calendar variant */
|
|
36
|
+
readonly variant: BnCalendarVariant;
|
|
37
|
+
/** Bangla year */
|
|
38
|
+
readonly year: Readonly<{
|
|
39
|
+
/** Bangla year in Bangla digit */bn: BanglaYear; /** Bangla year in Latin digit */
|
|
40
|
+
en: number;
|
|
41
|
+
}>;
|
|
42
|
+
/** Bangla month */
|
|
43
|
+
readonly month: Readonly<{
|
|
44
|
+
/** Bangla month in Bangla digit */bn: BanglaMonth; /** Bangla month in Latin digit */
|
|
45
|
+
en: NumberRange<1, 12>;
|
|
46
|
+
}>;
|
|
47
|
+
/** Bangla day of the month */
|
|
48
|
+
readonly date: Readonly<{
|
|
49
|
+
/** Bangla day of the month in Bangla digit */bn: BanglaDate; /** Bangla day of the month in Latin digit */
|
|
50
|
+
en: NumberRange<1, 31>;
|
|
51
|
+
}>;
|
|
52
|
+
/** Gregorian equivalent of the current bangla date */
|
|
53
|
+
readonly gregorian: Readonly<{
|
|
54
|
+
/** Gregorian year in Latin digit */year: number; /** Gregorian month in Latin digit (`1-12`) */
|
|
55
|
+
month: NumberRange<1, 12>; /** Gregorian day of the month in Latin digit (`1-31`) */
|
|
56
|
+
date: NumberRange<1, 31>;
|
|
57
|
+
}>;
|
|
58
|
+
/** Gets the day of the week (0-6, where 0 is Sunday (রবিবার)). */
|
|
59
|
+
readonly weekDay: Enumerate<7>;
|
|
60
|
+
/** Gets ISO weekday: 1 = Monday, 7 = Sunday */
|
|
61
|
+
readonly isoWeekDay: NumberRange<1, 7>;
|
|
62
|
+
/**
|
|
63
|
+
* * Creates a `BanglaCalendar` instance from the current Gregorian date.
|
|
64
|
+
*
|
|
65
|
+
* @param config - Calendar configuration options
|
|
66
|
+
*/
|
|
67
|
+
constructor(config?: BnCalendarConfig);
|
|
68
|
+
/**
|
|
69
|
+
* * Creates a `BanglaCalendar` instance from a **Gregorian** or **Bangla** date string.
|
|
70
|
+
*
|
|
71
|
+
* @param date - Gregorian (should be parsable by {@link Date}) or Bangla date string
|
|
72
|
+
* @param config - Calendar configuration options
|
|
73
|
+
*
|
|
74
|
+
* @remarks
|
|
75
|
+
* - Bangla date string must be in `YYYY-MM-DD` format (padded with `০` or non-padded) in Bangla digit
|
|
76
|
+
* - Bangla date string is validated internally using {@link isBanglaDateString} method
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* const fromBanglaString = new BanglaCalendar('১৪৩২-১১-০৮');
|
|
80
|
+
* const fromGregorianString = new BanglaCalendar('2023-04-14');
|
|
81
|
+
*/
|
|
82
|
+
constructor(date: string, config?: BnCalendarConfig);
|
|
83
|
+
/**
|
|
84
|
+
* * Creates a `BanglaCalendar` instance from a {@link Date} object.
|
|
85
|
+
*
|
|
86
|
+
* @param date - Gregorian date as {@link Date} object
|
|
87
|
+
* @param config - Calendar configuration options
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const fromDateObject = new BanglaCalendar(new Date('2023-04-14'));
|
|
91
|
+
*/
|
|
92
|
+
constructor(date: Date, config?: BnCalendarConfig);
|
|
93
|
+
/**
|
|
94
|
+
* * Creates a `BanglaCalendar` instance from a timestamp or Bangla year (Latin digits).
|
|
95
|
+
*
|
|
96
|
+
* @param tsOrBnYear - Timestamp (number of milliseconds) or Bangla year in Latin digits (`0-9999`)
|
|
97
|
+
* @param config - Calendar configuration options
|
|
98
|
+
*
|
|
99
|
+
* @remarks Current month and day of the month is set with the specified `bnYear`.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* const fromTimestamp = new BanglaCalendar(1681430400000); // 2023-04-14 timestamp
|
|
103
|
+
* const fromYear = new BanglaCalendar(1430); // Bangla year 1430
|
|
104
|
+
*/
|
|
105
|
+
constructor(tsOrBnYear: number, config?: BnCalendarConfig);
|
|
106
|
+
/**
|
|
107
|
+
* * Creates a BanglaCalendar instance from Bangla year (Bangla digits).
|
|
108
|
+
*
|
|
109
|
+
* @param bnYear - Bangla year in Bangla digits (`০-৯৯৯৯`)
|
|
110
|
+
* @param config - Calendar configuration options
|
|
111
|
+
*
|
|
112
|
+
* @remarks Current month and day of the month is set with the specified `bnYear`.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* const bnCal = new BanglaCalendar('১৪৩০'); // Bangla year 1430
|
|
116
|
+
*/
|
|
117
|
+
constructor(bnYear: BanglaYear, config?: BnCalendarConfig);
|
|
118
|
+
/**
|
|
119
|
+
* * Creates a `BanglaCalendar` instance from Bangla year and month (Latin digits).
|
|
120
|
+
*
|
|
121
|
+
* @param bnYear - Bangla year in Latin digits (`0-9999`)
|
|
122
|
+
* @param bnMonth - Bangla month in Latin digits (`1-12`)
|
|
123
|
+
* @param config - Calendar configuration options
|
|
124
|
+
*
|
|
125
|
+
* @remarks Current day of the month is set with the specified `bnYear` and `bnMonth`.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* const bnCal = new BanglaCalendar(1430, 1); // বৈশাখ 1430
|
|
129
|
+
*/
|
|
130
|
+
constructor(bnYear: number, bnMonth: NumberRange<1, 12>, config?: BnCalendarConfig);
|
|
131
|
+
/**
|
|
132
|
+
* * Creates a `BanglaCalendar` instance from Bangla year and month (Bangla digits).
|
|
133
|
+
*
|
|
134
|
+
* @param bnYear - Bangla year in Bangla digits (`০-৯৯৯৯`)
|
|
135
|
+
* @param bnMonth - Bangla month in Bangla digits (`১-১২`)
|
|
136
|
+
* @param config - Calendar configuration options
|
|
137
|
+
*
|
|
138
|
+
* @remarks Current day of the month is set with the specified `bnYear` and `bnMonth`.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '১'); // বৈশাখ 1430
|
|
142
|
+
*/
|
|
143
|
+
constructor(bnYear: BanglaYear, bnMonth: BanglaMonth, config?: BnCalendarConfig);
|
|
144
|
+
/**
|
|
145
|
+
* * Creates a `BanglaCalendar` instance from Bangla year, month, and day (Latin digits).
|
|
146
|
+
*
|
|
147
|
+
* @param bnYear - Bangla year in Latin digits (`0-9999`)
|
|
148
|
+
* @param bnMonth - Bangla month in Latin digits (`1-12`)
|
|
149
|
+
* @param bnDate - Bangla day of month in Latin digits (`1-31`)
|
|
150
|
+
* @param config - Calendar configuration options
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* const bnCal = new BanglaCalendar(1430, 1, 1); // ১ বৈশাখ ১৪৩০
|
|
154
|
+
*/
|
|
155
|
+
constructor(bnYear: number, bnMonth: NumberRange<1, 12>, bnDate: NumberRange<1, 31>, config?: BnCalendarConfig);
|
|
156
|
+
/**
|
|
157
|
+
* * Creates a `BanglaCalendar` instance from Bangla year, month, and day (Bangla digits).
|
|
158
|
+
*
|
|
159
|
+
* @param bnYear - Bangla year in Bangla digits (`০-৯৯৯৯`)
|
|
160
|
+
* @param bnMonth - Bangla month in Bangla digits (`১-১২`)
|
|
161
|
+
* @param bnDate - Bangla day of month in Bangla digits (`১-৩১`)
|
|
162
|
+
* @param config - Calendar configuration options
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '১', '১'); // ১ বৈশাখ ১৪৩০
|
|
166
|
+
*/
|
|
167
|
+
constructor(bnYear: BanglaYear, bnMonth: BanglaMonth, bnDate: BanglaDate, config?: BnCalendarConfig);
|
|
168
|
+
[Symbol.toPrimitive](hint: string): string | number;
|
|
169
|
+
get [Symbol.toStringTag](): string;
|
|
170
|
+
/**
|
|
171
|
+
* @instance Get timestamp in milliseconds for the current date.
|
|
172
|
+
* @remarks
|
|
173
|
+
* - Converts the current Bangla date to a Gregorian {@link Date} using {@link toDate()}.
|
|
174
|
+
* - Returns the Unix timestamp (in milliseconds) of the converted date.
|
|
175
|
+
* - The time component is normalized to midnight UTC during the conversion process.
|
|
176
|
+
*/
|
|
177
|
+
valueOf(): number;
|
|
178
|
+
/**
|
|
179
|
+
* @instance Returns a string representation of the Bangla date in ISO-like format (YYYY-MM-DD with Bangla digits).
|
|
180
|
+
*
|
|
181
|
+
* @returns Bangla date string in the format: "YYYY-MM-DD" (e.g., "১৪৩০-০১-০১")
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* const bnCal = new BanglaCalendar('2023-04-14');
|
|
185
|
+
* console.log(bnCal.toJSON()); // "১৪৩০-০১-০১"
|
|
186
|
+
*
|
|
187
|
+
* @remarks
|
|
188
|
+
* - This method is automatically called by {@link JSON.stringify()} method
|
|
189
|
+
* - Output follows the pattern: `"বছর-মাস-দিন"` with zero-padded Bangla digits
|
|
190
|
+
* - Month and date are padded to 2 digits, year to 4 digits
|
|
191
|
+
*/
|
|
192
|
+
toJSON(): string;
|
|
193
|
+
/**
|
|
194
|
+
* * Checks if the current Bangla year is a leap year.
|
|
195
|
+
*
|
|
196
|
+
* @returns `true` if the year is a leap year, `false` otherwise
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* const date = new BanglaCalendar(1430, 1, 1);
|
|
200
|
+
* const isLeap = date.isLeapYear(); // false
|
|
201
|
+
*
|
|
202
|
+
* @remarks
|
|
203
|
+
* - Leap year determination depends on the selected calendar variant.
|
|
204
|
+
* - The `'revised-2019'` and `'revised-1966'` variants have different leap year rules.
|
|
205
|
+
* - **Revised-2019**: Leap year is determined by the associated Gregorian year's leap rule:
|
|
206
|
+
* - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
|
|
207
|
+
* - **Revised-1966**: Leap year is determined solely by the Bangla year (`bnYear % 4 === 2`), no Gregorian rule applies.
|
|
208
|
+
*/
|
|
209
|
+
isLeapYear(): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* * Converts the Bangla calendar date to a JS {@link Date} object.
|
|
212
|
+
*
|
|
213
|
+
* @returns Gregorian Date object equivalent to the Bangla date
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* const bnDate = new BanglaCalendar('১৪৩০', '১', '১');
|
|
217
|
+
* const gregorianDate = bnDate.toDate(); // Date for April 14, 2023
|
|
218
|
+
* console.log(gregorianDate.toISOString()); // 2023-04-14T00:00:00.000Z
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* - The conversion takes into account the calendar variant and leap year rules.
|
|
222
|
+
* - Time component is always set to `00:00:00` in UTC.
|
|
223
|
+
*/
|
|
224
|
+
toDate(): Date;
|
|
225
|
+
/**
|
|
226
|
+
* @instance Gets the Bangla season name for the current date.
|
|
227
|
+
*
|
|
228
|
+
* @param locale - Output locale ('bn' for Bengali, 'en' for English)
|
|
229
|
+
* @returns Name of the season in the specified locale
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* const bnCal = new BanglaCalendar('2023-04-14');
|
|
233
|
+
* bnCal.getSeasonName(); // Returns: 'গ্রীষ্ম'
|
|
234
|
+
* bnCal.getSeasonName('en'); // Returns: 'Grisma (Summer)'
|
|
235
|
+
*
|
|
236
|
+
* @remarks
|
|
237
|
+
* Bangla calendar is traditionally divided into 6 seasons (ঋতু):
|
|
238
|
+
* - গ্রীষ্ম (Summer): Mid-April to Mid-June
|
|
239
|
+
* - বর্ষা (Monsoon): Mid-June to Mid-August
|
|
240
|
+
* - শরৎ (Autumn): Mid-August to Mid-October
|
|
241
|
+
* - হেমন্ত (Late Autumn): Mid-October to Mid-December
|
|
242
|
+
* - শীত (Winter): Mid-December to Mid-February
|
|
243
|
+
* - বসন্ত (Spring): Mid-February to Mid-April
|
|
244
|
+
*/
|
|
245
|
+
getSeasonName<Locale extends $BnEn = 'bn'>(locale?: Locale): BanglaSeasonName<Locale>;
|
|
246
|
+
/**
|
|
247
|
+
* @instance Gets the Bangla name of the month for the current date.
|
|
248
|
+
*
|
|
249
|
+
* @param locale - Output locale ('bn' for Bengali, 'en' for English)
|
|
250
|
+
* @returns Name of the month in the specified locale
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* const bnCal = new BanglaCalendar('2023-04-14');
|
|
254
|
+
* bnCal.getMonthName(); // Returns: 'বৈশাখ'
|
|
255
|
+
* bnCal.getMonthName('en'); // Returns: 'Boishakh'
|
|
256
|
+
*
|
|
257
|
+
* @remarks
|
|
258
|
+
* - Month names follow traditional Bengali naming conventions.
|
|
259
|
+
* - English names are transliterated versions of the Bengali names.
|
|
260
|
+
* - Month determination may vary slightly between calendar variants near month boundaries.
|
|
261
|
+
*/
|
|
262
|
+
getMonthName<Locale extends $BnEn = 'bn'>(locale?: Locale): BanglaMonthName<Locale>;
|
|
263
|
+
/**
|
|
264
|
+
* @instance Gets the Bangla name of the weekday for the current date.
|
|
265
|
+
*
|
|
266
|
+
* @param locale - Output locale ('bn' for Bengali, 'en' for English)
|
|
267
|
+
* @returns Name of the weekday in the specified locale
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* const bnCal = new BanglaCalendar('2023-04-14'); // Friday
|
|
271
|
+
* bnCal.getDayName(); // Returns: 'শুক্রবার'
|
|
272
|
+
* bnCal.getDayName('en'); // Returns: 'Shukrobar (Friday)'
|
|
273
|
+
*
|
|
274
|
+
* @remarks
|
|
275
|
+
* - Weekday names follow the standard Bengali naming convention ending with 'বার'.
|
|
276
|
+
* - English names are the Latin transliterations of the Bangla names with standard English weekday names.
|
|
277
|
+
*/
|
|
278
|
+
getDayName<Locale extends $BnEn = 'bn'>(locale?: Locale): BanglaDayName<Locale>;
|
|
279
|
+
/**
|
|
280
|
+
* @instance Adds days to the current Bangla date.
|
|
281
|
+
*
|
|
282
|
+
* @param days - Number of days to add (can be negative to subtract days)
|
|
283
|
+
* @returns New `BanglaCalendar` instance with the adjusted date
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '১', '১'); // ১ বৈশাখ ১৪৩০
|
|
287
|
+
*
|
|
288
|
+
* // Add days
|
|
289
|
+
* bnCal.addDays(7); // Returns: ৮ বৈশাখ ১৪৩০
|
|
290
|
+
*
|
|
291
|
+
* // Subtract days
|
|
292
|
+
* bnCal.addDays(-3); // Returns: ২৮ চৈত্র ১৪২৯
|
|
293
|
+
*
|
|
294
|
+
* // Add days crossing month boundary
|
|
295
|
+
* bnCal.addDays(35); // Returns: ৫ জ্যৈষ্ঠ ১৪৩০
|
|
296
|
+
*
|
|
297
|
+
* // Add days crossing year boundary
|
|
298
|
+
* const lateDate = new BanglaCalendar('১৪৩০', '১২', '২৫');
|
|
299
|
+
* lateDate.addDays(10); // Returns: ৫ বৈশাখ ১৪৩১
|
|
300
|
+
*
|
|
301
|
+
* @remarks
|
|
302
|
+
* - The resulting instance preserves the calendar variant of the original
|
|
303
|
+
* - Handles month and year transitions automatically
|
|
304
|
+
* - Accounts for varying month lengths and leap years
|
|
305
|
+
* - Time component remains at midnight UTC in the Gregorian conversion (using {@link BanglaCalendar.toDate()} method)
|
|
306
|
+
* - Negative values subtract days from the current date
|
|
307
|
+
*/
|
|
308
|
+
addDays(days: number): BanglaCalendar;
|
|
309
|
+
/**
|
|
310
|
+
* @instance Adds weeks to the current Bangla date.
|
|
311
|
+
*
|
|
312
|
+
* @param weeks - Number of weeks to add (can be negative to subtract weeks)
|
|
313
|
+
* @returns New `BanglaCalendar` instance with the adjusted date
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '১', '১'); // ১ বৈশাখ ১৪৩০
|
|
317
|
+
*
|
|
318
|
+
* // Add weeks
|
|
319
|
+
* bnCal.addWeeks(2); // Returns: ১৫ বৈশাখ ১৪৩০
|
|
320
|
+
*
|
|
321
|
+
* // Subtract weeks
|
|
322
|
+
* bnCal.addWeeks(-1); // Returns: ২৪ চৈত্র ১৪২৯
|
|
323
|
+
*
|
|
324
|
+
* // Add weeks crossing month boundary
|
|
325
|
+
* bnCal.addWeeks(5); // Returns: ৫ জ্যৈষ্ঠ ১৪৩০
|
|
326
|
+
*
|
|
327
|
+
* @remarks
|
|
328
|
+
* - Each week is treated as 7 days
|
|
329
|
+
* - The resulting instance preserves the calendar variant of the original
|
|
330
|
+
* - Handles month and year transitions automatically
|
|
331
|
+
* - Time component remains at midnight UTC in the Gregorian conversion (using {@link BanglaCalendar.toDate()} method)
|
|
332
|
+
* - Negative values subtract weeks from the current date
|
|
333
|
+
* - Useful for scheduling recurring weekly events
|
|
334
|
+
*/
|
|
335
|
+
addWeeks(weeks: number): BanglaCalendar;
|
|
336
|
+
/**
|
|
337
|
+
* @instance Adds months to the current Bangla date.
|
|
338
|
+
*
|
|
339
|
+
* @param months - Number of months to add (can be negative to subtract months)
|
|
340
|
+
* @param overflow - If `true`, allows date overflow to next month when day doesn't exist;
|
|
341
|
+
* if `false`, clamps to last day of target month (default: `true`)
|
|
342
|
+
* @returns New `BanglaCalendar` instance with the adjusted date
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* // Normal case: day exists in target month
|
|
346
|
+
* const normal = new BanglaCalendar('১৪৩০', '২', '১৫');
|
|
347
|
+
* normal.addMonths(1); // Returns: ১৫ আষাঢ় ১৪৩০
|
|
348
|
+
* normal.addMonths(1, false); // Returns: ১৫ আষাঢ় ১৪৩০ (same behavior for both)
|
|
349
|
+
*
|
|
350
|
+
* // Edge case: day does not exist in target month
|
|
351
|
+
* const edgeCase = new BanglaCalendar('১৪৩০', '৬', '৩১'); // ৩১ আশ্বিন ১৪৩০
|
|
352
|
+
*
|
|
353
|
+
* // With overflow (default): 31st doesn't exist in কার্তিক (30 days)
|
|
354
|
+
* edgeCase.addMonths(1); // Returns: ১ অগ্রহায়ণ ১৪৩০ (overflows to next month)
|
|
355
|
+
*
|
|
356
|
+
* // Without overflow: clamps to last day of target month
|
|
357
|
+
* edgeCase.addMonths(1, false); // Returns: ৩০ কার্তিক ১৪৩০ (clamped)
|
|
358
|
+
*
|
|
359
|
+
* // Subtract months
|
|
360
|
+
* edgeCase.addMonths(-1); // Returns: ১ আশ্বিন ১৪৩০
|
|
361
|
+
* edgeCase.addMonths(-1, false); // Returns: ৩১ ভাদ্র ১৪৩০
|
|
362
|
+
*
|
|
363
|
+
* @remarks
|
|
364
|
+
* - When `overflow=true` (default):
|
|
365
|
+
* Follows JavaScript {@link Date} behavior where invalid dates overflow to the next month (e.g., ৩১ আশ্বিন + 1 month → ১ অগ্রহায়ণ)
|
|
366
|
+
* - When `overflow=false`:
|
|
367
|
+
* Clamps to the last valid day of the target month (e.g., ৩১ আশ্বিন + 1 month → ৩০ কার্তিক)
|
|
368
|
+
* - The resulting instance preserves the calendar variant of the original
|
|
369
|
+
* - Handles year transitions automatically
|
|
370
|
+
* - Time component remains at midnight UTC in the Gregorian conversion (using {@link BanglaCalendar.toDate()} method)
|
|
371
|
+
* - Negative values subtract months from the current date
|
|
372
|
+
*/
|
|
373
|
+
addMonths(months: number, overflow?: boolean): BanglaCalendar;
|
|
374
|
+
/**
|
|
375
|
+
* @instance Adds years to the current Bangla date.
|
|
376
|
+
*
|
|
377
|
+
* @param years - Number of years to add (can be negative to subtract years)
|
|
378
|
+
* @param overflow - If `true`, allows date overflow when day doesn't exist in target year;
|
|
379
|
+
* if `false`, clamps to last valid day of month (default: `true`)
|
|
380
|
+
* @returns New `BanglaCalendar` instance with the adjusted date
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '১', '১৫'); // ১৫ বৈশাখ ১৪৩০
|
|
384
|
+
*
|
|
385
|
+
* // Add years
|
|
386
|
+
* bnCal.addYears(1); // Returns: ১৫ বৈশাখ ১৪৩১
|
|
387
|
+
*
|
|
388
|
+
* // Subtract years
|
|
389
|
+
* bnCal.addYears(-1); // Returns: ১৫ বৈশাখ ১৪২৯
|
|
390
|
+
*
|
|
391
|
+
* // Multiple years
|
|
392
|
+
* bnCal.addYears(5); // Returns: ১৫ বৈশাখ ১৪৩৫
|
|
393
|
+
*
|
|
394
|
+
* // Edge case: day adjustment for ফাল্গুন (accounting leap year)
|
|
395
|
+
* const leapDay = new BanglaCalendar('১৪৩১', '১১', '৩০'); // ১৪৩১ is a leap year
|
|
396
|
+
* leapDay.addYears(1, false); // Returns: ২৯ ফাল্গুন ১৪৩২ (non-leap years have 29 days in ফাল্গুন)
|
|
397
|
+
*
|
|
398
|
+
* @remarks
|
|
399
|
+
* - The resulting instance preserves the calendar variant of the original
|
|
400
|
+
* - Negative values subtract years from the current date
|
|
401
|
+
* - Year addition follows Bangla calendar years
|
|
402
|
+
* - Time component remains at midnight UTC in the Gregorian conversion (using {@link BanglaCalendar.toDate()} method)
|
|
403
|
+
* - The month and day generally remain the same unless affected by leap year rules
|
|
404
|
+
*/
|
|
405
|
+
addYears(years: number, overflow?: boolean): BanglaCalendar;
|
|
406
|
+
/**
|
|
407
|
+
* @instance Gets a new `BanglaCalendar` instance representing the first day of the current month.
|
|
408
|
+
*
|
|
409
|
+
* @returns A `BanglaCalendar` instance set to the 1st day of the current month
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '৫', '১৫');
|
|
413
|
+
* const startOfMonth = bnCal.startOfMonth(); // Returns: ১ জ্যৈষ্ঠ ১৪৩০
|
|
414
|
+
*
|
|
415
|
+
* @remarks
|
|
416
|
+
* - The resulting instance preserves the calendar variant of the original
|
|
417
|
+
* - Useful for date range calculations and month-based operations
|
|
418
|
+
* - Time component remains at midnight UTC in the Gregorian conversion (using {@link BanglaCalendar.toDate()} method)
|
|
419
|
+
*/
|
|
420
|
+
startOfMonth(): BanglaCalendar;
|
|
421
|
+
/**
|
|
422
|
+
* @instance Gets a new `BanglaCalendar` instance representing the last day of the current month.
|
|
423
|
+
*
|
|
424
|
+
* @returns A `BanglaCalendar` instance set to the last day of the current month
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '৫', '১৫');
|
|
428
|
+
* const endOfMonth = bnCal.endOfMonth(); // Returns: ৩১ জ্যৈষ্ঠ ১৪৩০ (or 30 for some months)
|
|
429
|
+
*
|
|
430
|
+
* @remarks
|
|
431
|
+
* - The resulting instance preserves the calendar variant of the original
|
|
432
|
+
* - Accounts for month length variations (29/30/31 days) including leap years
|
|
433
|
+
* - Time component remains at midnight UTC in the Gregorian conversion (using {@link BanglaCalendar.toDate()} method)
|
|
434
|
+
*/
|
|
435
|
+
endOfMonth(): BanglaCalendar;
|
|
436
|
+
/**
|
|
437
|
+
* @instance Gets a new `BanglaCalendar` instance representing the first day of the current year (১ বৈশাখ).
|
|
438
|
+
*
|
|
439
|
+
* @returns A `BanglaCalendar` instance set to ১ বৈশাখ of the current year
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '৫', '১৫');
|
|
443
|
+
* const startOfYear = bnCal.startOfYear(); // Returns: ১ বৈশাখ ১৪৩০
|
|
444
|
+
*
|
|
445
|
+
* @remarks
|
|
446
|
+
* - The resulting instance preserves the calendar variant of the original
|
|
447
|
+
* - Always returns the 1st day of the 1st month (বৈশাখ)
|
|
448
|
+
* - Time component remains at midnight UTC in the Gregorian conversion (using {@link BanglaCalendar.toDate()} method)
|
|
449
|
+
*/
|
|
450
|
+
startOfYear(): BanglaCalendar;
|
|
451
|
+
/**
|
|
452
|
+
* @instance Gets a new `BanglaCalendar` instance representing the last day of the current year (৩০ চৈত্র).
|
|
453
|
+
*
|
|
454
|
+
* @returns A `BanglaCalendar` instance set to ৩০ চৈত্র of the current year
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '৫', '১৫');
|
|
458
|
+
* const endOfYear = bnCal.endOfYear(); // Returns: ৩০ চৈত্র ১৪৩০
|
|
459
|
+
*
|
|
460
|
+
* @remarks
|
|
461
|
+
* - The resulting instance preserves the calendar variant of the original
|
|
462
|
+
* - Always returns the 30th day of the 12th month (চৈত্র)
|
|
463
|
+
* - Time component remains at midnight UTC in the Gregorian conversion (using {@link BanglaCalendar.toDate()} method)
|
|
464
|
+
*/
|
|
465
|
+
endOfYear(): BanglaCalendar;
|
|
466
|
+
/**
|
|
467
|
+
* @instance Gets the number of days in a Bangla month.
|
|
468
|
+
*
|
|
469
|
+
* @param month - Optional Bangla month (1-12 in Latin digits)
|
|
470
|
+
* @returns Number of days in the specified month (29, 30, or 31)
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* const bnCal = new BanglaCalendar('১৪৩০', '১', '১');
|
|
474
|
+
*
|
|
475
|
+
* // Get days in current month
|
|
476
|
+
* bnCal.daysInMonth(); // Returns: 31 (বৈশাখ has 31 days)
|
|
477
|
+
*
|
|
478
|
+
* // Get days in specific month
|
|
479
|
+
* bnCal.daysInMonth(2); // Returns: 31 (জ্যৈষ্ঠ has 31 days)
|
|
480
|
+
* bnCal.daysInMonth(12); // Returns: 30 (চৈত্র has 30 days)
|
|
481
|
+
*
|
|
482
|
+
* @remarks
|
|
483
|
+
* - The method accounts for the selected calendar variant when determining leap years
|
|
484
|
+
* - If no month is provided, uses the current instance's month
|
|
485
|
+
* - In the 'revised-2019' variant, leap years follow Gregorian leap rules
|
|
486
|
+
* - In the 'revised-1966' variant, leap years occur when `bnYear % 4 === 2`
|
|
487
|
+
*/
|
|
488
|
+
daysInMonth(month?: NumberRange<1, 12>): NumberRange<29, 31>;
|
|
489
|
+
/**
|
|
490
|
+
* @instance Returns a string representation of the Bangla date in Bengali format.
|
|
491
|
+
*
|
|
492
|
+
* @returns Bangla date string in the format: "শুক্রবার, ১৫ জ্যৈষ্ঠ, ১৪৩০ [গ্রীষ্ম]"
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* const bnCal = new BanglaCalendar('2023-04-14');
|
|
496
|
+
* console.log(bnCal.toString()); // "শুক্রবার, ১ বৈশাখ, ১৪৩০ [গ্রীষ্ম]"
|
|
497
|
+
*
|
|
498
|
+
* @remarks
|
|
499
|
+
* - Equivalent to calling {@link toStringEn()} with 'bn' locale
|
|
500
|
+
* - Format includes day name, date, month name, year, and season in brackets
|
|
501
|
+
* - Uses Bengali digits and Bengali month/day names
|
|
502
|
+
*/
|
|
503
|
+
toString(): string;
|
|
504
|
+
/**
|
|
505
|
+
* @instance Returns a string representation of the Bangla date in English/Latin format.
|
|
506
|
+
*
|
|
507
|
+
* @returns Bangla date string in the format: "Shukrobar (Friday), 15 Joishtho, 1430 [Grisma (Summer)]"
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* const bnCal = new BanglaCalendar('2023-04-14');
|
|
511
|
+
* console.log(bnCal.toStringEn()); // "Shukrobar (Friday), 1 Boishakh, 1430 [Grisma (Summer)]"
|
|
512
|
+
*
|
|
513
|
+
* @remarks
|
|
514
|
+
* - Equivalent to calling {@link toString()} with 'en' locale
|
|
515
|
+
* - Format includes transliterated day name (with English equivalent), date, transliterated month and season name, and year.
|
|
516
|
+
* - Uses Latin digits and transliterated Bengali names
|
|
517
|
+
*/
|
|
518
|
+
toStringEn(): string;
|
|
519
|
+
/**
|
|
520
|
+
* @instance Formats the current date as a Bangla calendar date string (no time) using customizable tokens.
|
|
521
|
+
*
|
|
522
|
+
* @param format - Format string using tokens (default: `'ddd, DD mmmm (SS), YYYY বঙ্গাব্দ'`)
|
|
523
|
+
* @returns Formatted Bangla date string according to the specified format
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* const bnCal = new BanglaCalendar('2023-04-14');
|
|
527
|
+
*
|
|
528
|
+
* bnCal.format();
|
|
529
|
+
* // Returns: 'শুক্রবার, বৈশাখ ০১ (গ্রীষ্মকাল), ১৪৩০ বঙ্গাব্দ'
|
|
530
|
+
*
|
|
531
|
+
* bnCal.format('YYYY-MM-DD');
|
|
532
|
+
* // Returns: '১৪৩০-০১-০১'
|
|
533
|
+
*
|
|
534
|
+
* bnCal.format('mmmm DD, YYYY');
|
|
535
|
+
* // Returns: 'বৈশাখ ০১, ১৪৩০'
|
|
536
|
+
*
|
|
537
|
+
* @remarks
|
|
538
|
+
* - **Important:** Does not allow time formatting tokens!
|
|
539
|
+
* - Supported format tokens include: `YYYY`, `YY`, `mmmm`, `mmm`, `MM`, `M`, `DD`, `D`, `dd`, `ddd`, `Do`, `SS` and `S`.
|
|
540
|
+
* - **Year**: `YYYY/yyyy` (full year), `YY/yy` (last 2 digits)
|
|
541
|
+
* - **Month**: `M/MM`(padded), `mmm` (short name), `mmmm` (full name)
|
|
542
|
+
* - **Day**: `D/DD`(padded), Do (results same as cardinal for Bangla dates)
|
|
543
|
+
* - **Weekday**: `d` (short), `dd` (without 'বার'), `ddd` (full)
|
|
544
|
+
* - **Season**: `S` (season), `SS` (season with 'কাল' suffix)
|
|
545
|
+
* - To output raw text (i.e., not interpreted as a date token), wrap it in square brackets.
|
|
546
|
+
* - For example, `[আজ] ddd` results in `আজ রবিবার`, and `[year ]YYYY` results in `year ২০২৫`.
|
|
547
|
+
* - *Any token not wrapped in brackets will be parsed and replaced with its corresponding date component.*
|
|
548
|
+
*/
|
|
549
|
+
format(format?: BanglaDateFormat): string;
|
|
550
|
+
/**
|
|
551
|
+
* @static Check if a value is a configuration object that contains a valid {@link variant}
|
|
552
|
+
* @param value Value to check
|
|
553
|
+
* @returns `true` if the value contains a valid {@link variant} property, `false` otherwise
|
|
554
|
+
*/
|
|
555
|
+
$hasVariantConfig(value: unknown): value is {
|
|
556
|
+
variant: BnCalendarVariant;
|
|
557
|
+
};
|
|
558
|
+
/**
|
|
559
|
+
* @static Checks whether a value is a valid Bangla year in Bangla digits (`০–৯৯৯৯`).
|
|
560
|
+
*
|
|
561
|
+
* @param value - Value to check. Accepts both zero-padded and non-padded Bangla digits
|
|
562
|
+
* @returns `true` if the value is a valid Bangla year, `false` otherwise
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* BanglaCalendar.isBanglaYear('১৪৩০'); // true
|
|
566
|
+
* BanglaCalendar.isBanglaYear('০'); // true
|
|
567
|
+
* BanglaCalendar.isBanglaYear('১০০০০'); // false (too many digits)
|
|
568
|
+
* BanglaCalendar.isBanglaYear('1430'); // false (Latin digits)
|
|
569
|
+
*/
|
|
570
|
+
static isBanglaYear(value: unknown): value is BanglaYear;
|
|
571
|
+
/**
|
|
572
|
+
* @static Checks whether a value is a valid Bangla year in Latin digits (`0–9999`).
|
|
573
|
+
*
|
|
574
|
+
* @param value - Value to check (must be a number)
|
|
575
|
+
* @returns `true` if the value is a valid Bangla year, `false` otherwise
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* BanglaCalendar.isBanglaYearEn(1430); // true
|
|
579
|
+
* BanglaCalendar.isBanglaYearEn(0); // true
|
|
580
|
+
* BanglaCalendar.isBanglaYearEn(10000); // false
|
|
581
|
+
* BanglaCalendar.isBanglaYearEn(-1); // false
|
|
582
|
+
*/
|
|
583
|
+
static isBanglaYearEn(value: number): boolean;
|
|
584
|
+
/**
|
|
585
|
+
* @static Checks whether a value is a valid Bangla month in Bangla digits (`১–১২`).
|
|
586
|
+
*
|
|
587
|
+
* @param value - Value to check. Accepts both zero-padded and non-padded Bangla digits
|
|
588
|
+
* @returns `true` if the value is a valid Bangla month, `false` otherwise
|
|
589
|
+
*
|
|
590
|
+
* @example
|
|
591
|
+
* BanglaCalendar.isBanglaMonth('১'); // true
|
|
592
|
+
* BanglaCalendar.isBanglaMonth('১২'); // true
|
|
593
|
+
* BanglaCalendar.isBanglaMonth('১৩'); // false
|
|
594
|
+
* BanglaCalendar.isBanglaMonth('0'); // false (Latin digit)
|
|
595
|
+
*/
|
|
596
|
+
static isBanglaMonth(value: unknown): value is BanglaMonth;
|
|
597
|
+
/**
|
|
598
|
+
* @static Checks whether a value is a valid Bangla month in Latin digits (`1–12`).
|
|
599
|
+
*
|
|
600
|
+
* @param value - Value to check
|
|
601
|
+
* @returns `true` if the value is a valid Bangla month, `false` otherwise
|
|
602
|
+
*
|
|
603
|
+
* @example
|
|
604
|
+
* BanglaCalendar.isBanglaMonthEn(1); // true
|
|
605
|
+
* BanglaCalendar.isBanglaMonthEn(12); // true
|
|
606
|
+
* BanglaCalendar.isBanglaMonthEn(0); // false
|
|
607
|
+
* BanglaCalendar.isBanglaMonthEn(13); // false
|
|
608
|
+
*/
|
|
609
|
+
static isBanglaMonthEn(value: unknown): value is NumberRange<1, 12>;
|
|
610
|
+
/**
|
|
611
|
+
* @static Checks whether a value is a valid Bangla date of month in Bangla digits (`১–৩১`).
|
|
612
|
+
*
|
|
613
|
+
* @param value - Value to check. Accepts both zero-padded and non-padded Bangla digits
|
|
614
|
+
* @returns `true` if the value is a valid Bangla date, `false` otherwise
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* BanglaCalendar.isBanglaDate('১'); // true
|
|
618
|
+
* BanglaCalendar.isBanglaDate('৩১'); // true
|
|
619
|
+
* BanglaCalendar.isBanglaDate('৩২'); // false
|
|
620
|
+
* BanglaCalendar.isBanglaDate('০'); // false
|
|
621
|
+
*/
|
|
622
|
+
static isBanglaDate(value: unknown): value is BanglaDate;
|
|
623
|
+
/**
|
|
624
|
+
* @static Checks whether a value is a valid Bangla date of month in Latin digits (`1–31`).
|
|
625
|
+
*
|
|
626
|
+
* @param value - Value to check
|
|
627
|
+
* @returns `true` if the value is a valid Bangla date, `false` otherwise
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* BanglaCalendar.isBanglaDateEn(1); // true
|
|
631
|
+
* BanglaCalendar.isBanglaDateEn(31); // true
|
|
632
|
+
* BanglaCalendar.isBanglaDateEn(32); // false
|
|
633
|
+
* BanglaCalendar.isBanglaDateEn(0); // false
|
|
634
|
+
*/
|
|
635
|
+
static isBanglaDateEn(value: unknown): value is NumberRange<1, 31>;
|
|
636
|
+
/**
|
|
637
|
+
* @static Checks whether a string follows the Bangla date format pattern (`YYYY-MM-DD` with Bangla digits).
|
|
638
|
+
*
|
|
639
|
+
* @param value - String value to check
|
|
640
|
+
* @returns `true` if the string matches the pattern `"বছর-মাস-দিন"` with Bangla digits, `false` otherwise
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* BanglaCalendar.isBanglaDateString('১৪৩০-০১-০১'); // true
|
|
644
|
+
* BanglaCalendar.isBanglaDateString('1430-01-01'); // false (Latin digits)
|
|
645
|
+
* BanglaCalendar.isBanglaDateString('১৪৩০-১-১'); // true (single-digit month/date)
|
|
646
|
+
* BanglaCalendar.isBanglaDateString('১৪৩০-১৩-০১'); // false (invalid month)
|
|
647
|
+
*
|
|
648
|
+
* @remarks
|
|
649
|
+
* - Accepts both zero-padded and non-padded Bangla digits
|
|
650
|
+
* - Validates year, month, and date components separately
|
|
651
|
+
* - Year must be `০-৯৯৯৯`, month must be `১-১২`, date must be `১-৩১`
|
|
652
|
+
*/
|
|
653
|
+
static isBanglaDateString(value: unknown): value is string;
|
|
654
|
+
}
|
|
655
|
+
//#endregion
|
|
656
|
+
export { BanglaCalendar, BanglaCalendar as BnCalendar, BanglaCalendar as Bongabdo };
|