bangla-stdlib 1.0.2 → 1.0.3
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1162 -1110
- package/dist/index.d.ts +1162 -1110
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,15 @@ declare const BANGLA_WEEKDAYS: readonly ["রবিবার", "সোমবা
|
|
|
7
7
|
|
|
8
8
|
declare const BANGLA_SEASONS: readonly ["গ্রীষ্ম", "বর্ষা", "শরৎ", "হেমন্ত", "শীত", "বসন্ত"];
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Phone operator constants for Bangladesh
|
|
12
|
+
*/
|
|
13
|
+
declare const VALID_OPERATOR_CODES: readonly ["013", "014", "015", "016", "017", "018", "019"];
|
|
14
|
+
declare const OPERATOR_INFO: Record<string, {
|
|
15
|
+
name: string;
|
|
16
|
+
nameBangla: string;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
10
19
|
/**
|
|
11
20
|
* Converts English/Arabic digits to Bangla digits.
|
|
12
21
|
*
|
|
@@ -195,9 +204,62 @@ declare function fromBanglaNumber(input: string): number;
|
|
|
195
204
|
declare function toWords(number: number): string;
|
|
196
205
|
|
|
197
206
|
/**
|
|
198
|
-
*
|
|
207
|
+
* Common separator characters used in formatting
|
|
208
|
+
*/
|
|
209
|
+
type Separator = ',' | ' ' | '-' | '.';
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Centralized option interfaces for all formatting and conversion functions
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Base formatting options shared across modules
|
|
217
|
+
*/
|
|
218
|
+
interface BaseFormatOptions {
|
|
219
|
+
/**
|
|
220
|
+
* Whether to use Bangla digits (০-৯) instead of English digits (0-9)
|
|
221
|
+
* @default true
|
|
222
|
+
*/
|
|
223
|
+
useBanglaDigits?: boolean;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Number formatting options
|
|
227
|
+
*/
|
|
228
|
+
interface NumberFormatOptions extends BaseFormatOptions {
|
|
229
|
+
/**
|
|
230
|
+
* Separator character for thousands
|
|
231
|
+
* @default ','
|
|
232
|
+
*/
|
|
233
|
+
separator?: Separator;
|
|
234
|
+
/**
|
|
235
|
+
* Minimum number of fraction digits
|
|
236
|
+
* @default undefined
|
|
237
|
+
*/
|
|
238
|
+
minimumFractionDigits?: number;
|
|
239
|
+
/**
|
|
240
|
+
* Maximum number of fraction digits
|
|
241
|
+
* @default undefined
|
|
242
|
+
*/
|
|
243
|
+
maximumFractionDigits?: number;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Formats a number with comma separators using Indian/Bangla numbering system
|
|
248
|
+
* Pattern: rightmost 3 digits, then groups of 2 digits
|
|
249
|
+
* @param number - The number to format
|
|
250
|
+
* @param options - Formatting options
|
|
251
|
+
* @returns Formatted number string
|
|
252
|
+
* @example
|
|
253
|
+
* formatNumber(1234567) // '12,34,567'
|
|
254
|
+
* formatNumber(1234567.89) // '12,34,567.89'
|
|
255
|
+
* formatNumber(1234567, { useBanglaDigits: false }) // '12,34,567'
|
|
256
|
+
*/
|
|
257
|
+
declare function formatNumber(number: number | string, options?: NumberFormatOptions): string;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Formats large numbers with Bangla unit names (হাজার, লক্ষ, কোটি).
|
|
199
261
|
*
|
|
200
|
-
* This function simplifies large numbers by expressing them in common
|
|
262
|
+
* This function simplifies large numbers by expressing them in common Bangla units:
|
|
201
263
|
* - হাজার (Thousand): 1,000
|
|
202
264
|
* - লক্ষ (Lakh): 100,000
|
|
203
265
|
* - কোটি (Crore): 10,000,000
|
|
@@ -265,25 +327,10 @@ declare function formatWithUnits(number: number, options?: {
|
|
|
265
327
|
useBanglaDigits?: boolean;
|
|
266
328
|
}): string;
|
|
267
329
|
|
|
268
|
-
interface FormatNumberOptions {
|
|
269
|
-
/** Whether to use Bangla digits (default: true) */
|
|
270
|
-
useBanglaDigits?: boolean;
|
|
271
|
-
/** Separator character for thousands (default: ',') */
|
|
272
|
-
separator?: string;
|
|
273
|
-
}
|
|
274
330
|
/**
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* @param number - The number to format
|
|
278
|
-
* @param options - Formatting options
|
|
279
|
-
* @returns Formatted number string
|
|
280
|
-
* @example
|
|
281
|
-
* formatNumber(1234567) // '12,34,567'
|
|
282
|
-
* formatNumber(1234567.89) // '12,34,567.89'
|
|
283
|
-
* formatNumber(1234567, { useBanglaDigits: false }) // '12,34,567'
|
|
331
|
+
* Number validation functions
|
|
332
|
+
* Uses core validation utilities where applicable while maintaining domain-specific logic
|
|
284
333
|
*/
|
|
285
|
-
declare function formatNumber(number: number | string, options?: FormatNumberOptions): string;
|
|
286
|
-
|
|
287
334
|
/**
|
|
288
335
|
* Validates if a string contains a valid Bangla number.
|
|
289
336
|
*
|
|
@@ -390,104 +437,63 @@ declare function isValidNumberForOrdinal(input: number): boolean;
|
|
|
390
437
|
declare function sanitizeNumberInput(input: string): string;
|
|
391
438
|
|
|
392
439
|
/**
|
|
393
|
-
* Result
|
|
440
|
+
* Result types for batch operations and multi-value returns
|
|
394
441
|
*/
|
|
395
|
-
|
|
396
|
-
|
|
442
|
+
/**
|
|
443
|
+
* Generic batch processing result
|
|
444
|
+
* Used by batch conversion, validation, and formatting operations
|
|
445
|
+
*/
|
|
446
|
+
interface BatchResult<TInput, TOutput> {
|
|
447
|
+
/** Successfully processed items */
|
|
397
448
|
success: Array<{
|
|
398
|
-
input:
|
|
399
|
-
output:
|
|
449
|
+
input: TInput;
|
|
450
|
+
output: TOutput;
|
|
400
451
|
}>;
|
|
401
|
-
/** Failed
|
|
452
|
+
/** Failed items with error messages */
|
|
402
453
|
errors: Array<{
|
|
403
|
-
input:
|
|
454
|
+
input: TInput;
|
|
404
455
|
error: string;
|
|
405
456
|
}>;
|
|
406
457
|
}
|
|
458
|
+
|
|
407
459
|
/**
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
*
|
|
460
|
+
* Generic range validation utilities
|
|
461
|
+
* Used across number, date, time, month, weekday, and other modules
|
|
462
|
+
*/
|
|
463
|
+
/**
|
|
464
|
+
* Check if a number is within a specified range (inclusive)
|
|
413
465
|
*
|
|
414
|
-
* @param
|
|
415
|
-
* @
|
|
466
|
+
* @param value - Number to check
|
|
467
|
+
* @param min - Minimum value (inclusive)
|
|
468
|
+
* @param max - Maximum value (inclusive)
|
|
469
|
+
* @returns true if value is in range
|
|
470
|
+
*/
|
|
471
|
+
declare function isNumberInRange$1(value: number, min: number, max: number): boolean;
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Converts multiple numbers to Bangla in a single operation.
|
|
416
475
|
*
|
|
417
|
-
*
|
|
418
|
-
* ```typescript
|
|
419
|
-
* const results = batchToBanglaNumber([123, '456', 'invalid', 789]);
|
|
420
|
-
* console.log(results.success);
|
|
421
|
-
* // [
|
|
422
|
-
* // { input: 123, output: '১২৩' },
|
|
423
|
-
* // { input: '456', output: '৪৫৬' },
|
|
424
|
-
* // { input: 789, output: '৭৮৯' }
|
|
425
|
-
* // ]
|
|
426
|
-
* console.log(results.errors);
|
|
427
|
-
* // [{ input: 'invalid', error: 'Invalid character in number: i' }]
|
|
428
|
-
* ```
|
|
476
|
+
* Uses the core batch processor pattern to eliminate duplication.
|
|
429
477
|
*/
|
|
430
|
-
declare
|
|
478
|
+
declare const batchToBanglaNumber: (inputs: (string | number)[]) => BatchResult<string | number, string>;
|
|
431
479
|
/**
|
|
432
480
|
* Converts multiple Bangla numbers to JavaScript numbers in a single operation.
|
|
433
481
|
*
|
|
434
|
-
*
|
|
435
|
-
* @returns Object containing successful conversions and errors
|
|
436
|
-
*
|
|
437
|
-
* @example
|
|
438
|
-
* ```typescript
|
|
439
|
-
* const results = batchFromBanglaNumber(['১২৩', '৪৫৬', 'invalid']);
|
|
440
|
-
* console.log(results.success);
|
|
441
|
-
* // [
|
|
442
|
-
* // { input: '১২৩', output: 123 },
|
|
443
|
-
* // { input: '৪৫৬', output: 456 }
|
|
444
|
-
* // ]
|
|
445
|
-
* console.log(results.errors);
|
|
446
|
-
* // [{ input: 'invalid', error: 'Invalid Bangla digit: i' }]
|
|
447
|
-
* ```
|
|
482
|
+
* Uses the core batch processor pattern to eliminate duplication.
|
|
448
483
|
*/
|
|
449
|
-
declare
|
|
450
|
-
success: Array<{
|
|
451
|
-
input: string;
|
|
452
|
-
output: number;
|
|
453
|
-
}>;
|
|
454
|
-
errors: Array<{
|
|
455
|
-
input: string;
|
|
456
|
-
error: string;
|
|
457
|
-
}>;
|
|
458
|
-
};
|
|
484
|
+
declare const batchFromBanglaNumber: (inputs: string[]) => BatchResult<string, number>;
|
|
459
485
|
/**
|
|
460
486
|
* Safely converts a number to Bangla with a fallback value.
|
|
461
487
|
*
|
|
462
|
-
*
|
|
463
|
-
* even if the conversion fails.
|
|
464
|
-
*
|
|
465
|
-
* @param input - The number or string to convert
|
|
466
|
-
* @param fallback - Value to return if conversion fails (default: '')
|
|
467
|
-
* @returns Bangla number string or fallback value
|
|
468
|
-
*
|
|
469
|
-
* @example
|
|
470
|
-
* ```typescript
|
|
471
|
-
* safeToBanglaNumber(123); // '১২৩'
|
|
472
|
-
* safeToBanglaNumber(NaN, '---'); // '---'
|
|
473
|
-
* safeToBanglaNumber(Infinity, 'N/A'); // 'N/A'
|
|
474
|
-
* ```
|
|
488
|
+
* Uses the core safe wrapper pattern to eliminate duplication.
|
|
475
489
|
*/
|
|
476
|
-
declare
|
|
490
|
+
declare const safeToBanglaNumber: (input: string | number, fallback?: string | undefined) => string;
|
|
477
491
|
/**
|
|
478
492
|
* Safely converts a Bangla number to a JavaScript number with a fallback.
|
|
479
493
|
*
|
|
480
|
-
*
|
|
481
|
-
* @param fallback - Value to return if conversion fails (default: 0)
|
|
482
|
-
* @returns JavaScript number or fallback value
|
|
483
|
-
*
|
|
484
|
-
* @example
|
|
485
|
-
* ```typescript
|
|
486
|
-
* safeFromBanglaNumber('১২৩'); // 123
|
|
487
|
-
* safeFromBanglaNumber('invalid', -1); // -1
|
|
488
|
-
* ```
|
|
494
|
+
* Uses the core safe wrapper pattern to eliminate duplication.
|
|
489
495
|
*/
|
|
490
|
-
declare
|
|
496
|
+
declare const safeFromBanglaNumber: (input: string, fallback?: number | undefined) => number;
|
|
491
497
|
/**
|
|
492
498
|
* Parses user input with sanitization and conversion to Bangla.
|
|
493
499
|
*
|
|
@@ -523,7 +529,7 @@ declare function parseAndConvertToBangla(input: string): string;
|
|
|
523
529
|
* formatAndConvert(1234567, true, ' '); // '১২ ৩৪ ৫৬৭'
|
|
524
530
|
* ```
|
|
525
531
|
*/
|
|
526
|
-
declare function formatAndConvert(input: number, useBanglaDigits?: boolean, separator?:
|
|
532
|
+
declare function formatAndConvert(input: number, useBanglaDigits?: boolean, separator?: Separator): string;
|
|
527
533
|
/**
|
|
528
534
|
* Converts a number to its word representation and also provides the Bangla digit form.
|
|
529
535
|
*
|
|
@@ -551,8 +557,7 @@ declare function convertToWordsAndDigits(input: number): {
|
|
|
551
557
|
/**
|
|
552
558
|
* Range validation: checks if a number is within a specified range.
|
|
553
559
|
*
|
|
554
|
-
*
|
|
555
|
-
* must fall within certain bounds.
|
|
560
|
+
* Re-exported from core validation utilities for convenience.
|
|
556
561
|
*
|
|
557
562
|
* @param value - The number to check
|
|
558
563
|
* @param min - Minimum allowed value (inclusive)
|
|
@@ -566,7 +571,7 @@ declare function convertToWordsAndDigits(input: number): {
|
|
|
566
571
|
* isNumberInRange(-5, 0, 100); // false
|
|
567
572
|
* ```
|
|
568
573
|
*/
|
|
569
|
-
declare
|
|
574
|
+
declare const isNumberInRange: typeof isNumberInRange$1;
|
|
570
575
|
/**
|
|
571
576
|
* Truncates a number to a specified number of decimal places without rounding.
|
|
572
577
|
*
|
|
@@ -588,7 +593,7 @@ declare function truncateDecimals(value: number, decimals?: number): number;
|
|
|
588
593
|
/**
|
|
589
594
|
* Formats a number as Bangladeshi Taka currency in Bangla.
|
|
590
595
|
*
|
|
591
|
-
* This function converts numeric currency amounts to
|
|
596
|
+
* This function converts numeric currency amounts to Bangla format with
|
|
592
597
|
* the Taka symbol (৳) and/or word (টাকা). Amounts are automatically formatted
|
|
593
598
|
* to 2 decimal places.
|
|
594
599
|
*
|
|
@@ -689,7 +694,7 @@ declare function formatCurrency(amount: number | string, options?: {
|
|
|
689
694
|
/**
|
|
690
695
|
* Parses a Bangla currency string to a number.
|
|
691
696
|
*
|
|
692
|
-
* This function extracts numeric values from
|
|
697
|
+
* This function extracts numeric values from Bangla currency strings,
|
|
693
698
|
* automatically removing currency symbols (৳) and words (টাকা).
|
|
694
699
|
* It supports various formatting styles commonly used in Bangladesh.
|
|
695
700
|
*
|
|
@@ -938,63 +943,9 @@ declare function hasTakaSymbol(value: string): boolean;
|
|
|
938
943
|
declare function hasTakaWord(value: string): boolean;
|
|
939
944
|
|
|
940
945
|
/**
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
* Unlike formatCurrency, this function doesn't throw errors for invalid inputs.
|
|
944
|
-
* Instead, it returns the fallback value.
|
|
945
|
-
*
|
|
946
|
-
* @param amount - The amount to format
|
|
947
|
-
* @param options - Formatting options
|
|
948
|
-
* @param fallback - Value to return if formatting fails (default: '')
|
|
949
|
-
* @returns Formatted currency string or fallback value
|
|
950
|
-
*
|
|
951
|
-
* @example
|
|
952
|
-
* ```typescript
|
|
953
|
-
* safeFormatCurrency(1234.56); // '৳ ১২৩৪.৫৬'
|
|
954
|
-
* safeFormatCurrency(NaN); // ''
|
|
955
|
-
* safeFormatCurrency(Infinity, {}, 'N/A'); // 'N/A'
|
|
956
|
-
* safeFormatCurrency(100, { includeWord: true }); // '৳ ১০০.০০ টাকা'
|
|
957
|
-
* ```
|
|
958
|
-
*/
|
|
959
|
-
declare function safeFormatCurrency(amount: number | string, options?: {
|
|
960
|
-
includeSymbol?: boolean;
|
|
961
|
-
includeWord?: boolean;
|
|
962
|
-
}, fallback?: string): string;
|
|
963
|
-
/**
|
|
964
|
-
* Safely parses a currency string with a fallback value.
|
|
965
|
-
*
|
|
966
|
-
* @param currencyString - The currency string to parse
|
|
967
|
-
* @param fallback - Value to return if parsing fails (default: 0)
|
|
968
|
-
* @returns Parsed amount or fallback value
|
|
969
|
-
*
|
|
970
|
-
* @example
|
|
971
|
-
* ```typescript
|
|
972
|
-
* safeParseCurrency('৳ ১২৩৪.৫৬'); // 1234.56
|
|
973
|
-
* safeParseCurrency('invalid'); // 0
|
|
974
|
-
* safeParseCurrency('invalid', -1); // -1
|
|
975
|
-
* ```
|
|
976
|
-
*/
|
|
977
|
-
declare function safeParseCurrency(currencyString: string, fallback?: number): number;
|
|
978
|
-
/**
|
|
979
|
-
* Formats an array of currency amounts.
|
|
980
|
-
*
|
|
981
|
-
* @param amounts - Array of amounts to format
|
|
982
|
-
* @param options - Formatting options
|
|
983
|
-
* @returns Array of formatted currency strings (invalid amounts are skipped)
|
|
984
|
-
*
|
|
985
|
-
* @example
|
|
986
|
-
* ```typescript
|
|
987
|
-
* batchFormatCurrency([100, 200, 300]);
|
|
988
|
-
* // ['৳ ১০০.০০', '৳ ২০০.০০', '৳ ৩০০.০০']
|
|
989
|
-
*
|
|
990
|
-
* batchFormatCurrency([100, NaN, 200], { includeWord: true });
|
|
991
|
-
* // ['৳ ১০০.০০ টাকা', '৳ ২০০.০০ টাকা']
|
|
992
|
-
* ```
|
|
946
|
+
* Currency arithmetic operations
|
|
947
|
+
* Basic mathematical operations with proper rounding
|
|
993
948
|
*/
|
|
994
|
-
declare function batchFormatCurrency(amounts: number[], options?: {
|
|
995
|
-
includeSymbol?: boolean;
|
|
996
|
-
includeWord?: boolean;
|
|
997
|
-
}): string[];
|
|
998
949
|
/**
|
|
999
950
|
* Rounds a currency amount to a specified number of decimal places.
|
|
1000
951
|
*
|
|
@@ -1025,6 +976,20 @@ declare function roundCurrency(amount: number, decimals?: number): number;
|
|
|
1025
976
|
* ```
|
|
1026
977
|
*/
|
|
1027
978
|
declare function sumCurrency(amounts: number[]): number;
|
|
979
|
+
/**
|
|
980
|
+
* Adds two currency amounts.
|
|
981
|
+
*
|
|
982
|
+
* @param amount1 - First amount
|
|
983
|
+
* @param amount2 - Second amount
|
|
984
|
+
* @returns Sum rounded to 2 decimal places
|
|
985
|
+
*
|
|
986
|
+
* @example
|
|
987
|
+
* ```typescript
|
|
988
|
+
* addCurrency(100, 200); // 300
|
|
989
|
+
* addCurrency(123.45, 67.89); // 191.34
|
|
990
|
+
* ```
|
|
991
|
+
*/
|
|
992
|
+
declare function addCurrency(amount1: number, amount2: number): number;
|
|
1028
993
|
/**
|
|
1029
994
|
* Calculates the difference between two currency amounts.
|
|
1030
995
|
*
|
|
@@ -1072,6 +1037,11 @@ declare function multiplyCurrency(amount: number, factor: number): number;
|
|
|
1072
1037
|
* ```
|
|
1073
1038
|
*/
|
|
1074
1039
|
declare function divideCurrency(amount: number, divisor: number): number;
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Currency percentage operations
|
|
1043
|
+
* Tax, discount, and percentage calculations
|
|
1044
|
+
*/
|
|
1075
1045
|
/**
|
|
1076
1046
|
* Calculates a percentage of a currency amount.
|
|
1077
1047
|
*
|
|
@@ -1117,6 +1087,40 @@ declare function applyDiscount(amount: number, discountPercent: number): number;
|
|
|
1117
1087
|
* ```
|
|
1118
1088
|
*/
|
|
1119
1089
|
declare function addTax(amount: number, taxPercent: number): number;
|
|
1090
|
+
/**
|
|
1091
|
+
* Calculates the tax amount only (without adding to base).
|
|
1092
|
+
*
|
|
1093
|
+
* This is an alias for calculatePercentage but with clearer naming for tax calculations.
|
|
1094
|
+
*
|
|
1095
|
+
* @param amount - The base amount
|
|
1096
|
+
* @param taxPercent - Tax percentage
|
|
1097
|
+
* @returns Tax amount rounded to 2 decimal places
|
|
1098
|
+
*
|
|
1099
|
+
* @example
|
|
1100
|
+
* ```typescript
|
|
1101
|
+
* calculateTax(1000, 15); // 150
|
|
1102
|
+
* calculateTax(500, 10); // 50
|
|
1103
|
+
* ```
|
|
1104
|
+
*/
|
|
1105
|
+
declare function calculateTax(amount: number, taxPercent: number): number;
|
|
1106
|
+
/**
|
|
1107
|
+
* Calculates the discount amount only (without subtracting from base).
|
|
1108
|
+
*
|
|
1109
|
+
* @param amount - The base amount
|
|
1110
|
+
* @param discountPercent - Discount percentage
|
|
1111
|
+
* @returns Discount amount rounded to 2 decimal places
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```typescript
|
|
1115
|
+
* calculateDiscount(1000, 10); // 100
|
|
1116
|
+
* calculateDiscount(500, 25); // 125
|
|
1117
|
+
* ```
|
|
1118
|
+
*/
|
|
1119
|
+
declare function calculateDiscount(amount: number, discountPercent: number): number;
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Currency rounding and splitting operations
|
|
1123
|
+
*/
|
|
1120
1124
|
/**
|
|
1121
1125
|
* Splits a currency amount into equal parts.
|
|
1122
1126
|
*
|
|
@@ -1132,9 +1136,86 @@ declare function addTax(amount: number, taxPercent: number): number;
|
|
|
1132
1136
|
* ```
|
|
1133
1137
|
*/
|
|
1134
1138
|
declare function splitAmount(amount: number, parts: number): number[];
|
|
1139
|
+
/**
|
|
1140
|
+
* Rounds up a currency amount to the nearest whole number.
|
|
1141
|
+
*
|
|
1142
|
+
* @param amount - The amount to round up
|
|
1143
|
+
* @returns Rounded up amount
|
|
1144
|
+
*
|
|
1145
|
+
* @example
|
|
1146
|
+
* ```typescript
|
|
1147
|
+
* ceilCurrency(123.01); // 124.00
|
|
1148
|
+
* ceilCurrency(123.99); // 124.00
|
|
1149
|
+
* ceilCurrency(123); // 123.00
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
1152
|
+
declare function ceilCurrency(amount: number): number;
|
|
1153
|
+
/**
|
|
1154
|
+
* Rounds down a currency amount to the nearest whole number.
|
|
1155
|
+
*
|
|
1156
|
+
* @param amount - The amount to round down
|
|
1157
|
+
* @returns Rounded down amount
|
|
1158
|
+
*
|
|
1159
|
+
* @example
|
|
1160
|
+
* ```typescript
|
|
1161
|
+
* floorCurrency(123.99); // 123.00
|
|
1162
|
+
* floorCurrency(123.01); // 123.00
|
|
1163
|
+
* floorCurrency(123); // 123.00
|
|
1164
|
+
* ```
|
|
1165
|
+
*/
|
|
1166
|
+
declare function floorCurrency(amount: number): number;
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Currency utility functions
|
|
1170
|
+
* Domain-specific utilities using core patterns
|
|
1171
|
+
*/
|
|
1172
|
+
/**
|
|
1173
|
+
* Safely formats a currency amount with a fallback value.
|
|
1174
|
+
*
|
|
1175
|
+
* @param amount - The amount to format (number or string)
|
|
1176
|
+
* @param options - Formatting options
|
|
1177
|
+
* @param fallback - Value to return if formatting fails (default: '')
|
|
1178
|
+
* @returns Formatted currency string or fallback value
|
|
1179
|
+
*/
|
|
1180
|
+
declare function safeFormatCurrency(amount: number | string, options?: {
|
|
1181
|
+
includeSymbol?: boolean;
|
|
1182
|
+
includeWord?: boolean;
|
|
1183
|
+
}, fallback?: string): string;
|
|
1184
|
+
/**
|
|
1185
|
+
* Safely parses a currency string with a fallback value.
|
|
1186
|
+
*
|
|
1187
|
+
* @param currencyString - The currency string to parse
|
|
1188
|
+
* @param fallback - Value to return if parsing fails (default: 0)
|
|
1189
|
+
* @returns Parsed amount or fallback value
|
|
1190
|
+
*/
|
|
1191
|
+
declare function safeParseCurrency(currencyString: string, fallback?: number): number;
|
|
1192
|
+
/**
|
|
1193
|
+
* Formats an array of currency amounts.
|
|
1194
|
+
*
|
|
1195
|
+
* Uses core validating batch processor to eliminate duplication.
|
|
1196
|
+
*
|
|
1197
|
+
* @param amounts - Array of amounts to format
|
|
1198
|
+
* @param options - Formatting options
|
|
1199
|
+
* @returns Array of formatted currency strings (invalid amounts are skipped)
|
|
1200
|
+
*
|
|
1201
|
+
* @example
|
|
1202
|
+
* ```typescript
|
|
1203
|
+
* batchFormatCurrency([100, 200, 300]);
|
|
1204
|
+
* // ['১০০ টাকা', '২০০ টাকা', '৩০০ টাকা']
|
|
1205
|
+
*
|
|
1206
|
+
* batchFormatCurrency([100, NaN, 200], { symbol: true });
|
|
1207
|
+
* // ['৳১০০', '৳২০০']
|
|
1208
|
+
* ```
|
|
1209
|
+
*/
|
|
1210
|
+
declare function batchFormatCurrency(amounts: number[], options?: {
|
|
1211
|
+
includeSymbol?: boolean;
|
|
1212
|
+
includeWord?: boolean;
|
|
1213
|
+
}): string[];
|
|
1135
1214
|
/**
|
|
1136
1215
|
* Compares two currency amounts.
|
|
1137
1216
|
*
|
|
1217
|
+
* Uses core currency comparator to eliminate duplication.
|
|
1218
|
+
*
|
|
1138
1219
|
* @param amount1 - First amount
|
|
1139
1220
|
* @param amount2 - Second amount
|
|
1140
1221
|
* @returns -1 if amount1 < amount2, 0 if equal, 1 if amount1 > amount2
|
|
@@ -1188,9 +1269,9 @@ declare function negateAmount(amount: number): number;
|
|
|
1188
1269
|
*
|
|
1189
1270
|
* @example
|
|
1190
1271
|
* ```typescript
|
|
1191
|
-
* parseAndFormatCurrency('1234.56'); // '
|
|
1192
|
-
* parseAndFormatCurrency(' 500 ', {
|
|
1193
|
-
* parseAndFormatCurrency(100); // '
|
|
1272
|
+
* parseAndFormatCurrency('1234.56'); // '১২৩৪.৫৬ টাকা'
|
|
1273
|
+
* parseAndFormatCurrency(' 500 ', { symbol: true }); // '৳৫০০'
|
|
1274
|
+
* parseAndFormatCurrency(100); // '১০০ টাকা'
|
|
1194
1275
|
* parseAndFormatCurrency('invalid'); // throws Error
|
|
1195
1276
|
* ```
|
|
1196
1277
|
*/
|
|
@@ -1198,97 +1279,84 @@ declare function parseAndFormatCurrency(value: any, options?: {
|
|
|
1198
1279
|
includeSymbol?: boolean;
|
|
1199
1280
|
includeWord?: boolean;
|
|
1200
1281
|
}): string;
|
|
1201
|
-
|
|
1202
1282
|
/**
|
|
1203
|
-
*
|
|
1283
|
+
* Checks if two currency amounts are equal (after rounding).
|
|
1284
|
+
*
|
|
1285
|
+
* @param amount1 - First amount
|
|
1286
|
+
* @param amount2 - Second amount
|
|
1287
|
+
* @returns true if amounts are equal after rounding to 2 decimals
|
|
1288
|
+
*
|
|
1289
|
+
* @example
|
|
1290
|
+
* ```typescript
|
|
1291
|
+
* isCurrencyEqual(100, 100); // true
|
|
1292
|
+
* isCurrencyEqual(100.001, 100.002); // true (both round to 100.00)
|
|
1293
|
+
* isCurrencyEqual(100, 100.01); // false
|
|
1294
|
+
* ```
|
|
1295
|
+
*/
|
|
1296
|
+
declare function isCurrencyEqual(amount1: number, amount2: number): boolean;
|
|
1297
|
+
/**
|
|
1298
|
+
* Checks if first amount is greater than second (after rounding).
|
|
1204
1299
|
*
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1300
|
+
* @param amount1 - First amount
|
|
1301
|
+
* @param amount2 - Second amount
|
|
1302
|
+
* @returns true if amount1 > amount2
|
|
1207
1303
|
*
|
|
1208
|
-
*
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* ```typescript
|
|
1306
|
+
* isGreaterThan(200, 100); // true
|
|
1307
|
+
* isGreaterThan(100, 200); // false
|
|
1308
|
+
* isGreaterThan(100, 100); // false
|
|
1309
|
+
* ```
|
|
1310
|
+
*/
|
|
1311
|
+
declare function isGreaterThan(amount1: number, amount2: number): boolean;
|
|
1312
|
+
/**
|
|
1313
|
+
* Checks if first amount is less than second (after rounding).
|
|
1211
1314
|
*
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1315
|
+
* @param amount1 - First amount
|
|
1316
|
+
* @param amount2 - Second amount
|
|
1317
|
+
* @returns true if amount1 < amount2
|
|
1215
1318
|
*
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
|
|
1223
|
-
|
|
1319
|
+
* @example
|
|
1320
|
+
* ```typescript
|
|
1321
|
+
* isLessThan(100, 200); // true
|
|
1322
|
+
* isLessThan(200, 100); // false
|
|
1323
|
+
* isLessThan(100, 100); // false
|
|
1324
|
+
* ```
|
|
1325
|
+
*/
|
|
1326
|
+
declare function isLessThan(amount1: number, amount2: number): boolean;
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* Formats a Gregorian date using the Bangla calendar with Bangla digits, month names, and weekdays.
|
|
1330
|
+
*
|
|
1331
|
+
* This function converts a JavaScript Date object to the Bangla calendar and
|
|
1332
|
+
* formats it using Bangla digits, Bangla month names, and Bangla weekday names.
|
|
1224
1333
|
*
|
|
1225
1334
|
* @param date - Date object to format
|
|
1226
1335
|
* @param options - Formatting options
|
|
1227
1336
|
* @param options.includeWeekday - Include weekday name (default: false)
|
|
1228
1337
|
* @param options.includeYear - Include year (default: true)
|
|
1229
1338
|
* @param options.format - Format style: 'short' or 'long' (default: 'long')
|
|
1230
|
-
* @returns Formatted date string in Bangla
|
|
1339
|
+
* @returns Formatted date string in Bangla calendar
|
|
1231
1340
|
*
|
|
1232
1341
|
* @example
|
|
1233
|
-
* Basic formatting
|
|
1342
|
+
* Basic formatting:
|
|
1234
1343
|
* ```typescript
|
|
1235
|
-
* formatDate(new Date(2024,
|
|
1236
|
-
* // "
|
|
1344
|
+
* formatDate(new Date(2024, 3, 14));
|
|
1345
|
+
* // "১ বৈশাখ ১৪৩১" (Pohela Boishakh)
|
|
1237
1346
|
* ```
|
|
1238
1347
|
*
|
|
1239
1348
|
* @example
|
|
1240
1349
|
* Without year:
|
|
1241
1350
|
* ```typescript
|
|
1242
|
-
* formatDate(new Date(2024,
|
|
1243
|
-
* // "
|
|
1351
|
+
* formatDate(new Date(2024, 3, 14), { includeYear: false });
|
|
1352
|
+
* // "১ বৈশাখ"
|
|
1244
1353
|
* ```
|
|
1245
1354
|
*
|
|
1246
1355
|
* @example
|
|
1247
1356
|
* With weekday:
|
|
1248
1357
|
* ```typescript
|
|
1249
|
-
* formatDate(new Date(2024,
|
|
1250
|
-
* // "
|
|
1251
|
-
* ```
|
|
1252
|
-
*
|
|
1253
|
-
* @example
|
|
1254
|
-
* Short format:
|
|
1255
|
-
* ```typescript
|
|
1256
|
-
* formatDate(new Date(2024, 0, 15), { format: 'short' });
|
|
1257
|
-
* // "১৫ বৈশাখ ২০২৪"
|
|
1258
|
-
* ```
|
|
1259
|
-
*
|
|
1260
|
-
* @example
|
|
1261
|
-
* All options combined:
|
|
1262
|
-
* ```typescript
|
|
1263
|
-
* formatDate(
|
|
1264
|
-
* new Date(2024, 0, 15),
|
|
1265
|
-
* { includeWeekday: true, includeYear: false, format: 'short' }
|
|
1266
|
-
* );
|
|
1267
|
-
* // "সোমবার ১৫ বৈশাখ"
|
|
1268
|
-
* ```
|
|
1269
|
-
*
|
|
1270
|
-
* @example
|
|
1271
|
-
* Display current date:
|
|
1272
|
-
* ```typescript
|
|
1273
|
-
* const today = formatDate(new Date(), { includeWeekday: true });
|
|
1274
|
-
* console.log(`আজ: ${today}`);
|
|
1275
|
-
* // "আজ: মঙ্গলবার ৭ পৌষ ২০২৫" (example)
|
|
1276
|
-
* ```
|
|
1277
|
-
*
|
|
1278
|
-
* @example
|
|
1279
|
-
* Event list formatting:
|
|
1280
|
-
* ```typescript
|
|
1281
|
-
* const events = [
|
|
1282
|
-
* new Date(2024, 3, 14),
|
|
1283
|
-
* new Date(2024, 11, 16),
|
|
1284
|
-
* new Date(2025, 1, 21)
|
|
1285
|
-
* ];
|
|
1286
|
-
* events.forEach(event => {
|
|
1287
|
-
* console.log(formatDate(event, { includeWeekday: true, includeYear: false }));
|
|
1288
|
-
* });
|
|
1289
|
-
* // "রবিবার ১৪ শ্রাবণ"
|
|
1290
|
-
* // "সোমবার ১৬ চৈত্র"
|
|
1291
|
-
* // "শুক্রবার ২১ জ্যৈষ্ঠ"
|
|
1358
|
+
* formatDate(new Date(2024, 3, 14), { includeWeekday: true });
|
|
1359
|
+
* // "রবিবার ১ বৈশাখ ১৪৩১"
|
|
1292
1360
|
* ```
|
|
1293
1361
|
*/
|
|
1294
1362
|
declare function formatDate(date: Date, options?: {
|
|
@@ -1298,31 +1366,31 @@ declare function formatDate(date: Date, options?: {
|
|
|
1298
1366
|
}): string;
|
|
1299
1367
|
|
|
1300
1368
|
/**
|
|
1301
|
-
* Parses a
|
|
1369
|
+
* Parses a Bangla formatted date string into a JavaScript Date object.
|
|
1302
1370
|
*
|
|
1303
|
-
* This function supports multiple
|
|
1371
|
+
* This function supports multiple Bangla date formats with both Bangla
|
|
1304
1372
|
* and English digits. It handles month names and separator-based formats.
|
|
1305
1373
|
*
|
|
1306
1374
|
* **Supported Formats:**
|
|
1307
1375
|
* 1. Month name format: "day month [year]"
|
|
1308
|
-
* - "১৫ বৈশাখ ১৪৩১" (
|
|
1376
|
+
* - "১৫ বৈশাখ ১৪৩১" (Bangla digits)
|
|
1309
1377
|
* - "15 বৈশাখ 1431" (English digits)
|
|
1310
1378
|
* - "১৫ বৈশাখ" (without year, uses current year)
|
|
1311
1379
|
*
|
|
1312
1380
|
* 2. Separator format: "day/month/year" or "day-month-year"
|
|
1313
|
-
* - "১৫/০৪/২০২৪" (
|
|
1381
|
+
* - "১৫/০৪/২০২৪" (Bangla digits with slash)
|
|
1314
1382
|
* - "15-04-2024" (English digits with dash)
|
|
1315
|
-
* - "১৫/০৪/২০২৪" (mixed
|
|
1383
|
+
* - "১৫/০৪/২০২৪" (mixed Bangla/English)
|
|
1316
1384
|
*
|
|
1317
|
-
* **Note:** This parses to Gregorian dates with
|
|
1318
|
-
* For
|
|
1385
|
+
* **Note:** This parses to Gregorian dates with Bangla formatting.
|
|
1386
|
+
* For Bangla calendar date parsing, use the `calendar` module's `fromBangla` function.
|
|
1319
1387
|
*
|
|
1320
|
-
* @param dateString -
|
|
1388
|
+
* @param dateString - Bangla formatted date string
|
|
1321
1389
|
* @returns JavaScript Date object
|
|
1322
1390
|
* @throws {Error} If the date string cannot be parsed
|
|
1323
1391
|
*
|
|
1324
1392
|
* @example
|
|
1325
|
-
* Month name format with
|
|
1393
|
+
* Month name format with Bangla digits:
|
|
1326
1394
|
* ```typescript
|
|
1327
1395
|
* parseDate('১৫ বৈশাখ ১৪৩১');
|
|
1328
1396
|
* // Date object for the 15th day of month 1 (Boishakh) in year 1431
|
|
@@ -1343,7 +1411,7 @@ declare function formatDate(date: Date, options?: {
|
|
|
1343
1411
|
* ```
|
|
1344
1412
|
*
|
|
1345
1413
|
* @example
|
|
1346
|
-
* Separator format with
|
|
1414
|
+
* Separator format with Bangla digits:
|
|
1347
1415
|
* ```typescript
|
|
1348
1416
|
* parseDate('১৫/০৪/২০২৪');
|
|
1349
1417
|
* // Date object for April 15, 2024
|
|
@@ -1447,94 +1515,94 @@ declare function parseDate(dateString: string): Date;
|
|
|
1447
1515
|
*/
|
|
1448
1516
|
declare function isValidDate(date: Date): boolean;
|
|
1449
1517
|
/**
|
|
1450
|
-
* Checks if a string is a valid
|
|
1518
|
+
* Checks if a string is a valid Bangla date format.
|
|
1451
1519
|
*
|
|
1452
1520
|
* Valid formats include:
|
|
1453
|
-
* - "১৫ বৈশাখ ১৪৩১" (with
|
|
1521
|
+
* - "১৫ বৈশাখ ১৪৩১" (with Bangla digits and month name)
|
|
1454
1522
|
* - "১৫ বৈশাখ" (without year)
|
|
1455
1523
|
* - "15 বৈশাখ 1431" (with English digits and month name)
|
|
1456
|
-
* - "১৫/০৪/২০২৪" or "১৫-০৪-২০২৪" (
|
|
1524
|
+
* - "১৫/০৪/২০২৪" or "১৫-০৪-২০২৪" (Bangla digits with separators)
|
|
1457
1525
|
* - "15/04/2024" or "15-04-2024" (English digits with separators)
|
|
1458
1526
|
*
|
|
1459
1527
|
* @param dateString - String to validate
|
|
1460
|
-
* @returns true if string matches a valid
|
|
1528
|
+
* @returns true if string matches a valid Bangla date format, false otherwise
|
|
1461
1529
|
*
|
|
1462
1530
|
* @example
|
|
1463
1531
|
* Valid formats:
|
|
1464
1532
|
* ```typescript
|
|
1465
|
-
*
|
|
1466
|
-
*
|
|
1467
|
-
*
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1533
|
+
* isValidBanglaDateString('১৫ বৈশাখ ১৪৩১'); // true
|
|
1534
|
+
* isValidBanglaDateString('১৫ বৈশাখ'); // true
|
|
1535
|
+
* isValidBanglaDateString('15 বৈশাখ 1431'); // true
|
|
1536
|
+
* isValidBanglaDateString('১৫/০৪/২০২৪'); // true
|
|
1537
|
+
* isValidBanglaDateString('15-04-2024'); // true
|
|
1470
1538
|
* ```
|
|
1471
1539
|
*
|
|
1472
1540
|
* @example
|
|
1473
1541
|
* Invalid formats:
|
|
1474
1542
|
* ```typescript
|
|
1475
|
-
*
|
|
1476
|
-
*
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1543
|
+
* isValidBanglaDateString('invalid'); // false
|
|
1544
|
+
* isValidBanglaDateString('2024-01-15'); // false (ISO format not supported)
|
|
1545
|
+
* isValidBanglaDateString(''); // false
|
|
1546
|
+
* isValidBanglaDateString(' '); // false
|
|
1479
1547
|
* ```
|
|
1480
1548
|
*/
|
|
1481
|
-
declare function
|
|
1549
|
+
declare function isValidBanglaDateString(dateString: string): boolean;
|
|
1482
1550
|
/**
|
|
1483
|
-
* Checks if a string contains
|
|
1551
|
+
* Checks if a string contains Bangla digits.
|
|
1484
1552
|
*
|
|
1485
|
-
*
|
|
1553
|
+
* Bangla digits: ০ ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯
|
|
1486
1554
|
*
|
|
1487
1555
|
* @param text - String to check
|
|
1488
|
-
* @returns true if string contains at least one
|
|
1556
|
+
* @returns true if string contains at least one Bangla digit, false otherwise
|
|
1489
1557
|
*
|
|
1490
1558
|
* @example
|
|
1491
|
-
* Strings with
|
|
1559
|
+
* Strings with Bangla digits:
|
|
1492
1560
|
* ```typescript
|
|
1493
|
-
*
|
|
1494
|
-
*
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1561
|
+
* hasBanglaDigits('১৫'); // true
|
|
1562
|
+
* hasBanglaDigits('১৫ বৈশাখ'); // true
|
|
1563
|
+
* hasBanglaDigits('Today is ১৫ বৈশাখ'); // true
|
|
1564
|
+
* hasBanglaDigits('১'); // true
|
|
1497
1565
|
* ```
|
|
1498
1566
|
*
|
|
1499
1567
|
* @example
|
|
1500
|
-
* Strings without
|
|
1568
|
+
* Strings without Bangla digits:
|
|
1501
1569
|
* ```typescript
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
*
|
|
1505
|
-
*
|
|
1570
|
+
* hasBanglaDigits('15'); // false
|
|
1571
|
+
* hasBanglaDigits('বৈশাখ'); // false
|
|
1572
|
+
* hasBanglaDigits(''); // false
|
|
1573
|
+
* hasBanglaDigits('hello'); // false
|
|
1506
1574
|
* ```
|
|
1507
1575
|
*/
|
|
1508
|
-
declare function
|
|
1576
|
+
declare function hasBanglaDigits(text: string): boolean;
|
|
1509
1577
|
/**
|
|
1510
|
-
* Checks if a string contains a
|
|
1578
|
+
* Checks if a string contains a Bangla month name.
|
|
1511
1579
|
*
|
|
1512
1580
|
* Valid month names:
|
|
1513
1581
|
* বৈশাখ, জ্যৈষ্ঠ, আষাঢ়, শ্রাবণ, ভাদ্র, আশ্বিন,
|
|
1514
1582
|
* কার্তিক, অগ্রহায়ণ, পৌষ, মাঘ, ফাল্গুন, চৈত্র
|
|
1515
1583
|
*
|
|
1516
1584
|
* @param text - String to check
|
|
1517
|
-
* @returns true if string contains a
|
|
1585
|
+
* @returns true if string contains a Bangla month name, false otherwise
|
|
1518
1586
|
*
|
|
1519
1587
|
* @example
|
|
1520
1588
|
* Strings with month names:
|
|
1521
1589
|
* ```typescript
|
|
1522
|
-
*
|
|
1523
|
-
*
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1590
|
+
* hasBanglaMonth('১৫ বৈশাখ ১৪৩১'); // true
|
|
1591
|
+
* hasBanglaMonth('বৈশাখ'); // true
|
|
1592
|
+
* hasBanglaMonth('Today is বৈশাখ month'); // true
|
|
1593
|
+
* hasBanglaMonth('চৈত্র'); // true
|
|
1526
1594
|
* ```
|
|
1527
1595
|
*
|
|
1528
1596
|
* @example
|
|
1529
1597
|
* Strings without month names:
|
|
1530
1598
|
* ```typescript
|
|
1531
|
-
*
|
|
1532
|
-
*
|
|
1533
|
-
*
|
|
1534
|
-
*
|
|
1599
|
+
* hasBanglaMonth('১৫/০৪/২০২৪'); // false
|
|
1600
|
+
* hasBanglaMonth('15'); // false
|
|
1601
|
+
* hasBanglaMonth('January'); // false
|
|
1602
|
+
* hasBanglaMonth(''); // false
|
|
1535
1603
|
* ```
|
|
1536
1604
|
*/
|
|
1537
|
-
declare function
|
|
1605
|
+
declare function hasBanglaMonth(text: string): boolean;
|
|
1538
1606
|
/**
|
|
1539
1607
|
* Sanitizes a Date object, returning null if invalid.
|
|
1540
1608
|
*
|
|
@@ -1577,12 +1645,196 @@ declare function hasBengaliMonth(text: string): boolean;
|
|
|
1577
1645
|
declare function sanitizeDate(date: Date): Date | null;
|
|
1578
1646
|
|
|
1579
1647
|
/**
|
|
1580
|
-
*
|
|
1648
|
+
* Date comparison operations
|
|
1649
|
+
* Uses core comparison utilities
|
|
1650
|
+
*/
|
|
1651
|
+
/**
|
|
1652
|
+
* Compares two dates and returns -1, 0, or 1.
|
|
1653
|
+
*
|
|
1654
|
+
* Uses core date comparator for consistent comparison logic.
|
|
1655
|
+
*
|
|
1656
|
+
* @param date1 - First date
|
|
1657
|
+
* @param date2 - Second date
|
|
1658
|
+
* @returns -1 if date1 < date2, 0 if equal, 1 if date1 > date2
|
|
1659
|
+
* @throws Error if either date is invalid
|
|
1660
|
+
*
|
|
1661
|
+
* @example
|
|
1662
|
+
* First date is earlier:
|
|
1663
|
+
* ```typescript
|
|
1664
|
+
* compareDates(new Date(2024, 0, 15), new Date(2024, 0, 20));
|
|
1665
|
+
* // -1
|
|
1666
|
+
* ```
|
|
1667
|
+
*
|
|
1668
|
+
* @example
|
|
1669
|
+
* Dates are equal:
|
|
1670
|
+
* ```typescript
|
|
1671
|
+
* compareDates(new Date(2024, 0, 15), new Date(2024, 0, 15));
|
|
1672
|
+
* // 0
|
|
1673
|
+
* ```
|
|
1674
|
+
*
|
|
1675
|
+
* @example
|
|
1676
|
+
* First date is later:
|
|
1677
|
+
* ```typescript
|
|
1678
|
+
* compareDates(new Date(2024, 0, 20), new Date(2024, 0, 15));
|
|
1679
|
+
* // 1
|
|
1680
|
+
* ```
|
|
1681
|
+
*/
|
|
1682
|
+
declare function compareDates(date1: Date, date2: Date): -1 | 0 | 1;
|
|
1683
|
+
|
|
1684
|
+
/**
|
|
1685
|
+
* Date calculation operations
|
|
1686
|
+
* Functions for date arithmetic and differences
|
|
1687
|
+
*/
|
|
1688
|
+
/**
|
|
1689
|
+
* Gets the difference in days between two dates.
|
|
1690
|
+
*
|
|
1691
|
+
* @param date1 - First date
|
|
1692
|
+
* @param date2 - Second date
|
|
1693
|
+
* @returns Number of days between dates (date2 - date1)
|
|
1694
|
+
* @throws Error if either date is invalid
|
|
1695
|
+
*
|
|
1696
|
+
* @example
|
|
1697
|
+
* ```typescript
|
|
1698
|
+
* const date1 = new Date(2024, 0, 1);
|
|
1699
|
+
* const date2 = new Date(2024, 0, 11);
|
|
1700
|
+
* getDaysDifference(date1, date2);
|
|
1701
|
+
* // 10
|
|
1702
|
+
* ```
|
|
1703
|
+
*
|
|
1704
|
+
* @example
|
|
1705
|
+
* Negative difference:
|
|
1706
|
+
* ```typescript
|
|
1707
|
+
* const date1 = new Date(2024, 0, 11);
|
|
1708
|
+
* const date2 = new Date(2024, 0, 1);
|
|
1709
|
+
* getDaysDifference(date1, date2);
|
|
1710
|
+
* // -10
|
|
1711
|
+
* ```
|
|
1712
|
+
*/
|
|
1713
|
+
declare function getDaysDifference(date1: Date, date2: Date): number;
|
|
1714
|
+
/**
|
|
1715
|
+
* Adds days to a date.
|
|
1716
|
+
*
|
|
1717
|
+
* @param date - Starting date
|
|
1718
|
+
* @param days - Number of days to add (can be negative)
|
|
1719
|
+
* @returns New Date object
|
|
1720
|
+
* @throws Error if date is invalid
|
|
1721
|
+
*
|
|
1722
|
+
* @example
|
|
1723
|
+
* Adding days:
|
|
1724
|
+
* ```typescript
|
|
1725
|
+
* const date = new Date(2024, 0, 1);
|
|
1726
|
+
* addDays(date, 10);
|
|
1727
|
+
* // Date for 2024-01-11
|
|
1728
|
+
* ```
|
|
1729
|
+
*
|
|
1730
|
+
* @example
|
|
1731
|
+
* Subtracting days:
|
|
1732
|
+
* ```typescript
|
|
1733
|
+
* const date = new Date(2024, 0, 11);
|
|
1734
|
+
* addDays(date, -10);
|
|
1735
|
+
* // Date for 2024-01-01
|
|
1736
|
+
* ```
|
|
1737
|
+
*/
|
|
1738
|
+
declare function addDays(date: Date, days: number): Date;
|
|
1739
|
+
|
|
1740
|
+
/**
|
|
1741
|
+
* Date range and relative checking operations
|
|
1742
|
+
* Functions for checking if dates are today, past, future, or in ranges
|
|
1743
|
+
*/
|
|
1744
|
+
/**
|
|
1745
|
+
* Checks if a date is today.
|
|
1746
|
+
*
|
|
1747
|
+
* @param date - Date to check
|
|
1748
|
+
* @returns true if date is today, false otherwise
|
|
1749
|
+
*
|
|
1750
|
+
* @example
|
|
1751
|
+
* ```typescript
|
|
1752
|
+
* isToday(new Date());
|
|
1753
|
+
* // true
|
|
1754
|
+
*
|
|
1755
|
+
* isToday(new Date(2024, 0, 1));
|
|
1756
|
+
* // false (unless today is 2024-01-01)
|
|
1757
|
+
* ```
|
|
1758
|
+
*/
|
|
1759
|
+
declare function isToday(date: Date): boolean;
|
|
1760
|
+
/**
|
|
1761
|
+
* Checks if a date is in the past.
|
|
1762
|
+
*
|
|
1763
|
+
* @param date - Date to check
|
|
1764
|
+
* @returns true if date is before now, false otherwise
|
|
1765
|
+
*
|
|
1766
|
+
* @example
|
|
1767
|
+
* ```typescript
|
|
1768
|
+
* isPast(new Date(2020, 0, 1));
|
|
1769
|
+
* // true
|
|
1770
|
+
*
|
|
1771
|
+
* isPast(new Date(2030, 0, 1));
|
|
1772
|
+
* // false
|
|
1773
|
+
* ```
|
|
1774
|
+
*/
|
|
1775
|
+
declare function isPast(date: Date): boolean;
|
|
1776
|
+
/**
|
|
1777
|
+
* Checks if a date is in the future.
|
|
1778
|
+
*
|
|
1779
|
+
* @param date - Date to check
|
|
1780
|
+
* @returns true if date is after now, false otherwise
|
|
1781
|
+
*
|
|
1782
|
+
* @example
|
|
1783
|
+
* ```typescript
|
|
1784
|
+
* isFuture(new Date(2030, 0, 1));
|
|
1785
|
+
* // true
|
|
1786
|
+
*
|
|
1787
|
+
* isFuture(new Date(2020, 0, 1));
|
|
1788
|
+
* // false
|
|
1789
|
+
* ```
|
|
1790
|
+
*/
|
|
1791
|
+
declare function isFuture(date: Date): boolean;
|
|
1792
|
+
/**
|
|
1793
|
+
* Checks if a date is in a range (inclusive).
|
|
1794
|
+
*
|
|
1795
|
+
* @param date - Date to check
|
|
1796
|
+
* @param start - Start of range (inclusive)
|
|
1797
|
+
* @param end - End of range (inclusive)
|
|
1798
|
+
* @returns true if date is in range, false otherwise
|
|
1799
|
+
*
|
|
1800
|
+
* @example
|
|
1801
|
+
* Date within range:
|
|
1802
|
+
* ```typescript
|
|
1803
|
+
* isDateInRange(
|
|
1804
|
+
* new Date(2024, 0, 15),
|
|
1805
|
+
* new Date(2024, 0, 10),
|
|
1806
|
+
* new Date(2024, 0, 20)
|
|
1807
|
+
* );
|
|
1808
|
+
* // true
|
|
1809
|
+
* ```
|
|
1581
1810
|
*
|
|
1582
|
-
*
|
|
1583
|
-
*
|
|
1811
|
+
* @example
|
|
1812
|
+
* Date on boundary:
|
|
1813
|
+
* ```typescript
|
|
1814
|
+
* isDateInRange(
|
|
1815
|
+
* new Date(2024, 0, 10),
|
|
1816
|
+
* new Date(2024, 0, 10),
|
|
1817
|
+
* new Date(2024, 0, 20)
|
|
1818
|
+
* );
|
|
1819
|
+
* // true
|
|
1820
|
+
* ```
|
|
1584
1821
|
*
|
|
1585
|
-
* @
|
|
1822
|
+
* @example
|
|
1823
|
+
* Date outside range:
|
|
1824
|
+
* ```typescript
|
|
1825
|
+
* isDateInRange(
|
|
1826
|
+
* new Date(2024, 0, 25),
|
|
1827
|
+
* new Date(2024, 0, 10),
|
|
1828
|
+
* new Date(2024, 0, 20)
|
|
1829
|
+
* );
|
|
1830
|
+
* // false
|
|
1831
|
+
* ```
|
|
1832
|
+
*/
|
|
1833
|
+
declare function isDateInRange(date: Date, start: Date, end: Date): boolean;
|
|
1834
|
+
|
|
1835
|
+
/**
|
|
1836
|
+
* Date utility functions
|
|
1837
|
+
* Domain-specific utilities using core patterns
|
|
1586
1838
|
*/
|
|
1587
1839
|
/**
|
|
1588
1840
|
* Safely formats a date with fallback value.
|
|
@@ -1625,12 +1877,12 @@ declare function safeFormatDate(date: Date, options?: {
|
|
|
1625
1877
|
format?: 'short' | 'long';
|
|
1626
1878
|
}, fallback?: string): string;
|
|
1627
1879
|
/**
|
|
1628
|
-
* Safely parses a
|
|
1880
|
+
* Safely parses a Bangla date string with fallback.
|
|
1629
1881
|
*
|
|
1630
1882
|
* Unlike parseDate, this function doesn't throw on invalid strings.
|
|
1631
1883
|
* Returns a fallback Date for invalid inputs.
|
|
1632
1884
|
*
|
|
1633
|
-
* @param dateString -
|
|
1885
|
+
* @param dateString - Bangla date string to parse
|
|
1634
1886
|
* @param fallback - Fallback Date if parsing fails (default: current date)
|
|
1635
1887
|
* @returns Parsed Date object or fallback
|
|
1636
1888
|
*
|
|
@@ -1717,9 +1969,9 @@ declare function batchFormatDates(dates: Date[], options?: {
|
|
|
1717
1969
|
format?: 'short' | 'long';
|
|
1718
1970
|
}): string[];
|
|
1719
1971
|
/**
|
|
1720
|
-
* Parses an array of
|
|
1972
|
+
* Parses an array of Bangla date strings.
|
|
1721
1973
|
*
|
|
1722
|
-
* @param dateStrings - Array of
|
|
1974
|
+
* @param dateStrings - Array of Bangla date strings
|
|
1723
1975
|
* @returns Array of Date objects
|
|
1724
1976
|
*
|
|
1725
1977
|
* @example
|
|
@@ -1751,243 +2003,74 @@ declare function batchParseDates(dateStrings: string[]): Date[];
|
|
|
1751
2003
|
* @example
|
|
1752
2004
|
* Valid strings:
|
|
1753
2005
|
* ```typescript
|
|
1754
|
-
*
|
|
1755
|
-
*
|
|
1756
|
-
*
|
|
2006
|
+
* canParseBanglaDate('১৫ বৈশাখ ১৪৩১'); // true
|
|
2007
|
+
* canParseBanglaDate('১৫/০৪/২০২৪'); // true
|
|
2008
|
+
* canParseBanglaDate('15 বৈশাখ 1431'); // true
|
|
1757
2009
|
* ```
|
|
1758
2010
|
*
|
|
1759
2011
|
* @example
|
|
1760
2012
|
* Invalid strings:
|
|
1761
2013
|
* ```typescript
|
|
1762
|
-
*
|
|
1763
|
-
*
|
|
1764
|
-
*
|
|
2014
|
+
* canParseBanglaDate('invalid'); // false
|
|
2015
|
+
* canParseBanglaDate('2024-01-15'); // false
|
|
2016
|
+
* canParseBanglaDate(''); // false
|
|
1765
2017
|
* ```
|
|
1766
2018
|
*/
|
|
1767
|
-
declare function
|
|
2019
|
+
declare function canParseBanglaDate(dateString: string): boolean;
|
|
2020
|
+
|
|
1768
2021
|
/**
|
|
1769
|
-
*
|
|
2022
|
+
* Converts a month number (1-12) to Bangla month name.
|
|
1770
2023
|
*
|
|
1771
|
-
*
|
|
1772
|
-
*
|
|
1773
|
-
*
|
|
2024
|
+
* This function maps standard month numbers to Bangla calendar month names.
|
|
2025
|
+
* The Bangla calendar has 12 months, each with its traditional name.
|
|
2026
|
+
*
|
|
2027
|
+
* **Month Mapping:**
|
|
2028
|
+
* 1. বৈশাখ (Boishakh)
|
|
2029
|
+
* 2. জ্যৈষ্ঠ (Jyoishtho)
|
|
2030
|
+
* 3. আষাঢ় (Asharh)
|
|
2031
|
+
* 4. শ্রাবণ (Srabon)
|
|
2032
|
+
* 5. ভাদ্র (Bhadro)
|
|
2033
|
+
* 6. আশ্বিন (Ashwin)
|
|
2034
|
+
* 7. কার্তিক (Kartik)
|
|
2035
|
+
* 8. অগ্রহায়ণ (Ogrohayon)
|
|
2036
|
+
* 9. পৌষ (Poush)
|
|
2037
|
+
* 10. মাঘ (Magh)
|
|
2038
|
+
* 11. ফাল্গুন (Falgun)
|
|
2039
|
+
* 12. চৈত্র (Choitro)
|
|
2040
|
+
*
|
|
2041
|
+
* @param monthNumber - Month number (1-12)
|
|
2042
|
+
* @returns Bangla month name
|
|
2043
|
+
* @throws {Error} If month number is not between 1 and 12
|
|
1774
2044
|
*
|
|
1775
2045
|
* @example
|
|
1776
|
-
* First
|
|
2046
|
+
* First three months:
|
|
1777
2047
|
* ```typescript
|
|
1778
|
-
*
|
|
1779
|
-
* //
|
|
2048
|
+
* toBanglaMonth(1); // 'বৈশাখ'
|
|
2049
|
+
* toBanglaMonth(2); // 'জ্যৈষ্ঠ'
|
|
2050
|
+
* toBanglaMonth(3); // 'আষাঢ়'
|
|
1780
2051
|
* ```
|
|
1781
2052
|
*
|
|
1782
2053
|
* @example
|
|
1783
|
-
*
|
|
2054
|
+
* Mid-year months:
|
|
1784
2055
|
* ```typescript
|
|
1785
|
-
*
|
|
1786
|
-
*
|
|
1787
|
-
* //
|
|
2056
|
+
* toBanglaMonth(6); // 'আশ্বিন'
|
|
2057
|
+
* toBanglaMonth(7); // 'কার্তিক'
|
|
2058
|
+
* toBanglaMonth(8); // 'অগ্রহায়ণ'
|
|
1788
2059
|
* ```
|
|
1789
2060
|
*
|
|
1790
2061
|
* @example
|
|
1791
|
-
*
|
|
2062
|
+
* Last month:
|
|
1792
2063
|
* ```typescript
|
|
1793
|
-
*
|
|
1794
|
-
* // 1
|
|
2064
|
+
* toBanglaMonth(12); // 'চৈত্র'
|
|
1795
2065
|
* ```
|
|
1796
|
-
*/
|
|
1797
|
-
declare function compareDates(date1: Date, date2: Date): -1 | 0 | 1;
|
|
1798
|
-
/**
|
|
1799
|
-
* Checks if a date is today.
|
|
1800
|
-
*
|
|
1801
|
-
* @param date - Date to check
|
|
1802
|
-
* @returns true if date is today, false otherwise
|
|
1803
2066
|
*
|
|
1804
2067
|
* @example
|
|
2068
|
+
* Error cases:
|
|
1805
2069
|
* ```typescript
|
|
1806
|
-
*
|
|
1807
|
-
* //
|
|
1808
|
-
*
|
|
1809
|
-
*
|
|
1810
|
-
* // false (unless today is 2024-01-01)
|
|
1811
|
-
* ```
|
|
1812
|
-
*/
|
|
1813
|
-
declare function isToday(date: Date): boolean;
|
|
1814
|
-
/**
|
|
1815
|
-
* Checks if a date is in the past.
|
|
1816
|
-
*
|
|
1817
|
-
* @param date - Date to check
|
|
1818
|
-
* @returns true if date is before now, false otherwise
|
|
1819
|
-
*
|
|
1820
|
-
* @example
|
|
1821
|
-
* ```typescript
|
|
1822
|
-
* isPast(new Date(2020, 0, 1));
|
|
1823
|
-
* // true
|
|
1824
|
-
*
|
|
1825
|
-
* isPast(new Date(2030, 0, 1));
|
|
1826
|
-
* // false
|
|
1827
|
-
* ```
|
|
1828
|
-
*/
|
|
1829
|
-
declare function isPast(date: Date): boolean;
|
|
1830
|
-
/**
|
|
1831
|
-
* Checks if a date is in the future.
|
|
1832
|
-
*
|
|
1833
|
-
* @param date - Date to check
|
|
1834
|
-
* @returns true if date is after now, false otherwise
|
|
1835
|
-
*
|
|
1836
|
-
* @example
|
|
1837
|
-
* ```typescript
|
|
1838
|
-
* isFuture(new Date(2030, 0, 1));
|
|
1839
|
-
* // true
|
|
1840
|
-
*
|
|
1841
|
-
* isFuture(new Date(2020, 0, 1));
|
|
1842
|
-
* // false
|
|
1843
|
-
* ```
|
|
1844
|
-
*/
|
|
1845
|
-
declare function isFuture(date: Date): boolean;
|
|
1846
|
-
/**
|
|
1847
|
-
* Gets the difference in days between two dates.
|
|
1848
|
-
*
|
|
1849
|
-
* @param date1 - First date
|
|
1850
|
-
* @param date2 - Second date
|
|
1851
|
-
* @returns Number of days between dates (date2 - date1)
|
|
1852
|
-
*
|
|
1853
|
-
* @example
|
|
1854
|
-
* ```typescript
|
|
1855
|
-
* const date1 = new Date(2024, 0, 1);
|
|
1856
|
-
* const date2 = new Date(2024, 0, 11);
|
|
1857
|
-
* getDaysDifference(date1, date2);
|
|
1858
|
-
* // 10
|
|
1859
|
-
* ```
|
|
1860
|
-
*
|
|
1861
|
-
* @example
|
|
1862
|
-
* Negative difference:
|
|
1863
|
-
* ```typescript
|
|
1864
|
-
* const date1 = new Date(2024, 0, 11);
|
|
1865
|
-
* const date2 = new Date(2024, 0, 1);
|
|
1866
|
-
* getDaysDifference(date1, date2);
|
|
1867
|
-
* // -10
|
|
1868
|
-
* ```
|
|
1869
|
-
*/
|
|
1870
|
-
declare function getDaysDifference(date1: Date, date2: Date): number;
|
|
1871
|
-
/**
|
|
1872
|
-
* Adds days to a date.
|
|
1873
|
-
*
|
|
1874
|
-
* @param date - Starting date
|
|
1875
|
-
* @param days - Number of days to add (can be negative)
|
|
1876
|
-
* @returns New Date object
|
|
1877
|
-
*
|
|
1878
|
-
* @example
|
|
1879
|
-
* Adding days:
|
|
1880
|
-
* ```typescript
|
|
1881
|
-
* const date = new Date(2024, 0, 1);
|
|
1882
|
-
* addDays(date, 10);
|
|
1883
|
-
* // Date for 2024-01-11
|
|
1884
|
-
* ```
|
|
1885
|
-
*
|
|
1886
|
-
* @example
|
|
1887
|
-
* Subtracting days:
|
|
1888
|
-
* ```typescript
|
|
1889
|
-
* const date = new Date(2024, 0, 11);
|
|
1890
|
-
* addDays(date, -10);
|
|
1891
|
-
* // Date for 2024-01-01
|
|
1892
|
-
* ```
|
|
1893
|
-
*/
|
|
1894
|
-
declare function addDays(date: Date, days: number): Date;
|
|
1895
|
-
/**
|
|
1896
|
-
* Checks if a date is in a range (inclusive).
|
|
1897
|
-
*
|
|
1898
|
-
* @param date - Date to check
|
|
1899
|
-
* @param start - Start of range (inclusive)
|
|
1900
|
-
* @param end - End of range (inclusive)
|
|
1901
|
-
* @returns true if date is in range, false otherwise
|
|
1902
|
-
*
|
|
1903
|
-
* @example
|
|
1904
|
-
* Date within range:
|
|
1905
|
-
* ```typescript
|
|
1906
|
-
* isDateInRange(
|
|
1907
|
-
* new Date(2024, 0, 15),
|
|
1908
|
-
* new Date(2024, 0, 10),
|
|
1909
|
-
* new Date(2024, 0, 20)
|
|
1910
|
-
* );
|
|
1911
|
-
* // true
|
|
1912
|
-
* ```
|
|
1913
|
-
*
|
|
1914
|
-
* @example
|
|
1915
|
-
* Date on boundary:
|
|
1916
|
-
* ```typescript
|
|
1917
|
-
* isDateInRange(
|
|
1918
|
-
* new Date(2024, 0, 10),
|
|
1919
|
-
* new Date(2024, 0, 10),
|
|
1920
|
-
* new Date(2024, 0, 20)
|
|
1921
|
-
* );
|
|
1922
|
-
* // true
|
|
1923
|
-
* ```
|
|
1924
|
-
*
|
|
1925
|
-
* @example
|
|
1926
|
-
* Date outside range:
|
|
1927
|
-
* ```typescript
|
|
1928
|
-
* isDateInRange(
|
|
1929
|
-
* new Date(2024, 0, 25),
|
|
1930
|
-
* new Date(2024, 0, 10),
|
|
1931
|
-
* new Date(2024, 0, 20)
|
|
1932
|
-
* );
|
|
1933
|
-
* // false
|
|
1934
|
-
* ```
|
|
1935
|
-
*/
|
|
1936
|
-
declare function isDateInRange(date: Date, start: Date, end: Date): boolean;
|
|
1937
|
-
|
|
1938
|
-
/**
|
|
1939
|
-
* Converts a month number (1-12) to Bangla month name.
|
|
1940
|
-
*
|
|
1941
|
-
* This function maps standard month numbers to Bengali calendar month names.
|
|
1942
|
-
* The Bengali calendar has 12 months, each with its traditional name.
|
|
1943
|
-
*
|
|
1944
|
-
* **Month Mapping:**
|
|
1945
|
-
* 1. বৈশাখ (Boishakh)
|
|
1946
|
-
* 2. জ্যৈষ্ঠ (Jyoishtho)
|
|
1947
|
-
* 3. আষাঢ় (Asharh)
|
|
1948
|
-
* 4. শ্রাবণ (Srabon)
|
|
1949
|
-
* 5. ভাদ্র (Bhadro)
|
|
1950
|
-
* 6. আশ্বিন (Ashwin)
|
|
1951
|
-
* 7. কার্তিক (Kartik)
|
|
1952
|
-
* 8. অগ্রহায়ণ (Ogrohayon)
|
|
1953
|
-
* 9. পৌষ (Poush)
|
|
1954
|
-
* 10. মাঘ (Magh)
|
|
1955
|
-
* 11. ফাল্গুন (Falgun)
|
|
1956
|
-
* 12. চৈত্র (Choitro)
|
|
1957
|
-
*
|
|
1958
|
-
* @param monthNumber - Month number (1-12)
|
|
1959
|
-
* @returns Bangla month name
|
|
1960
|
-
* @throws {Error} If month number is not between 1 and 12
|
|
1961
|
-
*
|
|
1962
|
-
* @example
|
|
1963
|
-
* First three months:
|
|
1964
|
-
* ```typescript
|
|
1965
|
-
* toBanglaMonth(1); // 'বৈশাখ'
|
|
1966
|
-
* toBanglaMonth(2); // 'জ্যৈষ্ঠ'
|
|
1967
|
-
* toBanglaMonth(3); // 'আষাঢ়'
|
|
1968
|
-
* ```
|
|
1969
|
-
*
|
|
1970
|
-
* @example
|
|
1971
|
-
* Mid-year months:
|
|
1972
|
-
* ```typescript
|
|
1973
|
-
* toBanglaMonth(6); // 'আশ্বিন'
|
|
1974
|
-
* toBanglaMonth(7); // 'কার্তিক'
|
|
1975
|
-
* toBanglaMonth(8); // 'অগ্রহায়ণ'
|
|
1976
|
-
* ```
|
|
1977
|
-
*
|
|
1978
|
-
* @example
|
|
1979
|
-
* Last month:
|
|
1980
|
-
* ```typescript
|
|
1981
|
-
* toBanglaMonth(12); // 'চৈত্র'
|
|
1982
|
-
* ```
|
|
1983
|
-
*
|
|
1984
|
-
* @example
|
|
1985
|
-
* Error cases:
|
|
1986
|
-
* ```typescript
|
|
1987
|
-
* toBanglaMonth(0); // throws Error: Month number must be between 1 and 12
|
|
1988
|
-
* toBanglaMonth(13); // throws Error: Month number must be between 1 and 12
|
|
1989
|
-
* toBanglaMonth(-1); // throws Error: Month number must be between 1 and 12
|
|
1990
|
-
* ```
|
|
2070
|
+
* toBanglaMonth(0); // throws Error: Month number must be between 1 and 12
|
|
2071
|
+
* toBanglaMonth(13); // throws Error: Month number must be between 1 and 12
|
|
2072
|
+
* toBanglaMonth(-1); // throws Error: Month number must be between 1 and 12
|
|
2073
|
+
* ```
|
|
1991
2074
|
*
|
|
1992
2075
|
* @example
|
|
1993
2076
|
* Practical usage (dropdown options):
|
|
@@ -2005,7 +2088,7 @@ declare function toBanglaMonth(monthNumber: number): string;
|
|
|
2005
2088
|
* Converts a Bangla month name to month number (1-12).
|
|
2006
2089
|
*
|
|
2007
2090
|
* This function performs the reverse operation of toBanglaMonth,
|
|
2008
|
-
* converting
|
|
2091
|
+
* converting Bangla month names to their numeric equivalents.
|
|
2009
2092
|
*
|
|
2010
2093
|
* **Valid Month Names:**
|
|
2011
2094
|
* - বৈশাখ → 1
|
|
@@ -2072,44 +2155,18 @@ declare function fromBanglaMonth(monthName: string): number;
|
|
|
2072
2155
|
/**
|
|
2073
2156
|
* Gets the Bangla month name from a Date object.
|
|
2074
2157
|
*
|
|
2075
|
-
* This function
|
|
2076
|
-
*
|
|
2077
|
-
* uses a direct 1:1 mapping (JS month + 1 = Bangla month number).
|
|
2078
|
-
*
|
|
2079
|
-
* **Note:** This is a simplified mapping. For accurate Bengali calendar
|
|
2080
|
-
* conversions, use the calendar module which accounts for Bengali new year
|
|
2081
|
-
* and proper date calculations.
|
|
2158
|
+
* This function converts the given date to the Bangla calendar and returns
|
|
2159
|
+
* the corresponding Bangla month name.
|
|
2082
2160
|
*
|
|
2083
2161
|
* @param date - Date object
|
|
2084
2162
|
* @returns Bangla month name
|
|
2085
2163
|
*
|
|
2086
2164
|
* @example
|
|
2087
|
-
* Getting month name from current date:
|
|
2088
|
-
* ```typescript
|
|
2089
|
-
* const today = new Date();
|
|
2090
|
-
* const monthName = getMonthName(today);
|
|
2091
|
-
* console.log(`Current month: ${monthName}`);
|
|
2092
|
-
* ```
|
|
2093
|
-
*
|
|
2094
|
-
* @example
|
|
2095
2165
|
* Getting month name from specific dates:
|
|
2096
2166
|
* ```typescript
|
|
2097
|
-
*
|
|
2098
|
-
* getMonthName(
|
|
2099
|
-
*
|
|
2100
|
-
* const june = new Date(2024, 5, 15); // June
|
|
2101
|
-
* getMonthName(june); // 'আশ্বিন'
|
|
2102
|
-
*
|
|
2103
|
-
* const dec = new Date(2024, 11, 31); // December
|
|
2104
|
-
* getMonthName(dec); // 'চৈত্র'
|
|
2105
|
-
* ```
|
|
2106
|
-
*
|
|
2107
|
-
* @example
|
|
2108
|
-
* Practical usage (display):
|
|
2109
|
-
* ```typescript
|
|
2110
|
-
* const appointment = new Date(2024, 3, 20);
|
|
2111
|
-
* const monthName = getMonthName(appointment);
|
|
2112
|
-
* console.log(`Appointment in ${monthName}`); // 'Appointment in শ্রাবণ'
|
|
2167
|
+
* getMonthName(new Date(2024, 3, 14)); // 'বৈশাখ' (Pohela Boishakh)
|
|
2168
|
+
* getMonthName(new Date(2024, 0, 15)); // 'পৌষ' (January falls in Poush)
|
|
2169
|
+
* getMonthName(new Date(2024, 6, 15)); // 'শ্রাবণ' (July falls in Srabon)
|
|
2113
2170
|
* ```
|
|
2114
2171
|
*/
|
|
2115
2172
|
declare function getMonthName(date: Date): string;
|
|
@@ -2867,14 +2924,14 @@ declare function getDaysBetween(from: number, to: number): number;
|
|
|
2867
2924
|
/**
|
|
2868
2925
|
* Gets the Bangla season name from a Date object.
|
|
2869
2926
|
*
|
|
2870
|
-
* This function determines the current
|
|
2871
|
-
* It follows the traditional
|
|
2927
|
+
* This function determines the current Bangla season based on the Bangla month of the given date.
|
|
2928
|
+
* It follows the traditional Bangla calendar system which divides the year into six seasons.
|
|
2872
2929
|
*
|
|
2873
|
-
* **
|
|
2930
|
+
* **Bangla Seasons (ঋতু) — 2 months per season:**
|
|
2874
2931
|
* - গ্রীষ্ম (Grisshô - Summer): months 1-2 (বৈশাখ-জ্যৈষ্ঠ)
|
|
2875
|
-
* - বর্ষা (Bôrsha - Monsoon): months 3-
|
|
2876
|
-
* - শরৎ (Shôrôt - Autumn): months 6
|
|
2877
|
-
* - হেমন্ত (Hemonto - Late Autumn):
|
|
2932
|
+
* - বর্ষা (Bôrsha - Monsoon): months 3-4 (আষাঢ়-শ্রাবণ)
|
|
2933
|
+
* - শরৎ (Shôrôt - Autumn): months 5-6 (ভাদ্র-আশ্বিন)
|
|
2934
|
+
* - হেমন্ত (Hemonto - Late Autumn): months 7-8 (কার্তিক-অগ্রহায়ণ)
|
|
2878
2935
|
* - শীত (Sheet - Winter): months 9-10 (পৌষ-মাঘ)
|
|
2879
2936
|
* - বসন্ত (Bôshonto - Spring): months 11-12 (ফাল্গুন-চৈত্র)
|
|
2880
2937
|
*
|
|
@@ -2884,10 +2941,10 @@ declare function getDaysBetween(from: number, to: number): number;
|
|
|
2884
2941
|
* @example
|
|
2885
2942
|
* Basic usage:
|
|
2886
2943
|
* ```typescript
|
|
2887
|
-
* const date1 = new Date('2024-04-15'); //
|
|
2944
|
+
* const date1 = new Date('2024-04-15'); // Bangla month 1 (Boishakh)
|
|
2888
2945
|
* getSeason(date1); // 'গ্রীষ্ম'
|
|
2889
2946
|
*
|
|
2890
|
-
* const date2 = new Date('2024-07-15'); //
|
|
2947
|
+
* const date2 = new Date('2024-07-15'); // Bangla month 4 (Monsoon period)
|
|
2891
2948
|
* getSeason(date2); // 'বর্ষা'
|
|
2892
2949
|
* ```
|
|
2893
2950
|
*
|
|
@@ -2932,20 +2989,20 @@ declare function getDaysBetween(from: number, to: number): number;
|
|
|
2932
2989
|
declare function getSeason(date: Date): string;
|
|
2933
2990
|
|
|
2934
2991
|
/**
|
|
2935
|
-
* Gets the Bangla season name from a
|
|
2992
|
+
* Gets the Bangla season name from a Bangla month number.
|
|
2936
2993
|
*
|
|
2937
|
-
* This function maps
|
|
2938
|
-
* according to the traditional
|
|
2994
|
+
* This function maps Bangla month numbers (1-12) to their corresponding seasons
|
|
2995
|
+
* according to the traditional Bangla calendar system.
|
|
2939
2996
|
*
|
|
2940
|
-
* **Month to Season Mapping:**
|
|
2997
|
+
* **Month to Season Mapping (2 months per season):**
|
|
2941
2998
|
* - Months 1-2 (বৈশাখ-জ্যৈষ্ঠ) → গ্রীষ্ম (Summer)
|
|
2942
|
-
* - Months 3-
|
|
2943
|
-
* - Months 6
|
|
2944
|
-
* -
|
|
2999
|
+
* - Months 3-4 (আষাঢ়-শ্রাবণ) → বর্ষা (Monsoon)
|
|
3000
|
+
* - Months 5-6 (ভাদ্র-আশ্বিন) → শরৎ (Autumn)
|
|
3001
|
+
* - Months 7-8 (কার্তিক-অগ্রহায়ণ) → হেমন্ত (Late Autumn)
|
|
2945
3002
|
* - Months 9-10 (পৌষ-মাঘ) → শীত (Winter)
|
|
2946
3003
|
* - Months 11-12 (ফাল্গুন-চৈত্র) → বসন্ত (Spring)
|
|
2947
3004
|
*
|
|
2948
|
-
* @param monthNumber -
|
|
3005
|
+
* @param monthNumber - Bangla month number (1-12)
|
|
2949
3006
|
* @returns Bangla season name
|
|
2950
3007
|
* @throws {Error} If monthNumber is not between 1 and 12
|
|
2951
3008
|
*
|
|
@@ -2968,13 +3025,13 @@ declare function getSeason(date: Date): string;
|
|
|
2968
3025
|
* // Monsoon months
|
|
2969
3026
|
* getSeasonFromMonth(3); // 'বর্ষা' (Asharh)
|
|
2970
3027
|
* getSeasonFromMonth(4); // 'বর্ষা' (Shrabon)
|
|
2971
|
-
* getSeasonFromMonth(5); // 'বর্ষা' (Bhadro)
|
|
2972
3028
|
*
|
|
2973
3029
|
* // Autumn months
|
|
3030
|
+
* getSeasonFromMonth(5); // 'শরৎ' (Bhadro)
|
|
2974
3031
|
* getSeasonFromMonth(6); // 'শরৎ' (Ashwin)
|
|
2975
|
-
* getSeasonFromMonth(7); // 'শরৎ' (Kartik)
|
|
2976
3032
|
*
|
|
2977
|
-
* // Late Autumn
|
|
3033
|
+
* // Late Autumn months
|
|
3034
|
+
* getSeasonFromMonth(7); // 'হেমন্ত' (Kartik)
|
|
2978
3035
|
* getSeasonFromMonth(8); // 'হেমন্ত' (Ogrohayon)
|
|
2979
3036
|
*
|
|
2980
3037
|
* // Winter months
|
|
@@ -3100,13 +3157,13 @@ declare function getAllSeasons(): string[];
|
|
|
3100
3157
|
* Gets the month numbers for a given season.
|
|
3101
3158
|
*
|
|
3102
3159
|
* This function returns an array of month numbers (1-12) that belong to
|
|
3103
|
-
* the specified season in the
|
|
3160
|
+
* the specified season in the Bangla calendar system.
|
|
3104
3161
|
*
|
|
3105
|
-
* **Season to Month Mapping:**
|
|
3162
|
+
* **Season to Month Mapping (2 months per season):**
|
|
3106
3163
|
* - গ্রীষ্ম (Summer): months 1-2 (বৈশাখ-জ্যৈষ্ঠ)
|
|
3107
|
-
* - বর্ষা (Monsoon): months 3-
|
|
3108
|
-
* - শরৎ (Autumn): months 6
|
|
3109
|
-
* - হেমন্ত (Late Autumn):
|
|
3164
|
+
* - বর্ষা (Monsoon): months 3-4 (আষাঢ়-শ্রাবণ)
|
|
3165
|
+
* - শরৎ (Autumn): months 5-6 (ভাদ্র-আশ্বিন)
|
|
3166
|
+
* - হেমন্ত (Late Autumn): months 7-8 (কার্তিক-অগ্রহায়ণ)
|
|
3110
3167
|
* - শীত (Winter): months 9-10 (পৌষ-মাঘ)
|
|
3111
3168
|
* - বসন্ত (Spring): months 11-12 (ফাল্গুন-চৈত্র)
|
|
3112
3169
|
*
|
|
@@ -3117,9 +3174,9 @@ declare function getAllSeasons(): string[];
|
|
|
3117
3174
|
* @example
|
|
3118
3175
|
* ```typescript
|
|
3119
3176
|
* getSeasonMonths('গ্রীষ্ম'); // [1, 2]
|
|
3120
|
-
* getSeasonMonths('বর্ষা'); // [3, 4
|
|
3121
|
-
* getSeasonMonths('শরৎ'); // [
|
|
3122
|
-
* getSeasonMonths('হেমন্ত'); // [8]
|
|
3177
|
+
* getSeasonMonths('বর্ষা'); // [3, 4]
|
|
3178
|
+
* getSeasonMonths('শরৎ'); // [5, 6]
|
|
3179
|
+
* getSeasonMonths('হেমন্ত'); // [7, 8]
|
|
3123
3180
|
* getSeasonMonths('শীত'); // [9, 10]
|
|
3124
3181
|
* getSeasonMonths('বসন্ত'); // [11, 12]
|
|
3125
3182
|
* ```
|
|
@@ -3494,6 +3551,8 @@ declare function safeToOrdinal(number: number, fallback?: string): string;
|
|
|
3494
3551
|
* This function processes multiple numbers at once, converting each to
|
|
3495
3552
|
* its ordinal form. Invalid numbers are skipped.
|
|
3496
3553
|
*
|
|
3554
|
+
* Uses core validating batch processor to eliminate duplication.
|
|
3555
|
+
*
|
|
3497
3556
|
* @param numbers - Array of numbers to convert
|
|
3498
3557
|
* @returns Array of ordinal strings (invalid numbers are skipped)
|
|
3499
3558
|
*
|
|
@@ -3509,7 +3568,7 @@ declare function safeToOrdinal(number: number, fallback?: string): string;
|
|
|
3509
3568
|
* // ['দশম', 'বিংশ', 'ত্রিংশ']
|
|
3510
3569
|
* ```
|
|
3511
3570
|
*/
|
|
3512
|
-
declare
|
|
3571
|
+
declare const batchToOrdinal: (inputs: number[]) => string[];
|
|
3513
3572
|
/**
|
|
3514
3573
|
* Parses and converts input to ordinal in one step.
|
|
3515
3574
|
*
|
|
@@ -3734,10 +3793,12 @@ declare function createOrdinalList<T>(items: T[], startFrom?: number): Array<{
|
|
|
3734
3793
|
* It can accept either a Date object or a time string in HH:mm or HH:mm:ss format.
|
|
3735
3794
|
*
|
|
3736
3795
|
* **12-Hour Format Periods:**
|
|
3737
|
-
* - রাত (night): 12:00 AM -
|
|
3738
|
-
* - সকাল (morning):
|
|
3739
|
-
* - দুপুর (noon): 12:00 PM -
|
|
3740
|
-
* - বিকাল (afternoon
|
|
3796
|
+
* - রাত (night): 12:00 AM - 5:59 AM (hours 0-5)
|
|
3797
|
+
* - সকাল (morning): 6:00 AM - 11:59 AM (hours 6-11)
|
|
3798
|
+
* - দুপুর (noon/afternoon): 12:00 PM - 2:59 PM (hours 12-14)
|
|
3799
|
+
* - বিকাল (late afternoon): 3:00 PM - 5:59 PM (hours 15-17)
|
|
3800
|
+
* - সন্ধ্যা (evening): 6:00 PM - 7:59 PM (hours 18-19)
|
|
3801
|
+
* - রাত (night): 8:00 PM - 11:59 PM (hours 20-23)
|
|
3741
3802
|
*
|
|
3742
3803
|
* @param date - Date object or time string (HH:mm or HH:mm:ss format)
|
|
3743
3804
|
* @param options - Formatting options
|
|
@@ -3755,47 +3816,15 @@ declare function createOrdinalList<T>(items: T[], startFrom?: number): Array<{
|
|
|
3755
3816
|
* ```
|
|
3756
3817
|
*
|
|
3757
3818
|
* @example
|
|
3758
|
-
* With seconds:
|
|
3759
|
-
* ```typescript
|
|
3760
|
-
* formatTime('14:30:45', { includeSeconds: true }); // '১৪:৩০:৪৫'
|
|
3761
|
-
* formatTime(new Date('2024-01-07T09:15:30'), { includeSeconds: true }); // '০৯:১৫:৩০'
|
|
3762
|
-
* ```
|
|
3763
|
-
*
|
|
3764
|
-
* @example
|
|
3765
3819
|
* 12-hour format with Bangla periods:
|
|
3766
3820
|
* ```typescript
|
|
3767
|
-
* formatTime('09:30', { use12Hour: true }); // '০৯:৩০
|
|
3768
|
-
* formatTime('14:30', { use12Hour: true }); // '০২:৩০
|
|
3769
|
-
* formatTime('
|
|
3770
|
-
* formatTime('
|
|
3771
|
-
*
|
|
3772
|
-
*
|
|
3773
|
-
*
|
|
3774
|
-
* Combining options:
|
|
3775
|
-
* ```typescript
|
|
3776
|
-
* formatTime('14:30:45', { use12Hour: true, includeSeconds: true }); // '০২:৩০:৪৫ বিকাল'
|
|
3777
|
-
* formatTime('09:15:30', { use12Hour: true, includeSeconds: true }); // '০৯:১৫:৩০ সকাল'
|
|
3778
|
-
* ```
|
|
3779
|
-
*
|
|
3780
|
-
* @example
|
|
3781
|
-
* Error cases:
|
|
3782
|
-
* ```typescript
|
|
3783
|
-
* formatTime('invalid'); // throws Error: Invalid time string format
|
|
3784
|
-
* formatTime('25:00'); // throws Error: Invalid time string format
|
|
3785
|
-
* formatTime('12:70'); // throws Error: Invalid time string format
|
|
3786
|
-
* ```
|
|
3787
|
-
*
|
|
3788
|
-
* @example
|
|
3789
|
-
* Real-world usage:
|
|
3790
|
-
* ```typescript
|
|
3791
|
-
* const event = {
|
|
3792
|
-
* name: 'Team Meeting',
|
|
3793
|
-
* time: new Date('2024-01-07T10:30:00')
|
|
3794
|
-
* };
|
|
3795
|
-
*
|
|
3796
|
-
* const formattedTime = formatTime(event.time, { use12Hour: true });
|
|
3797
|
-
* console.log(`${event.name}: ${formattedTime}`);
|
|
3798
|
-
* // Output: "Team Meeting: ১০:৩০ সকাল"
|
|
3821
|
+
* formatTime('09:30', { use12Hour: true }); // 'সকাল ০৯:৩০'
|
|
3822
|
+
* formatTime('14:30', { use12Hour: true }); // 'দুপুর ০২:৩০'
|
|
3823
|
+
* formatTime('16:00', { use12Hour: true }); // 'বিকাল ০৪:০০'
|
|
3824
|
+
* formatTime('18:30', { use12Hour: true }); // 'সন্ধ্যা ০৬:৩০'
|
|
3825
|
+
* formatTime('22:00', { use12Hour: true }); // 'রাত ১০:০০'
|
|
3826
|
+
* formatTime('04:30', { use12Hour: true }); // 'রাত ০৪:৩০'
|
|
3827
|
+
* formatTime('00:00', { use12Hour: true }); // 'রাত ১২:০০'
|
|
3799
3828
|
* ```
|
|
3800
3829
|
*/
|
|
3801
3830
|
declare function formatTime(date: Date | string, options?: {
|
|
@@ -3967,6 +3996,59 @@ declare function relativeTime(date: Date, baseDate?: Date): string;
|
|
|
3967
3996
|
*/
|
|
3968
3997
|
declare function relativeDay(date: Date, baseDate?: Date): string;
|
|
3969
3998
|
|
|
3999
|
+
/**
|
|
4000
|
+
* Time conversion utilities
|
|
4001
|
+
* Functions for parsing and converting time strings
|
|
4002
|
+
*/
|
|
4003
|
+
/**
|
|
4004
|
+
* Parses a time string and returns hours, minutes, and seconds.
|
|
4005
|
+
*
|
|
4006
|
+
* @param timeString - Time string in HH:mm or HH:mm:ss format
|
|
4007
|
+
* @returns Object with hours, minutes, and seconds
|
|
4008
|
+
* @throws Error if the time string is invalid
|
|
4009
|
+
*
|
|
4010
|
+
* @example
|
|
4011
|
+
* ```typescript
|
|
4012
|
+
* parseTime('14:30'); // { hours: 14, minutes: 30, seconds: 0 }
|
|
4013
|
+
* parseTime('09:15:45'); // { hours: 9, minutes: 15, seconds: 45 }
|
|
4014
|
+
* parseTime('23:59:59'); // { hours: 23, minutes: 59, seconds: 59 }
|
|
4015
|
+
* ```
|
|
4016
|
+
*/
|
|
4017
|
+
declare function parseTime(timeString: string): {
|
|
4018
|
+
hours: number;
|
|
4019
|
+
minutes: number;
|
|
4020
|
+
seconds: number;
|
|
4021
|
+
};
|
|
4022
|
+
/**
|
|
4023
|
+
* Converts a time string to total seconds since midnight.
|
|
4024
|
+
*
|
|
4025
|
+
* @param timeString - Time string in HH:mm or HH:mm:ss format
|
|
4026
|
+
* @returns Total seconds since midnight
|
|
4027
|
+
*
|
|
4028
|
+
* @example
|
|
4029
|
+
* ```typescript
|
|
4030
|
+
* timeToSeconds('01:00'); // 3600
|
|
4031
|
+
* timeToSeconds('01:30'); // 5400
|
|
4032
|
+
* timeToSeconds('12:00:00'); // 43200
|
|
4033
|
+
* ```
|
|
4034
|
+
*/
|
|
4035
|
+
declare function timeToSeconds(timeString: string): number;
|
|
4036
|
+
/**
|
|
4037
|
+
* Converts seconds since midnight to a time string.
|
|
4038
|
+
*
|
|
4039
|
+
* @param totalSeconds - Total seconds since midnight
|
|
4040
|
+
* @returns Time string in HH:mm:ss format
|
|
4041
|
+
* @throws Error if seconds is out of valid range
|
|
4042
|
+
*
|
|
4043
|
+
* @example
|
|
4044
|
+
* ```typescript
|
|
4045
|
+
* secondsToTime(3600); // '01:00:00'
|
|
4046
|
+
* secondsToTime(5400); // '01:30:00'
|
|
4047
|
+
* secondsToTime(43200); // '12:00:00'
|
|
4048
|
+
* ```
|
|
4049
|
+
*/
|
|
4050
|
+
declare function secondsToTime(totalSeconds: number): string;
|
|
4051
|
+
|
|
3970
4052
|
/**
|
|
3971
4053
|
* Validates if a string represents a valid time format.
|
|
3972
4054
|
*
|
|
@@ -4036,52 +4118,8 @@ declare function hasSeconds(timeString: string): boolean;
|
|
|
4036
4118
|
declare function sanitizeTimeInput(input: string): string;
|
|
4037
4119
|
|
|
4038
4120
|
/**
|
|
4039
|
-
*
|
|
4040
|
-
*
|
|
4041
|
-
* @param timeString - Time string in HH:mm or HH:mm:ss format
|
|
4042
|
-
* @returns Object with hours, minutes, and seconds
|
|
4043
|
-
* @throws Error if the time string is invalid
|
|
4044
|
-
*
|
|
4045
|
-
* @example
|
|
4046
|
-
* ```typescript
|
|
4047
|
-
* parseTime('14:30'); // { hours: 14, minutes: 30, seconds: 0 }
|
|
4048
|
-
* parseTime('09:15:45'); // { hours: 9, minutes: 15, seconds: 45 }
|
|
4049
|
-
* parseTime('23:59:59'); // { hours: 23, minutes: 59, seconds: 59 }
|
|
4050
|
-
* ```
|
|
4051
|
-
*/
|
|
4052
|
-
declare function parseTime(timeString: string): {
|
|
4053
|
-
hours: number;
|
|
4054
|
-
minutes: number;
|
|
4055
|
-
seconds: number;
|
|
4056
|
-
};
|
|
4057
|
-
/**
|
|
4058
|
-
* Converts a time string to total seconds since midnight.
|
|
4059
|
-
*
|
|
4060
|
-
* @param timeString - Time string in HH:mm or HH:mm:ss format
|
|
4061
|
-
* @returns Total seconds since midnight
|
|
4062
|
-
*
|
|
4063
|
-
* @example
|
|
4064
|
-
* ```typescript
|
|
4065
|
-
* timeToSeconds('01:00'); // 3600
|
|
4066
|
-
* timeToSeconds('01:30'); // 5400
|
|
4067
|
-
* timeToSeconds('12:00:00'); // 43200
|
|
4068
|
-
* ```
|
|
4069
|
-
*/
|
|
4070
|
-
declare function timeToSeconds(timeString: string): number;
|
|
4071
|
-
/**
|
|
4072
|
-
* Converts seconds since midnight to a time string.
|
|
4073
|
-
*
|
|
4074
|
-
* @param totalSeconds - Total seconds since midnight
|
|
4075
|
-
* @returns Time string in HH:mm:ss format
|
|
4076
|
-
*
|
|
4077
|
-
* @example
|
|
4078
|
-
* ```typescript
|
|
4079
|
-
* secondsToTime(3600); // '01:00:00'
|
|
4080
|
-
* secondsToTime(5400); // '01:30:00'
|
|
4081
|
-
* secondsToTime(43200); // '12:00:00'
|
|
4082
|
-
* ```
|
|
4121
|
+
* Time comparison operations
|
|
4083
4122
|
*/
|
|
4084
|
-
declare function secondsToTime(totalSeconds: number): string;
|
|
4085
4123
|
/**
|
|
4086
4124
|
* Compares two time strings and returns -1, 0, or 1.
|
|
4087
4125
|
*
|
|
@@ -4098,21 +4136,28 @@ declare function secondsToTime(totalSeconds: number): string;
|
|
|
4098
4136
|
*/
|
|
4099
4137
|
declare function compareTimes(time1: string, time2: string): number;
|
|
4100
4138
|
/**
|
|
4101
|
-
* Checks if
|
|
4139
|
+
* Checks if two dates are on the same day.
|
|
4102
4140
|
*
|
|
4103
|
-
* @param
|
|
4104
|
-
* @param
|
|
4105
|
-
* @
|
|
4106
|
-
* @returns true if time is within range, false otherwise
|
|
4141
|
+
* @param date1 - First date
|
|
4142
|
+
* @param date2 - Second date
|
|
4143
|
+
* @returns true if dates are on the same day, false otherwise
|
|
4107
4144
|
*
|
|
4108
4145
|
* @example
|
|
4109
4146
|
* ```typescript
|
|
4110
|
-
*
|
|
4111
|
-
*
|
|
4112
|
-
*
|
|
4147
|
+
* const date1 = new Date(2024, 0, 15, 10, 30);
|
|
4148
|
+
* const date2 = new Date(2024, 0, 15, 14, 45);
|
|
4149
|
+
* isSameDay(date1, date2); // true
|
|
4150
|
+
*
|
|
4151
|
+
* const date3 = new Date(2024, 0, 16, 10, 30);
|
|
4152
|
+
* isSameDay(date1, date3); // false
|
|
4113
4153
|
* ```
|
|
4114
4154
|
*/
|
|
4115
|
-
declare function
|
|
4155
|
+
declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
4156
|
+
|
|
4157
|
+
/**
|
|
4158
|
+
* Time calculation operations
|
|
4159
|
+
* Functions for time arithmetic and differences
|
|
4160
|
+
*/
|
|
4116
4161
|
/**
|
|
4117
4162
|
* Adds a duration (in minutes) to a time string.
|
|
4118
4163
|
*
|
|
@@ -4143,6 +4188,31 @@ declare function addMinutesToTime(timeString: string, minutes: number): string;
|
|
|
4143
4188
|
* ```
|
|
4144
4189
|
*/
|
|
4145
4190
|
declare function timeDifferenceMinutes(time1: string, time2: string): number;
|
|
4191
|
+
|
|
4192
|
+
/**
|
|
4193
|
+
* Time range checking operations
|
|
4194
|
+
*/
|
|
4195
|
+
/**
|
|
4196
|
+
* Checks if a time string falls within a given time range.
|
|
4197
|
+
*
|
|
4198
|
+
* @param time - Time to check
|
|
4199
|
+
* @param startTime - Start of range (inclusive)
|
|
4200
|
+
* @param endTime - End of range (inclusive)
|
|
4201
|
+
* @returns true if time is within range, false otherwise
|
|
4202
|
+
*
|
|
4203
|
+
* @example
|
|
4204
|
+
* ```typescript
|
|
4205
|
+
* isTimeInRange('10:00', '09:00', '11:00'); // true
|
|
4206
|
+
* isTimeInRange('08:00', '09:00', '11:00'); // false
|
|
4207
|
+
* isTimeInRange('09:00', '09:00', '11:00'); // true (inclusive)
|
|
4208
|
+
* ```
|
|
4209
|
+
*/
|
|
4210
|
+
declare function isTimeInRange(time: string, startTime: string, endTime: string): boolean;
|
|
4211
|
+
|
|
4212
|
+
/**
|
|
4213
|
+
* Time utility functions
|
|
4214
|
+
* Domain-specific utilities
|
|
4215
|
+
*/
|
|
4146
4216
|
/**
|
|
4147
4217
|
* Safely formats time with a fallback value.
|
|
4148
4218
|
*
|
|
@@ -4217,33 +4287,112 @@ declare function getCurrentTimeBangla(options?: {
|
|
|
4217
4287
|
includeSeconds?: boolean;
|
|
4218
4288
|
use12Hour?: boolean;
|
|
4219
4289
|
}): string;
|
|
4290
|
+
|
|
4220
4291
|
/**
|
|
4221
|
-
*
|
|
4292
|
+
* Formats a Gregorian date as a Bangla calendar date string with Bangla text.
|
|
4222
4293
|
*
|
|
4223
|
-
*
|
|
4224
|
-
*
|
|
4225
|
-
*
|
|
4294
|
+
* This function converts a Gregorian date to the Bangla calendar and formats it
|
|
4295
|
+
* with Bangla digits and month names. It's ideal for displaying dates in
|
|
4296
|
+
* Bangla cultural contexts.
|
|
4297
|
+
*
|
|
4298
|
+
* **Output Format:**
|
|
4299
|
+
* - Default: "day month year" (e.g., "১৫ বৈশাখ ১৪৩১")
|
|
4300
|
+
* - With weekday: "weekday day month year" (e.g., "রবিবার ১৫ বৈশাখ ১৪৩১")
|
|
4301
|
+
* - Without year: "day month" (e.g., "১৫ বৈশাখ")
|
|
4302
|
+
*
|
|
4303
|
+
* **Weekday Names:**
|
|
4304
|
+
* - রবিবার (Robibar) - Sunday
|
|
4305
|
+
* - সোমবার (Sombar) - Monday
|
|
4306
|
+
* - মঙ্গলবার (Mongolbar) - Tuesday
|
|
4307
|
+
* - বুধবার (Budhbar) - Wednesday
|
|
4308
|
+
* - বৃহস্পতিবার (Brihaspotibar) - Thursday
|
|
4309
|
+
* - শুক্রবার (Shukrobar) - Friday
|
|
4310
|
+
* - শনিবার (Shonibar) - Saturday
|
|
4311
|
+
*
|
|
4312
|
+
* @param date - Gregorian Date object to format
|
|
4313
|
+
* @param options - Formatting options
|
|
4314
|
+
* @param options.includeYear - Include Bangla year in output (default: true)
|
|
4315
|
+
* @param options.includeWeekday - Include weekday name in output (default: false)
|
|
4316
|
+
* @returns Formatted Bangla date string
|
|
4226
4317
|
*
|
|
4227
4318
|
* @example
|
|
4319
|
+
* Basic formatting (with year):
|
|
4228
4320
|
* ```typescript
|
|
4229
|
-
*
|
|
4230
|
-
*
|
|
4231
|
-
*
|
|
4321
|
+
* getBanglaDate(new Date(2024, 3, 14));
|
|
4322
|
+
* // "১ বৈশাখ ১৪৩১" (Pohela Boishakh 1431)
|
|
4323
|
+
* ```
|
|
4232
4324
|
*
|
|
4233
|
-
*
|
|
4234
|
-
*
|
|
4325
|
+
* @example
|
|
4326
|
+
* Without year:
|
|
4327
|
+
* ```typescript
|
|
4328
|
+
* getBanglaDate(new Date(2024, 3, 14), { includeYear: false });
|
|
4329
|
+
* // "১ বৈশাখ"
|
|
4330
|
+
* ```
|
|
4331
|
+
*
|
|
4332
|
+
* @example
|
|
4333
|
+
* With weekday:
|
|
4334
|
+
* ```typescript
|
|
4335
|
+
* getBanglaDate(new Date(2024, 3, 14), { includeWeekday: true });
|
|
4336
|
+
* // "রবিবার ১ বৈশাখ ১৪৩১" (if April 14, 2024 is Sunday)
|
|
4337
|
+
* ```
|
|
4338
|
+
*
|
|
4339
|
+
* @example
|
|
4340
|
+
* With weekday, without year:
|
|
4341
|
+
* ```typescript
|
|
4342
|
+
* getBanglaDate(
|
|
4343
|
+
* new Date(2024, 3, 14),
|
|
4344
|
+
* { includeWeekday: true, includeYear: false }
|
|
4345
|
+
* );
|
|
4346
|
+
* // "রবিবার ১ বৈশাখ"
|
|
4347
|
+
* ```
|
|
4348
|
+
*
|
|
4349
|
+
* @example
|
|
4350
|
+
* Display current date in Bangla:
|
|
4351
|
+
* ```typescript
|
|
4352
|
+
* const today = new Date();
|
|
4353
|
+
* const bengaliToday = getBanglaDate(today, { includeWeekday: true });
|
|
4354
|
+
* console.log(`আজ: ${bengaliToday}`);
|
|
4355
|
+
* // "আজ: মঙ্গলবার ২৪ পৌষ ১৪৩১" (example)
|
|
4356
|
+
* ```
|
|
4357
|
+
*
|
|
4358
|
+
* @example
|
|
4359
|
+
* Birthday display:
|
|
4360
|
+
* ```typescript
|
|
4361
|
+
* const birthday = new Date(2024, 6, 15);
|
|
4362
|
+
* const bengaliBirthday = getBanglaDate(birthday);
|
|
4363
|
+
* console.log(`জন্মদিন: ${bengaliBirthday}`);
|
|
4364
|
+
* // "জন্মদিন: ১ শ্রাবণ ১৪৩১" (example)
|
|
4365
|
+
* ```
|
|
4366
|
+
*
|
|
4367
|
+
* @example
|
|
4368
|
+
* Event calendar:
|
|
4369
|
+
* ```typescript
|
|
4370
|
+
* const events = [
|
|
4371
|
+
* new Date(2024, 3, 14),
|
|
4372
|
+
* new Date(2024, 11, 16),
|
|
4373
|
+
* new Date(2025, 1, 21)
|
|
4374
|
+
* ];
|
|
4375
|
+
* events.forEach(event => {
|
|
4376
|
+
* console.log(getBanglaDate(event, { includeWeekday: true }));
|
|
4377
|
+
* });
|
|
4378
|
+
* // "রবিবার ১ বৈশাখ ১৪৩১"
|
|
4379
|
+
* // "সোমবার ২ পৌষ ১৪৩১"
|
|
4380
|
+
* // "শুক্রবার ৯ ফাল্গুন ১৪৩১"
|
|
4235
4381
|
* ```
|
|
4236
4382
|
*/
|
|
4237
|
-
declare function
|
|
4383
|
+
declare function getBanglaDate(date: Date, options?: {
|
|
4384
|
+
includeYear?: boolean;
|
|
4385
|
+
includeWeekday?: boolean;
|
|
4386
|
+
}): string;
|
|
4238
4387
|
|
|
4239
4388
|
/**
|
|
4240
|
-
* Converts a Gregorian date to
|
|
4389
|
+
* Converts a Gregorian date to Bangla calendar date.
|
|
4241
4390
|
*
|
|
4242
4391
|
* This function performs accurate conversion from the Gregorian calendar
|
|
4243
|
-
* to the
|
|
4244
|
-
* The
|
|
4392
|
+
* to the Bangla calendar (also known as Bangla calendar or Bangla calendar).
|
|
4393
|
+
* The Bangla calendar year is typically 593-594 years behind the Gregorian calendar.
|
|
4245
4394
|
*
|
|
4246
|
-
* **
|
|
4395
|
+
* **Bangla Calendar System:**
|
|
4247
4396
|
* - New Year (Pohela Boishakh): April 14 (Gregorian)
|
|
4248
4397
|
* - 12 months with varying lengths (31, 30, or 29/30 days)
|
|
4249
4398
|
* - Leap year adjustment in Falgun (month 11)
|
|
@@ -4263,29 +4412,29 @@ declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
|
4263
4412
|
* 12. চৈত্র (Chaitra) - 30 days
|
|
4264
4413
|
*
|
|
4265
4414
|
* @param date - Gregorian Date object to convert
|
|
4266
|
-
* @returns
|
|
4415
|
+
* @returns Bangla date object with year, month (1-12), and day properties
|
|
4267
4416
|
*
|
|
4268
4417
|
* @example
|
|
4269
|
-
*
|
|
4418
|
+
* Bangla New Year (Pohela Boishakh):
|
|
4270
4419
|
* ```typescript
|
|
4271
|
-
*
|
|
4420
|
+
* toBangla(new Date(2024, 3, 14)); // April 14, 2024
|
|
4272
4421
|
* // { year: 1431, month: 1, day: 1 }
|
|
4273
4422
|
* ```
|
|
4274
4423
|
*
|
|
4275
4424
|
* @example
|
|
4276
4425
|
* Mid-year dates:
|
|
4277
4426
|
* ```typescript
|
|
4278
|
-
*
|
|
4427
|
+
* toBangla(new Date(2024, 6, 15)); // July 15, 2024
|
|
4279
4428
|
* // { year: 1431, month: 4, day: 1 } (approx - Srabon)
|
|
4280
4429
|
*
|
|
4281
|
-
*
|
|
4430
|
+
* toBangla(new Date(2024, 11, 31)); // December 31, 2024
|
|
4282
4431
|
* // { year: 1431, month: 9, day: 17 } (approx - Poush)
|
|
4283
4432
|
* ```
|
|
4284
4433
|
*
|
|
4285
4434
|
* @example
|
|
4286
|
-
* Before
|
|
4435
|
+
* Before Bangla New Year (same Gregorian year):
|
|
4287
4436
|
* ```typescript
|
|
4288
|
-
*
|
|
4437
|
+
* toBangla(new Date(2024, 0, 15)); // January 15, 2024
|
|
4289
4438
|
* // { year: 1430, month: 10, day: 2 } (approx - Magh)
|
|
4290
4439
|
* ```
|
|
4291
4440
|
*
|
|
@@ -4293,7 +4442,7 @@ declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
|
4293
4442
|
* Practical usage:
|
|
4294
4443
|
* ```typescript
|
|
4295
4444
|
* const today = new Date();
|
|
4296
|
-
* const bengaliDate =
|
|
4445
|
+
* const bengaliDate = toBangla(today);
|
|
4297
4446
|
* console.log(`${bengaliDate.day}/${bengaliDate.month}/${bengaliDate.year}`);
|
|
4298
4447
|
* // "24/9/1431" (example)
|
|
4299
4448
|
* ```
|
|
@@ -4302,57 +4451,57 @@ declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
|
4302
4451
|
* Leap year handling:
|
|
4303
4452
|
* ```typescript
|
|
4304
4453
|
* // 2020 is a leap year, affecting Falgun (month 11)
|
|
4305
|
-
*
|
|
4306
|
-
* // Month 11 (Falgun) will have 30 days in
|
|
4454
|
+
* toBangla(new Date(2021, 2, 14)); // March 14, 2021
|
|
4455
|
+
* // Month 11 (Falgun) will have 30 days in Bangla year 1427
|
|
4307
4456
|
* ```
|
|
4308
4457
|
*/
|
|
4309
|
-
declare function
|
|
4458
|
+
declare function toBanglaCalendar(date: Date): {
|
|
4310
4459
|
year: number;
|
|
4311
4460
|
month: number;
|
|
4312
4461
|
day: number;
|
|
4313
4462
|
};
|
|
4314
4463
|
|
|
4315
4464
|
/**
|
|
4316
|
-
* Converts a
|
|
4465
|
+
* Converts a Bangla calendar date to Gregorian date.
|
|
4317
4466
|
*
|
|
4318
|
-
* This function performs the reverse operation of
|
|
4319
|
-
* from the
|
|
4467
|
+
* This function performs the reverse operation of toBangla, converting
|
|
4468
|
+
* from the Bangla calendar to the Gregorian calendar. It accurately
|
|
4320
4469
|
* handles month boundaries, year transitions, and leap years.
|
|
4321
4470
|
*
|
|
4322
4471
|
* **Input Format:**
|
|
4323
|
-
* - year:
|
|
4324
|
-
* - month:
|
|
4472
|
+
* - year: Bangla year (positive integer)
|
|
4473
|
+
* - month: Bangla month (1-12)
|
|
4325
4474
|
* - day: Day of month (1-31, depending on month)
|
|
4326
4475
|
*
|
|
4327
|
-
* **
|
|
4328
|
-
* -
|
|
4329
|
-
* - 1 Boishakh (
|
|
4476
|
+
* **Bangla to Gregorian Mapping:**
|
|
4477
|
+
* - Bangla year + 593 or 594 = Gregorian year (depends on date)
|
|
4478
|
+
* - 1 Boishakh (Bangla New Year) = April 14 (Gregorian)
|
|
4330
4479
|
*
|
|
4331
|
-
* @param bengaliDate -
|
|
4480
|
+
* @param bengaliDate - Bangla date object with year, month, and day properties
|
|
4332
4481
|
* @returns Gregorian Date object
|
|
4333
|
-
* @throws {Error} If the
|
|
4482
|
+
* @throws {Error} If the Bangla date is invalid
|
|
4334
4483
|
*
|
|
4335
4484
|
* @example
|
|
4336
|
-
*
|
|
4485
|
+
* Bangla New Year to Gregorian:
|
|
4337
4486
|
* ```typescript
|
|
4338
|
-
*
|
|
4487
|
+
* fromBangla({ year: 1431, month: 1, day: 1 });
|
|
4339
4488
|
* // Date object for April 14, 2024 (Pohela Boishakh)
|
|
4340
4489
|
* ```
|
|
4341
4490
|
*
|
|
4342
4491
|
* @example
|
|
4343
4492
|
* Mid-year conversions:
|
|
4344
4493
|
* ```typescript
|
|
4345
|
-
*
|
|
4494
|
+
* fromBangla({ year: 1431, month: 6, day: 15 });
|
|
4346
4495
|
* // Date object for October 1, 2024 (approx - Ashwin)
|
|
4347
4496
|
*
|
|
4348
|
-
*
|
|
4497
|
+
* fromBangla({ year: 1431, month: 9, day: 1 });
|
|
4349
4498
|
* // Date object for December 16, 2024 (approx - Poush)
|
|
4350
4499
|
* ```
|
|
4351
4500
|
*
|
|
4352
4501
|
* @example
|
|
4353
4502
|
* End of year:
|
|
4354
4503
|
* ```typescript
|
|
4355
|
-
*
|
|
4504
|
+
* fromBangla({ year: 1431, month: 12, day: 30 });
|
|
4356
4505
|
* // Date object for April 13, 2025 (last day before new year)
|
|
4357
4506
|
* ```
|
|
4358
4507
|
*
|
|
@@ -4360,7 +4509,7 @@ declare function toBengali(date: Date): {
|
|
|
4360
4509
|
* Practical usage (event scheduling):
|
|
4361
4510
|
* ```typescript
|
|
4362
4511
|
* const bengaliEvent = { year: 1431, month: 1, day: 1 };
|
|
4363
|
-
* const gregorianDate =
|
|
4512
|
+
* const gregorianDate = fromBangla(bengaliEvent);
|
|
4364
4513
|
* console.log(`Event date: ${gregorianDate.toLocaleDateString()}`);
|
|
4365
4514
|
* // "Event date: 4/14/2024"
|
|
4366
4515
|
* ```
|
|
@@ -4369,7 +4518,7 @@ declare function toBengali(date: Date): {
|
|
|
4369
4518
|
* Leap year handling:
|
|
4370
4519
|
* ```typescript
|
|
4371
4520
|
* // Falgun 30 in a leap year
|
|
4372
|
-
*
|
|
4521
|
+
* fromBangla({ year: 1427, month: 11, day: 30 });
|
|
4373
4522
|
* // Valid conversion (2020 is a leap year)
|
|
4374
4523
|
*
|
|
4375
4524
|
* // Falgun 30 in a non-leap year would be invalid
|
|
@@ -4380,291 +4529,194 @@ declare function toBengali(date: Date): {
|
|
|
4380
4529
|
* Round-trip conversion:
|
|
4381
4530
|
* ```typescript
|
|
4382
4531
|
* const original = new Date(2024, 6, 15);
|
|
4383
|
-
* const bengali =
|
|
4384
|
-
* const converted =
|
|
4532
|
+
* const bengali = toBangla(original);
|
|
4533
|
+
* const converted = fromBangla(bengali);
|
|
4385
4534
|
* // converted should equal original date
|
|
4386
4535
|
* ```
|
|
4387
4536
|
*/
|
|
4388
|
-
declare function
|
|
4537
|
+
declare function fromBanglaCalendar(b: {
|
|
4389
4538
|
year: number;
|
|
4390
4539
|
month: number;
|
|
4391
4540
|
day: number;
|
|
4392
4541
|
}): Date;
|
|
4393
4542
|
|
|
4394
4543
|
/**
|
|
4395
|
-
*
|
|
4396
|
-
*
|
|
4397
|
-
* This function converts a Gregorian date to the Bengali calendar and formats it
|
|
4398
|
-
* with Bengali digits and month names. It's ideal for displaying dates in
|
|
4399
|
-
* Bengali cultural contexts.
|
|
4400
|
-
*
|
|
4401
|
-
* **Output Format:**
|
|
4402
|
-
* - Default: "day month year" (e.g., "১৫ বৈশাখ ১৪৩১")
|
|
4403
|
-
* - With weekday: "weekday day month year" (e.g., "রবিবার ১৫ বৈশাখ ১৪৩১")
|
|
4404
|
-
* - Without year: "day month" (e.g., "১৫ বৈশাখ")
|
|
4405
|
-
*
|
|
4406
|
-
* **Weekday Names:**
|
|
4407
|
-
* - রবিবার (Robibar) - Sunday
|
|
4408
|
-
* - সোমবার (Sombar) - Monday
|
|
4409
|
-
* - মঙ্গলবার (Mongolbar) - Tuesday
|
|
4410
|
-
* - বুধবার (Budhbar) - Wednesday
|
|
4411
|
-
* - বৃহস্পতিবার (Brihaspotibar) - Thursday
|
|
4412
|
-
* - শুক্রবার (Shukrobar) - Friday
|
|
4413
|
-
* - শনিবার (Shonibar) - Saturday
|
|
4414
|
-
*
|
|
4415
|
-
* @param date - Gregorian Date object to format
|
|
4416
|
-
* @param options - Formatting options
|
|
4417
|
-
* @param options.includeYear - Include Bengali year in output (default: true)
|
|
4418
|
-
* @param options.includeWeekday - Include weekday name in output (default: false)
|
|
4419
|
-
* @returns Formatted Bengali date string
|
|
4420
|
-
*
|
|
4421
|
-
* @example
|
|
4422
|
-
* Basic formatting (with year):
|
|
4423
|
-
* ```typescript
|
|
4424
|
-
* getBengaliDate(new Date(2024, 3, 14));
|
|
4425
|
-
* // "১ বৈশাখ ১৪৩১" (Pohela Boishakh 1431)
|
|
4426
|
-
* ```
|
|
4427
|
-
*
|
|
4428
|
-
* @example
|
|
4429
|
-
* Without year:
|
|
4430
|
-
* ```typescript
|
|
4431
|
-
* getBengaliDate(new Date(2024, 3, 14), { includeYear: false });
|
|
4432
|
-
* // "১ বৈশাখ"
|
|
4433
|
-
* ```
|
|
4434
|
-
*
|
|
4435
|
-
* @example
|
|
4436
|
-
* With weekday:
|
|
4437
|
-
* ```typescript
|
|
4438
|
-
* getBengaliDate(new Date(2024, 3, 14), { includeWeekday: true });
|
|
4439
|
-
* // "রবিবার ১ বৈশাখ ১৪৩১" (if April 14, 2024 is Sunday)
|
|
4440
|
-
* ```
|
|
4441
|
-
*
|
|
4442
|
-
* @example
|
|
4443
|
-
* With weekday, without year:
|
|
4444
|
-
* ```typescript
|
|
4445
|
-
* getBengaliDate(
|
|
4446
|
-
* new Date(2024, 3, 14),
|
|
4447
|
-
* { includeWeekday: true, includeYear: false }
|
|
4448
|
-
* );
|
|
4449
|
-
* // "রবিবার ১ বৈশাখ"
|
|
4450
|
-
* ```
|
|
4451
|
-
*
|
|
4452
|
-
* @example
|
|
4453
|
-
* Display current date in Bengali:
|
|
4454
|
-
* ```typescript
|
|
4455
|
-
* const today = new Date();
|
|
4456
|
-
* const bengaliToday = getBengaliDate(today, { includeWeekday: true });
|
|
4457
|
-
* console.log(`আজ: ${bengaliToday}`);
|
|
4458
|
-
* // "আজ: মঙ্গলবার ২৪ পৌষ ১৪৩১" (example)
|
|
4459
|
-
* ```
|
|
4460
|
-
*
|
|
4461
|
-
* @example
|
|
4462
|
-
* Birthday display:
|
|
4463
|
-
* ```typescript
|
|
4464
|
-
* const birthday = new Date(2024, 6, 15);
|
|
4465
|
-
* const bengaliBirthday = getBengaliDate(birthday);
|
|
4466
|
-
* console.log(`জন্মদিন: ${bengaliBirthday}`);
|
|
4467
|
-
* // "জন্মদিন: ১ শ্রাবণ ১৪৩১" (example)
|
|
4468
|
-
* ```
|
|
4469
|
-
*
|
|
4470
|
-
* @example
|
|
4471
|
-
* Event calendar:
|
|
4472
|
-
* ```typescript
|
|
4473
|
-
* const events = [
|
|
4474
|
-
* new Date(2024, 3, 14),
|
|
4475
|
-
* new Date(2024, 11, 16),
|
|
4476
|
-
* new Date(2025, 1, 21)
|
|
4477
|
-
* ];
|
|
4478
|
-
* events.forEach(event => {
|
|
4479
|
-
* console.log(getBengaliDate(event, { includeWeekday: true }));
|
|
4480
|
-
* });
|
|
4481
|
-
* // "রবিবার ১ বৈশাখ ১৪৩১"
|
|
4482
|
-
* // "সোমবার ২ পৌষ ১৪৩১"
|
|
4483
|
-
* // "শুক্রবার ৯ ফাল্গুন ১৪৩১"
|
|
4484
|
-
* ```
|
|
4485
|
-
*/
|
|
4486
|
-
declare function getBengaliDate(date: Date, options?: {
|
|
4487
|
-
includeYear?: boolean;
|
|
4488
|
-
includeWeekday?: boolean;
|
|
4489
|
-
}): string;
|
|
4490
|
-
|
|
4491
|
-
/**
|
|
4492
|
-
* Validation utilities for Bengali calendar operations.
|
|
4544
|
+
* Validation utilities for Bangla calendar operations.
|
|
4493
4545
|
*
|
|
4494
|
-
* This module provides non-throwing validation functions for
|
|
4546
|
+
* This module provides non-throwing validation functions for Bangla calendar dates.
|
|
4495
4547
|
* All validators return boolean values or null for sanitization functions.
|
|
4496
4548
|
*
|
|
4497
4549
|
* @module calendar/validate
|
|
4498
4550
|
*/
|
|
4499
4551
|
/**
|
|
4500
|
-
* Checks if a year is a valid
|
|
4552
|
+
* Checks if a year is a valid Bangla calendar year.
|
|
4501
4553
|
*
|
|
4502
|
-
* Valid
|
|
4554
|
+
* Valid Bangla years are positive integers. The Bangla calendar
|
|
4503
4555
|
* is typically 593-594 years behind the Gregorian calendar.
|
|
4504
4556
|
*
|
|
4505
4557
|
* @param year - Year to validate
|
|
4506
|
-
* @returns true if year is a valid
|
|
4558
|
+
* @returns true if year is a valid Bangla year, false otherwise
|
|
4507
4559
|
*
|
|
4508
4560
|
* @example
|
|
4509
4561
|
* Valid years:
|
|
4510
4562
|
* ```typescript
|
|
4511
|
-
*
|
|
4512
|
-
*
|
|
4513
|
-
*
|
|
4563
|
+
* isValidBanglaYear(1431); // true
|
|
4564
|
+
* isValidBanglaYear(1400); // true
|
|
4565
|
+
* isValidBanglaYear(1); // true
|
|
4514
4566
|
* ```
|
|
4515
4567
|
*
|
|
4516
4568
|
* @example
|
|
4517
4569
|
* Invalid years:
|
|
4518
4570
|
* ```typescript
|
|
4519
|
-
*
|
|
4520
|
-
*
|
|
4521
|
-
*
|
|
4522
|
-
*
|
|
4571
|
+
* isValidBanglaYear(0); // false
|
|
4572
|
+
* isValidBanglaYear(-10); // false
|
|
4573
|
+
* isValidBanglaYear(1431.5); // false
|
|
4574
|
+
* isValidBanglaYear('1431' as any); // false
|
|
4523
4575
|
* ```
|
|
4524
4576
|
*/
|
|
4525
|
-
declare function
|
|
4577
|
+
declare function isValidBanglaYear(year: number): boolean;
|
|
4526
4578
|
/**
|
|
4527
|
-
* Checks if a month is a valid
|
|
4579
|
+
* Checks if a month number is a valid Bangla calendar month (1-12).
|
|
4528
4580
|
*
|
|
4529
|
-
*
|
|
4581
|
+
* Bangla calendar has 12 months:
|
|
4530
4582
|
* 1=বৈশাখ, 2=জ্যৈষ্ঠ, 3=আষাঢ়, 4=শ্রাবণ, 5=ভাদ্র, 6=আশ্বিন,
|
|
4531
4583
|
* 7=কার্তিক, 8=অগ্রহায়ণ, 9=পৌষ, 10=মাঘ, 11=ফাল্গুন, 12=চৈত্র
|
|
4532
4584
|
*
|
|
4533
|
-
* @param month - Month to validate (1-12)
|
|
4585
|
+
* @param month - Month number to validate (1-12)
|
|
4534
4586
|
* @returns true if month is valid, false otherwise
|
|
4535
4587
|
*
|
|
4536
4588
|
* @example
|
|
4537
4589
|
* Valid months:
|
|
4538
4590
|
* ```typescript
|
|
4539
|
-
*
|
|
4540
|
-
*
|
|
4541
|
-
*
|
|
4591
|
+
* isValidBanglaMonthNumber(1); // true (Boishakh)
|
|
4592
|
+
* isValidBanglaMonthNumber(6); // true (Ashwin)
|
|
4593
|
+
* isValidBanglaMonthNumber(12); // true (Chaitra)
|
|
4542
4594
|
* ```
|
|
4543
4595
|
*
|
|
4544
4596
|
* @example
|
|
4545
4597
|
* Invalid months:
|
|
4546
4598
|
* ```typescript
|
|
4547
|
-
*
|
|
4548
|
-
*
|
|
4549
|
-
*
|
|
4599
|
+
* isValidBanglaMonthNumber(0); // false
|
|
4600
|
+
* isValidBanglaMonthNumber(13); // false
|
|
4601
|
+
* isValidBanglaMonthNumber(6.5); // false
|
|
4550
4602
|
* ```
|
|
4551
4603
|
*/
|
|
4552
|
-
declare function
|
|
4604
|
+
declare function isValidBanglaMonthNumber(month: number): boolean;
|
|
4553
4605
|
/**
|
|
4554
|
-
* Checks if a day is valid for a given
|
|
4606
|
+
* Checks if a day is valid for a given Bangla month and year.
|
|
4555
4607
|
*
|
|
4556
|
-
*
|
|
4608
|
+
* Bangla calendar month lengths:
|
|
4557
4609
|
* - Months 1-5 (বৈশাখ-ভাদ্র): 31 days
|
|
4558
4610
|
* - Months 6-10 (আশ্বিন-মাঘ): 30 days
|
|
4559
4611
|
* - Month 11 (ফাল্গুন): 29 or 30 days (depends on Gregorian leap year)
|
|
4560
4612
|
* - Month 12 (চৈত্র): 30 days
|
|
4561
4613
|
*
|
|
4562
4614
|
* @param day - Day to validate
|
|
4563
|
-
* @param month -
|
|
4564
|
-
* @param year -
|
|
4615
|
+
* @param month - Bangla month (1-12)
|
|
4616
|
+
* @param year - Bangla year
|
|
4565
4617
|
* @returns true if day is valid for the given month/year, false otherwise
|
|
4566
4618
|
*
|
|
4567
4619
|
* @example
|
|
4568
4620
|
* Valid days:
|
|
4569
4621
|
* ```typescript
|
|
4570
|
-
*
|
|
4571
|
-
*
|
|
4572
|
-
*
|
|
4622
|
+
* isValidBanglaDay(15, 1, 1431); // true (Boishakh has 31 days)
|
|
4623
|
+
* isValidBanglaDay(31, 1, 1431); // true (last day of Boishakh)
|
|
4624
|
+
* isValidBanglaDay(30, 6, 1431); // true (Ashwin has 30 days)
|
|
4573
4625
|
* ```
|
|
4574
4626
|
*
|
|
4575
4627
|
* @example
|
|
4576
4628
|
* Invalid days:
|
|
4577
4629
|
* ```typescript
|
|
4578
|
-
*
|
|
4579
|
-
*
|
|
4580
|
-
*
|
|
4581
|
-
*
|
|
4630
|
+
* isValidBanglaDay(32, 1, 1431); // false (Boishakh has only 31 days)
|
|
4631
|
+
* isValidBanglaDay(31, 6, 1431); // false (Ashwin has only 30 days)
|
|
4632
|
+
* isValidBanglaDay(0, 1, 1431); // false (day must be >= 1)
|
|
4633
|
+
* isValidBanglaDay(15.5, 1, 1431); // false (must be integer)
|
|
4582
4634
|
* ```
|
|
4583
4635
|
*
|
|
4584
4636
|
* @example
|
|
4585
4637
|
* Leap year handling:
|
|
4586
4638
|
* ```typescript
|
|
4587
|
-
* // 1427
|
|
4588
|
-
*
|
|
4639
|
+
* // 1427 Bangla corresponds to 2020 Gregorian (leap year)
|
|
4640
|
+
* isValidBanglaDay(30, 11, 1427); // true (Falgun has 30 days in leap year)
|
|
4589
4641
|
*
|
|
4590
|
-
* // 1428
|
|
4591
|
-
*
|
|
4592
|
-
*
|
|
4642
|
+
* // 1428 Bangla corresponds to 2021 Gregorian (not leap year)
|
|
4643
|
+
* isValidBanglaDay(30, 11, 1428); // false (Falgun has only 29 days)
|
|
4644
|
+
* isValidBanglaDay(29, 11, 1428); // true
|
|
4593
4645
|
* ```
|
|
4594
4646
|
*/
|
|
4595
|
-
declare function
|
|
4647
|
+
declare function isValidBanglaDay(day: number, month: number, year: number): boolean;
|
|
4596
4648
|
/**
|
|
4597
|
-
* Checks if a
|
|
4649
|
+
* Checks if a Bangla date object is valid.
|
|
4598
4650
|
*
|
|
4599
|
-
* A valid
|
|
4651
|
+
* A valid Bangla date object must have valid year, month, and day properties
|
|
4600
4652
|
* that form a valid date combination.
|
|
4601
4653
|
*
|
|
4602
|
-
* @param date -
|
|
4654
|
+
* @param date - Bangla date object with year, month, day properties
|
|
4603
4655
|
* @returns true if the date object is valid, false otherwise
|
|
4604
4656
|
*
|
|
4605
4657
|
* @example
|
|
4606
4658
|
* Valid dates:
|
|
4607
4659
|
* ```typescript
|
|
4608
|
-
*
|
|
4609
|
-
*
|
|
4610
|
-
*
|
|
4660
|
+
* isValidBanglaDate({ year: 1431, month: 1, day: 1 }); // true
|
|
4661
|
+
* isValidBanglaDate({ year: 1431, month: 6, day: 15 }); // true
|
|
4662
|
+
* isValidBanglaDate({ year: 1431, month: 12, day: 30 }); // true
|
|
4611
4663
|
* ```
|
|
4612
4664
|
*
|
|
4613
4665
|
* @example
|
|
4614
4666
|
* Invalid dates:
|
|
4615
4667
|
* ```typescript
|
|
4616
|
-
*
|
|
4617
|
-
*
|
|
4618
|
-
*
|
|
4619
|
-
*
|
|
4668
|
+
* isValidBanglaDate({ year: 1431, month: 13, day: 1 }); // false (invalid month)
|
|
4669
|
+
* isValidBanglaDate({ year: 1431, month: 1, day: 32 }); // false (day > 31)
|
|
4670
|
+
* isValidBanglaDate({ year: 0, month: 1, day: 1 }); // false (invalid year)
|
|
4671
|
+
* isValidBanglaDate({ year: 1431, month: 6, day: 31 }); // false (Ashwin has only 30 days)
|
|
4620
4672
|
* ```
|
|
4621
4673
|
*
|
|
4622
4674
|
* @example
|
|
4623
4675
|
* Type validation:
|
|
4624
4676
|
* ```typescript
|
|
4625
|
-
*
|
|
4626
|
-
*
|
|
4627
|
-
*
|
|
4677
|
+
* isValidBanglaDate({ year: 1431, month: 1 } as any); // false (missing day)
|
|
4678
|
+
* isValidBanglaDate({ year: '1431', month: 1, day: 1 } as any); // false (year not number)
|
|
4679
|
+
* isValidBanglaDate(null as any); // false
|
|
4628
4680
|
* ```
|
|
4629
4681
|
*/
|
|
4630
|
-
declare function
|
|
4682
|
+
declare function isValidBanglaDate(date: {
|
|
4631
4683
|
year: number;
|
|
4632
4684
|
month: number;
|
|
4633
4685
|
day: number;
|
|
4634
4686
|
}): boolean;
|
|
4635
4687
|
/**
|
|
4636
|
-
* Sanitizes a
|
|
4688
|
+
* Sanitizes a Bangla date object, returning null if invalid.
|
|
4637
4689
|
*
|
|
4638
|
-
* This function validates all components of a
|
|
4690
|
+
* This function validates all components of a Bangla date and returns
|
|
4639
4691
|
* the date object if valid, or null if any component is invalid.
|
|
4640
4692
|
*
|
|
4641
|
-
* @param date -
|
|
4693
|
+
* @param date - Bangla date object to sanitize
|
|
4642
4694
|
* @returns The date object if valid, null otherwise
|
|
4643
4695
|
*
|
|
4644
4696
|
* @example
|
|
4645
4697
|
* Valid dates:
|
|
4646
4698
|
* ```typescript
|
|
4647
|
-
*
|
|
4699
|
+
* sanitizeBanglaDate({ year: 1431, month: 1, day: 1 });
|
|
4648
4700
|
* // { year: 1431, month: 1, day: 1 }
|
|
4649
4701
|
*
|
|
4650
|
-
*
|
|
4702
|
+
* sanitizeBanglaDate({ year: 1431, month: 6, day: 15 });
|
|
4651
4703
|
* // { year: 1431, month: 6, day: 15 }
|
|
4652
4704
|
* ```
|
|
4653
4705
|
*
|
|
4654
4706
|
* @example
|
|
4655
4707
|
* Invalid dates:
|
|
4656
4708
|
* ```typescript
|
|
4657
|
-
*
|
|
4658
|
-
*
|
|
4659
|
-
*
|
|
4660
|
-
*
|
|
4709
|
+
* sanitizeBanglaDate({ year: 1431, month: 13, day: 1 }); // null
|
|
4710
|
+
* sanitizeBanglaDate({ year: 1431, month: 1, day: 32 }); // null
|
|
4711
|
+
* sanitizeBanglaDate({ year: 0, month: 1, day: 1 }); // null
|
|
4712
|
+
* sanitizeBanglaDate(null as any); // null
|
|
4661
4713
|
* ```
|
|
4662
4714
|
*
|
|
4663
4715
|
* @example
|
|
4664
4716
|
* Practical usage (form validation):
|
|
4665
4717
|
* ```typescript
|
|
4666
4718
|
* const userInput = { year: 1431, month: 1, day: 15 };
|
|
4667
|
-
* const validDate =
|
|
4719
|
+
* const validDate = sanitizeBanglaDate(userInput);
|
|
4668
4720
|
*
|
|
4669
4721
|
* if (validDate) {
|
|
4670
4722
|
* console.log('Valid date:', validDate);
|
|
@@ -4673,7 +4725,7 @@ declare function isValidBengaliDate(date: {
|
|
|
4673
4725
|
* }
|
|
4674
4726
|
* ```
|
|
4675
4727
|
*/
|
|
4676
|
-
declare function
|
|
4728
|
+
declare function sanitizeBanglaDate(date: {
|
|
4677
4729
|
year: number;
|
|
4678
4730
|
month: number;
|
|
4679
4731
|
day: number;
|
|
@@ -4684,48 +4736,48 @@ declare function sanitizeBengaliDate(date: {
|
|
|
4684
4736
|
} | null;
|
|
4685
4737
|
|
|
4686
4738
|
/**
|
|
4687
|
-
* Utility functions for
|
|
4739
|
+
* Utility functions for Bangla calendar operations.
|
|
4688
4740
|
*
|
|
4689
|
-
* This module provides helper functions for working with
|
|
4741
|
+
* This module provides helper functions for working with Bangla calendar dates,
|
|
4690
4742
|
* including safe conversions, date arithmetic, comparisons, and formatting utilities.
|
|
4691
4743
|
*
|
|
4692
4744
|
* @module calendar/utils
|
|
4693
4745
|
*/
|
|
4694
4746
|
/**
|
|
4695
|
-
* Safely converts a Gregorian date to
|
|
4747
|
+
* Safely converts a Gregorian date to Bangla date with fallback.
|
|
4696
4748
|
*
|
|
4697
|
-
* Unlike
|
|
4749
|
+
* Unlike toBangla, this function doesn't throw on invalid dates.
|
|
4698
4750
|
* Returns a fallback date object for invalid inputs.
|
|
4699
4751
|
*
|
|
4700
4752
|
* @param date - Gregorian Date object
|
|
4701
4753
|
* @param fallback - Fallback value if conversion fails
|
|
4702
|
-
* @returns
|
|
4754
|
+
* @returns Bangla date object or fallback
|
|
4703
4755
|
*
|
|
4704
4756
|
* @example
|
|
4705
4757
|
* Valid dates:
|
|
4706
4758
|
* ```typescript
|
|
4707
|
-
* const bengaliDate =
|
|
4759
|
+
* const bengaliDate = safeToBangla(new Date(2024, 0, 15));
|
|
4708
4760
|
* // { year: 1430, month: 10, day: 2 }
|
|
4709
4761
|
* ```
|
|
4710
4762
|
*
|
|
4711
4763
|
* @example
|
|
4712
4764
|
* Invalid dates with fallback:
|
|
4713
4765
|
* ```typescript
|
|
4714
|
-
*
|
|
4766
|
+
* safeToBangla(new Date('invalid'), { year: 1431, month: 1, day: 1 });
|
|
4715
4767
|
* // { year: 1431, month: 1, day: 1 }
|
|
4716
4768
|
*
|
|
4717
|
-
*
|
|
4769
|
+
* safeToBangla(null as any, { year: 1431, month: 1, day: 1 });
|
|
4718
4770
|
* // { year: 1431, month: 1, day: 1 }
|
|
4719
4771
|
* ```
|
|
4720
4772
|
*
|
|
4721
4773
|
* @example
|
|
4722
|
-
* Default fallback (current
|
|
4774
|
+
* Default fallback (current Bangla date):
|
|
4723
4775
|
* ```typescript
|
|
4724
|
-
*
|
|
4725
|
-
* // Returns current
|
|
4776
|
+
* safeToBangla(new Date('invalid'));
|
|
4777
|
+
* // Returns current Bangla date
|
|
4726
4778
|
* ```
|
|
4727
4779
|
*/
|
|
4728
|
-
declare function
|
|
4780
|
+
declare function safeToBangla(date: Date, fallback?: {
|
|
4729
4781
|
year: number;
|
|
4730
4782
|
month: number;
|
|
4731
4783
|
day: number;
|
|
@@ -4735,19 +4787,19 @@ declare function safeToBengali(date: Date, fallback?: {
|
|
|
4735
4787
|
day: number;
|
|
4736
4788
|
};
|
|
4737
4789
|
/**
|
|
4738
|
-
* Safely converts a
|
|
4790
|
+
* Safely converts a Bangla date to Gregorian date with fallback.
|
|
4739
4791
|
*
|
|
4740
|
-
* Unlike
|
|
4792
|
+
* Unlike fromBangla, this function doesn't throw on invalid dates.
|
|
4741
4793
|
* Returns a fallback Date object for invalid inputs.
|
|
4742
4794
|
*
|
|
4743
|
-
* @param bengaliDate -
|
|
4795
|
+
* @param bengaliDate - Bangla date object with year, month, day
|
|
4744
4796
|
* @param fallback - Fallback Date if conversion fails (default: current date)
|
|
4745
4797
|
* @returns Gregorian Date object or fallback
|
|
4746
4798
|
*
|
|
4747
4799
|
* @example
|
|
4748
4800
|
* Valid conversions:
|
|
4749
4801
|
* ```typescript
|
|
4750
|
-
*
|
|
4802
|
+
* safeFromBangla({ year: 1431, month: 1, day: 1 });
|
|
4751
4803
|
* // Date object for 2024-04-14
|
|
4752
4804
|
* ```
|
|
4753
4805
|
*
|
|
@@ -4755,101 +4807,101 @@ declare function safeToBengali(date: Date, fallback?: {
|
|
|
4755
4807
|
* Invalid dates with fallback:
|
|
4756
4808
|
* ```typescript
|
|
4757
4809
|
* const fallbackDate = new Date(2024, 0, 1);
|
|
4758
|
-
*
|
|
4810
|
+
* safeFromBangla({ year: 1431, month: 13, day: 1 }, fallbackDate);
|
|
4759
4811
|
* // Returns fallbackDate
|
|
4760
4812
|
*
|
|
4761
|
-
*
|
|
4813
|
+
* safeFromBangla({ year: 0, month: 1, day: 1 }, fallbackDate);
|
|
4762
4814
|
* // Returns fallbackDate
|
|
4763
4815
|
* ```
|
|
4764
4816
|
*/
|
|
4765
|
-
declare function
|
|
4817
|
+
declare function safeFromBangla(bengaliDate: {
|
|
4766
4818
|
year: number;
|
|
4767
4819
|
month: number;
|
|
4768
4820
|
day: number;
|
|
4769
4821
|
}, fallback?: Date): Date;
|
|
4770
4822
|
/**
|
|
4771
|
-
* Gets the number of days in a
|
|
4823
|
+
* Gets the number of days in a Bangla month.
|
|
4772
4824
|
*
|
|
4773
|
-
*
|
|
4825
|
+
* Bangla calendar month lengths (Bangladesh Revised Calendar):
|
|
4774
4826
|
* - Months 1-5: 31 days
|
|
4775
4827
|
* - Months 6-10: 30 days
|
|
4776
|
-
* - Month 11:
|
|
4828
|
+
* - Month 11: 30 or 31 days (31 in leap year)
|
|
4777
4829
|
* - Month 12: 30 days
|
|
4778
4830
|
*
|
|
4779
|
-
* @param month -
|
|
4780
|
-
* @param year -
|
|
4831
|
+
* @param month - Bangla month (1-12)
|
|
4832
|
+
* @param year - Bangla year (for leap year calculation)
|
|
4781
4833
|
* @returns Number of days in the month, or 0 if invalid
|
|
4782
4834
|
*
|
|
4783
4835
|
* @example
|
|
4784
4836
|
* First five months (31 days):
|
|
4785
4837
|
* ```typescript
|
|
4786
|
-
*
|
|
4787
|
-
*
|
|
4788
|
-
*
|
|
4838
|
+
* getBanglaMonthDays(1, 1431); // 31 (Boishakh)
|
|
4839
|
+
* getBanglaMonthDays(2, 1431); // 31 (Joishtho)
|
|
4840
|
+
* getBanglaMonthDays(5, 1431); // 31 (Bhadro)
|
|
4789
4841
|
* ```
|
|
4790
4842
|
*
|
|
4791
4843
|
* @example
|
|
4792
4844
|
* Months 6-10 and 12 (30 days):
|
|
4793
4845
|
* ```typescript
|
|
4794
|
-
*
|
|
4795
|
-
*
|
|
4796
|
-
*
|
|
4846
|
+
* getBanglaMonthDays(6, 1431); // 30 (Ashwin)
|
|
4847
|
+
* getBanglaMonthDays(10, 1431); // 30 (Magh)
|
|
4848
|
+
* getBanglaMonthDays(12, 1431); // 30 (Chaitra)
|
|
4797
4849
|
* ```
|
|
4798
4850
|
*
|
|
4799
4851
|
* @example
|
|
4800
4852
|
* Falgun (month 11) - leap year handling:
|
|
4801
4853
|
* ```typescript
|
|
4802
|
-
*
|
|
4803
|
-
*
|
|
4854
|
+
* getBanglaMonthDays(11, 1426); // 31 (Falgun 1426 → Feb-Mar 2020, leap year)
|
|
4855
|
+
* getBanglaMonthDays(11, 1427); // 30 (Falgun 1427 → Feb-Mar 2021, not leap year)
|
|
4804
4856
|
* ```
|
|
4805
4857
|
*
|
|
4806
4858
|
* @example
|
|
4807
4859
|
* Invalid inputs:
|
|
4808
4860
|
* ```typescript
|
|
4809
|
-
*
|
|
4810
|
-
*
|
|
4861
|
+
* getBanglaMonthDays(0, 1431); // 0
|
|
4862
|
+
* getBanglaMonthDays(13, 1431); // 0
|
|
4811
4863
|
* ```
|
|
4812
4864
|
*/
|
|
4813
|
-
declare function
|
|
4865
|
+
declare function getBanglaMonthDays(month: number, year: number): number;
|
|
4814
4866
|
/**
|
|
4815
|
-
* Adds days to a
|
|
4867
|
+
* Adds days to a Bangla date.
|
|
4816
4868
|
*
|
|
4817
4869
|
* This function properly handles month and year boundaries, including
|
|
4818
4870
|
* varying month lengths and leap years.
|
|
4819
4871
|
*
|
|
4820
|
-
* @param bengaliDate - Starting
|
|
4872
|
+
* @param bengaliDate - Starting Bangla date
|
|
4821
4873
|
* @param days - Number of days to add (can be negative to subtract)
|
|
4822
|
-
* @returns New
|
|
4874
|
+
* @returns New Bangla date object
|
|
4823
4875
|
*
|
|
4824
4876
|
* @example
|
|
4825
4877
|
* Adding days within same month:
|
|
4826
4878
|
* ```typescript
|
|
4827
|
-
*
|
|
4879
|
+
* addDaysToBanglaDate({ year: 1431, month: 1, day: 10 }, 5);
|
|
4828
4880
|
* // { year: 1431, month: 1, day: 15 }
|
|
4829
4881
|
* ```
|
|
4830
4882
|
*
|
|
4831
4883
|
* @example
|
|
4832
4884
|
* Adding days across months:
|
|
4833
4885
|
* ```typescript
|
|
4834
|
-
*
|
|
4886
|
+
* addDaysToBanglaDate({ year: 1431, month: 1, day: 30 }, 5);
|
|
4835
4887
|
* // { year: 1431, month: 2, day: 4 } (crosses to Joishtho)
|
|
4836
4888
|
* ```
|
|
4837
4889
|
*
|
|
4838
4890
|
* @example
|
|
4839
4891
|
* Adding days across years:
|
|
4840
4892
|
* ```typescript
|
|
4841
|
-
*
|
|
4893
|
+
* addDaysToBanglaDate({ year: 1431, month: 12, day: 29 }, 5);
|
|
4842
4894
|
* // { year: 1432, month: 1, day: 3 } (crosses to new year)
|
|
4843
4895
|
* ```
|
|
4844
4896
|
*
|
|
4845
4897
|
* @example
|
|
4846
4898
|
* Subtracting days:
|
|
4847
4899
|
* ```typescript
|
|
4848
|
-
*
|
|
4900
|
+
* addDaysToBanglaDate({ year: 1431, month: 2, day: 5 }, -10);
|
|
4849
4901
|
* // { year: 1431, month: 1, day: 26 }
|
|
4850
4902
|
* ```
|
|
4851
4903
|
*/
|
|
4852
|
-
declare function
|
|
4904
|
+
declare function addDaysToBanglaDate(bengaliDate: {
|
|
4853
4905
|
year: number;
|
|
4854
4906
|
month: number;
|
|
4855
4907
|
day: number;
|
|
@@ -4859,18 +4911,18 @@ declare function addDaysToBengaliDate(bengaliDate: {
|
|
|
4859
4911
|
day: number;
|
|
4860
4912
|
};
|
|
4861
4913
|
/**
|
|
4862
|
-
* Calculates the difference in days between two
|
|
4914
|
+
* Calculates the difference in days between two Bangla dates.
|
|
4863
4915
|
*
|
|
4864
4916
|
* The result is positive if the second date is later, negative if earlier.
|
|
4865
4917
|
*
|
|
4866
|
-
* @param date1 - First
|
|
4867
|
-
* @param date2 - Second
|
|
4918
|
+
* @param date1 - First Bangla date
|
|
4919
|
+
* @param date2 - Second Bangla date
|
|
4868
4920
|
* @returns Number of days between dates (date2 - date1)
|
|
4869
4921
|
*
|
|
4870
4922
|
* @example
|
|
4871
4923
|
* Difference within same month:
|
|
4872
4924
|
* ```typescript
|
|
4873
|
-
* const diff =
|
|
4925
|
+
* const diff = getBanglaDateDifference(
|
|
4874
4926
|
* { year: 1431, month: 1, day: 10 },
|
|
4875
4927
|
* { year: 1431, month: 1, day: 15 }
|
|
4876
4928
|
* );
|
|
@@ -4880,7 +4932,7 @@ declare function addDaysToBengaliDate(bengaliDate: {
|
|
|
4880
4932
|
* @example
|
|
4881
4933
|
* Difference across months:
|
|
4882
4934
|
* ```typescript
|
|
4883
|
-
* const diff =
|
|
4935
|
+
* const diff = getBanglaDateDifference(
|
|
4884
4936
|
* { year: 1431, month: 1, day: 1 },
|
|
4885
4937
|
* { year: 1431, month: 2, day: 1 }
|
|
4886
4938
|
* );
|
|
@@ -4890,7 +4942,7 @@ declare function addDaysToBengaliDate(bengaliDate: {
|
|
|
4890
4942
|
* @example
|
|
4891
4943
|
* Negative difference (earlier date):
|
|
4892
4944
|
* ```typescript
|
|
4893
|
-
* const diff =
|
|
4945
|
+
* const diff = getBanglaDateDifference(
|
|
4894
4946
|
* { year: 1431, month: 1, day: 15 },
|
|
4895
4947
|
* { year: 1431, month: 1, day: 10 }
|
|
4896
4948
|
* );
|
|
@@ -4900,14 +4952,14 @@ declare function addDaysToBengaliDate(bengaliDate: {
|
|
|
4900
4952
|
* @example
|
|
4901
4953
|
* Across years:
|
|
4902
4954
|
* ```typescript
|
|
4903
|
-
* const diff =
|
|
4955
|
+
* const diff = getBanglaDateDifference(
|
|
4904
4956
|
* { year: 1431, month: 1, day: 1 },
|
|
4905
4957
|
* { year: 1432, month: 1, day: 1 }
|
|
4906
4958
|
* );
|
|
4907
|
-
* // 366 (days in
|
|
4959
|
+
* // 366 (days in Bangla year 1431)
|
|
4908
4960
|
* ```
|
|
4909
4961
|
*/
|
|
4910
|
-
declare function
|
|
4962
|
+
declare function getBanglaDateDifference(date1: {
|
|
4911
4963
|
year: number;
|
|
4912
4964
|
month: number;
|
|
4913
4965
|
day: number;
|
|
@@ -4917,16 +4969,16 @@ declare function getBengaliDateDifference(date1: {
|
|
|
4917
4969
|
day: number;
|
|
4918
4970
|
}): number;
|
|
4919
4971
|
/**
|
|
4920
|
-
* Compares two
|
|
4972
|
+
* Compares two Bangla dates.
|
|
4921
4973
|
*
|
|
4922
|
-
* @param date1 - First
|
|
4923
|
-
* @param date2 - Second
|
|
4974
|
+
* @param date1 - First Bangla date
|
|
4975
|
+
* @param date2 - Second Bangla date
|
|
4924
4976
|
* @returns -1 if date1 < date2, 0 if equal, 1 if date1 > date2
|
|
4925
4977
|
*
|
|
4926
4978
|
* @example
|
|
4927
4979
|
* First date is earlier:
|
|
4928
4980
|
* ```typescript
|
|
4929
|
-
*
|
|
4981
|
+
* compareBanglaDates(
|
|
4930
4982
|
* { year: 1431, month: 1, day: 10 },
|
|
4931
4983
|
* { year: 1431, month: 1, day: 15 }
|
|
4932
4984
|
* ); // -1
|
|
@@ -4935,7 +4987,7 @@ declare function getBengaliDateDifference(date1: {
|
|
|
4935
4987
|
* @example
|
|
4936
4988
|
* Dates are equal:
|
|
4937
4989
|
* ```typescript
|
|
4938
|
-
*
|
|
4990
|
+
* compareBanglaDates(
|
|
4939
4991
|
* { year: 1431, month: 1, day: 10 },
|
|
4940
4992
|
* { year: 1431, month: 1, day: 10 }
|
|
4941
4993
|
* ); // 0
|
|
@@ -4944,13 +4996,13 @@ declare function getBengaliDateDifference(date1: {
|
|
|
4944
4996
|
* @example
|
|
4945
4997
|
* First date is later:
|
|
4946
4998
|
* ```typescript
|
|
4947
|
-
*
|
|
4999
|
+
* compareBanglaDates(
|
|
4948
5000
|
* { year: 1431, month: 2, day: 1 },
|
|
4949
5001
|
* { year: 1431, month: 1, day: 31 }
|
|
4950
5002
|
* ); // 1
|
|
4951
5003
|
* ```
|
|
4952
5004
|
*/
|
|
4953
|
-
declare function
|
|
5005
|
+
declare function compareBanglaDates(date1: {
|
|
4954
5006
|
year: number;
|
|
4955
5007
|
month: number;
|
|
4956
5008
|
day: number;
|
|
@@ -4960,9 +5012,9 @@ declare function compareBengaliDates(date1: {
|
|
|
4960
5012
|
day: number;
|
|
4961
5013
|
}): -1 | 0 | 1;
|
|
4962
5014
|
/**
|
|
4963
|
-
* Checks if a
|
|
5015
|
+
* Checks if a Bangla date is in a range (inclusive).
|
|
4964
5016
|
*
|
|
4965
|
-
* @param date -
|
|
5017
|
+
* @param date - Bangla date to check
|
|
4966
5018
|
* @param start - Start of range (inclusive)
|
|
4967
5019
|
* @param end - End of range (inclusive)
|
|
4968
5020
|
* @returns true if date is in range, false otherwise
|
|
@@ -4970,7 +5022,7 @@ declare function compareBengaliDates(date1: {
|
|
|
4970
5022
|
* @example
|
|
4971
5023
|
* Date within range:
|
|
4972
5024
|
* ```typescript
|
|
4973
|
-
*
|
|
5025
|
+
* isBanglaDateInRange(
|
|
4974
5026
|
* { year: 1431, month: 1, day: 15 },
|
|
4975
5027
|
* { year: 1431, month: 1, day: 10 },
|
|
4976
5028
|
* { year: 1431, month: 1, day: 20 }
|
|
@@ -4980,7 +5032,7 @@ declare function compareBengaliDates(date1: {
|
|
|
4980
5032
|
* @example
|
|
4981
5033
|
* Date on boundaries:
|
|
4982
5034
|
* ```typescript
|
|
4983
|
-
*
|
|
5035
|
+
* isBanglaDateInRange(
|
|
4984
5036
|
* { year: 1431, month: 1, day: 10 },
|
|
4985
5037
|
* { year: 1431, month: 1, day: 10 },
|
|
4986
5038
|
* { year: 1431, month: 1, day: 20 }
|
|
@@ -4990,14 +5042,14 @@ declare function compareBengaliDates(date1: {
|
|
|
4990
5042
|
* @example
|
|
4991
5043
|
* Date outside range:
|
|
4992
5044
|
* ```typescript
|
|
4993
|
-
*
|
|
5045
|
+
* isBanglaDateInRange(
|
|
4994
5046
|
* { year: 1431, month: 2, day: 1 },
|
|
4995
5047
|
* { year: 1431, month: 1, day: 10 },
|
|
4996
5048
|
* { year: 1431, month: 1, day: 20 }
|
|
4997
5049
|
* ); // false
|
|
4998
5050
|
* ```
|
|
4999
5051
|
*/
|
|
5000
|
-
declare function
|
|
5052
|
+
declare function isBanglaDateInRange(date: {
|
|
5001
5053
|
year: number;
|
|
5002
5054
|
month: number;
|
|
5003
5055
|
day: number;
|
|
@@ -5011,106 +5063,106 @@ declare function isBengaliDateInRange(date: {
|
|
|
5011
5063
|
day: number;
|
|
5012
5064
|
}): boolean;
|
|
5013
5065
|
/**
|
|
5014
|
-
* Gets the first day of a
|
|
5066
|
+
* Gets the first day of a Bangla month.
|
|
5015
5067
|
*
|
|
5016
|
-
* @param month -
|
|
5017
|
-
* @param year -
|
|
5018
|
-
* @returns
|
|
5068
|
+
* @param month - Bangla month (1-12)
|
|
5069
|
+
* @param year - Bangla year
|
|
5070
|
+
* @returns Bangla date object for the first day of the month
|
|
5019
5071
|
*
|
|
5020
5072
|
* @example
|
|
5021
5073
|
* ```typescript
|
|
5022
|
-
*
|
|
5074
|
+
* getFirstDayOfBanglaMonth(1, 1431);
|
|
5023
5075
|
* // { year: 1431, month: 1, day: 1 }
|
|
5024
5076
|
*
|
|
5025
|
-
*
|
|
5077
|
+
* getFirstDayOfBanglaMonth(6, 1431);
|
|
5026
5078
|
* // { year: 1431, month: 6, day: 1 }
|
|
5027
5079
|
* ```
|
|
5028
5080
|
*/
|
|
5029
|
-
declare function
|
|
5081
|
+
declare function getFirstDayOfBanglaMonth(month: number, year: number): {
|
|
5030
5082
|
year: number;
|
|
5031
5083
|
month: number;
|
|
5032
5084
|
day: number;
|
|
5033
5085
|
};
|
|
5034
5086
|
/**
|
|
5035
|
-
* Gets the last day of a
|
|
5087
|
+
* Gets the last day of a Bangla month.
|
|
5036
5088
|
*
|
|
5037
|
-
* @param month -
|
|
5038
|
-
* @param year -
|
|
5039
|
-
* @returns
|
|
5089
|
+
* @param month - Bangla month (1-12)
|
|
5090
|
+
* @param year - Bangla year
|
|
5091
|
+
* @returns Bangla date object for the last day of the month
|
|
5040
5092
|
*
|
|
5041
5093
|
* @example
|
|
5042
5094
|
* Months with 31 days:
|
|
5043
5095
|
* ```typescript
|
|
5044
|
-
*
|
|
5096
|
+
* getLastDayOfBanglaMonth(1, 1431);
|
|
5045
5097
|
* // { year: 1431, month: 1, day: 31 } (Boishakh)
|
|
5046
5098
|
* ```
|
|
5047
5099
|
*
|
|
5048
5100
|
* @example
|
|
5049
5101
|
* Months with 30 days:
|
|
5050
5102
|
* ```typescript
|
|
5051
|
-
*
|
|
5103
|
+
* getLastDayOfBanglaMonth(6, 1431);
|
|
5052
5104
|
* // { year: 1431, month: 6, day: 30 } (Ashwin)
|
|
5053
5105
|
* ```
|
|
5054
5106
|
*
|
|
5055
5107
|
* @example
|
|
5056
5108
|
* Falgun with leap year:
|
|
5057
5109
|
* ```typescript
|
|
5058
|
-
*
|
|
5059
|
-
* // { year:
|
|
5110
|
+
* getLastDayOfBanglaMonth(11, 1426);
|
|
5111
|
+
* // { year: 1426, month: 11, day: 31 } (leap year)
|
|
5060
5112
|
*
|
|
5061
|
-
*
|
|
5062
|
-
* // { year:
|
|
5113
|
+
* getLastDayOfBanglaMonth(11, 1427);
|
|
5114
|
+
* // { year: 1427, month: 11, day: 30 } (non-leap year)
|
|
5063
5115
|
* ```
|
|
5064
5116
|
*/
|
|
5065
|
-
declare function
|
|
5117
|
+
declare function getLastDayOfBanglaMonth(month: number, year: number): {
|
|
5066
5118
|
year: number;
|
|
5067
5119
|
month: number;
|
|
5068
5120
|
day: number;
|
|
5069
5121
|
};
|
|
5070
5122
|
/**
|
|
5071
|
-
* Checks if a
|
|
5123
|
+
* Checks if a Bangla year is a leap year.
|
|
5072
5124
|
*
|
|
5073
|
-
*
|
|
5074
|
-
* The
|
|
5125
|
+
* Bangla leap years correspond to Gregorian leap years.
|
|
5126
|
+
* The Bangla calendar adjusts Falgun (month 11) from 29 to 30 days in leap years.
|
|
5075
5127
|
*
|
|
5076
|
-
* @param year -
|
|
5128
|
+
* @param year - Bangla year
|
|
5077
5129
|
* @returns true if leap year, false otherwise
|
|
5078
5130
|
*
|
|
5079
5131
|
* @example
|
|
5080
5132
|
* Leap years:
|
|
5081
5133
|
* ```typescript
|
|
5082
|
-
*
|
|
5083
|
-
*
|
|
5134
|
+
* isBanglaLeapYear(1427); // true (corresponds to 2020, a leap year)
|
|
5135
|
+
* isBanglaLeapYear(1420); // true (corresponds to 2013... wait, let me recalculate)
|
|
5084
5136
|
* ```
|
|
5085
5137
|
*
|
|
5086
5138
|
* @example
|
|
5087
5139
|
* Non-leap years:
|
|
5088
5140
|
* ```typescript
|
|
5089
|
-
*
|
|
5090
|
-
*
|
|
5141
|
+
* isBanglaLeapYear(1428); // false (corresponds to 2021)
|
|
5142
|
+
* isBanglaLeapYear(1429); // false (corresponds to 2022)
|
|
5091
5143
|
* ```
|
|
5092
5144
|
*/
|
|
5093
|
-
declare function
|
|
5145
|
+
declare function isBanglaLeapYear(year: number): boolean;
|
|
5094
5146
|
/**
|
|
5095
|
-
* Formats a
|
|
5147
|
+
* Formats a Bangla date as a string with Bangla digits.
|
|
5096
5148
|
*
|
|
5097
|
-
* This is a convenience wrapper around
|
|
5149
|
+
* This is a convenience wrapper around getBanglaDate.
|
|
5098
5150
|
*
|
|
5099
|
-
* @param bengaliDate -
|
|
5151
|
+
* @param bengaliDate - Bangla date object
|
|
5100
5152
|
* @param options - Formatting options
|
|
5101
|
-
* @returns Formatted
|
|
5153
|
+
* @returns Formatted Bangla date string
|
|
5102
5154
|
*
|
|
5103
5155
|
* @example
|
|
5104
5156
|
* Basic formatting:
|
|
5105
5157
|
* ```typescript
|
|
5106
|
-
*
|
|
5158
|
+
* formatBanglaDate({ year: 1431, month: 1, day: 15 });
|
|
5107
5159
|
* // "১৫ বৈশাখ ১৪৩১"
|
|
5108
5160
|
* ```
|
|
5109
5161
|
*
|
|
5110
5162
|
* @example
|
|
5111
5163
|
* Without year:
|
|
5112
5164
|
* ```typescript
|
|
5113
|
-
*
|
|
5165
|
+
* formatBanglaDate(
|
|
5114
5166
|
* { year: 1431, month: 1, day: 15 },
|
|
5115
5167
|
* { includeYear: false }
|
|
5116
5168
|
* );
|
|
@@ -5120,14 +5172,14 @@ declare function isBengaliLeapYear(year: number): boolean;
|
|
|
5120
5172
|
* @example
|
|
5121
5173
|
* With weekday:
|
|
5122
5174
|
* ```typescript
|
|
5123
|
-
*
|
|
5175
|
+
* formatBanglaDate(
|
|
5124
5176
|
* { year: 1431, month: 1, day: 1 },
|
|
5125
5177
|
* { includeWeekday: true }
|
|
5126
5178
|
* );
|
|
5127
5179
|
* // "রবিবার ১ বৈশাখ ১৪৩১" (if 1 Boishakh 1431 is a Sunday)
|
|
5128
5180
|
* ```
|
|
5129
5181
|
*/
|
|
5130
|
-
declare function
|
|
5182
|
+
declare function formatBanglaDate(bengaliDate: {
|
|
5131
5183
|
year: number;
|
|
5132
5184
|
month: number;
|
|
5133
5185
|
day: number;
|
|
@@ -5136,26 +5188,26 @@ declare function formatBengaliDate(bengaliDate: {
|
|
|
5136
5188
|
includeWeekday?: boolean;
|
|
5137
5189
|
}): string;
|
|
5138
5190
|
/**
|
|
5139
|
-
* Gets the current date in
|
|
5191
|
+
* Gets the current date in Bangla calendar.
|
|
5140
5192
|
*
|
|
5141
|
-
* @returns Current
|
|
5193
|
+
* @returns Current Bangla date object
|
|
5142
5194
|
*
|
|
5143
5195
|
* @example
|
|
5144
5196
|
* ```typescript
|
|
5145
|
-
* const today =
|
|
5197
|
+
* const today = getCurrentBanglaDate();
|
|
5146
5198
|
* // { year: 1431, month: 9, day: 24 } (example for 2025-01-07)
|
|
5147
5199
|
* ```
|
|
5148
5200
|
*/
|
|
5149
|
-
declare function
|
|
5201
|
+
declare function getCurrentBanglaDate(): {
|
|
5150
5202
|
year: number;
|
|
5151
5203
|
month: number;
|
|
5152
5204
|
day: number;
|
|
5153
5205
|
};
|
|
5154
5206
|
/**
|
|
5155
|
-
* Batch converts an array of Gregorian dates to
|
|
5207
|
+
* Batch converts an array of Gregorian dates to Bangla dates.
|
|
5156
5208
|
*
|
|
5157
5209
|
* @param dates - Array of Gregorian Date objects
|
|
5158
|
-
* @returns Array of
|
|
5210
|
+
* @returns Array of Bangla date objects
|
|
5159
5211
|
*
|
|
5160
5212
|
* @example
|
|
5161
5213
|
* ```typescript
|
|
@@ -5164,7 +5216,7 @@ declare function getCurrentBengaliDate(): {
|
|
|
5164
5216
|
* new Date(2024, 3, 15),
|
|
5165
5217
|
* new Date(2024, 3, 16)
|
|
5166
5218
|
* ];
|
|
5167
|
-
* const bengaliDates =
|
|
5219
|
+
* const bengaliDates = batchToBangla(dates);
|
|
5168
5220
|
* // [
|
|
5169
5221
|
* // { year: 1431, month: 1, day: 1 },
|
|
5170
5222
|
* // { year: 1431, month: 1, day: 2 },
|
|
@@ -5172,15 +5224,15 @@ declare function getCurrentBengaliDate(): {
|
|
|
5172
5224
|
* // ]
|
|
5173
5225
|
* ```
|
|
5174
5226
|
*/
|
|
5175
|
-
declare function
|
|
5227
|
+
declare function batchToBangla(dates: Date[]): Array<{
|
|
5176
5228
|
year: number;
|
|
5177
5229
|
month: number;
|
|
5178
5230
|
day: number;
|
|
5179
5231
|
}>;
|
|
5180
5232
|
/**
|
|
5181
|
-
* Gets the month lengths for a given
|
|
5233
|
+
* Gets the month lengths for a given Bangla year.
|
|
5182
5234
|
*/
|
|
5183
|
-
declare function
|
|
5235
|
+
declare function getBanglaMonthLengths(bengaliYear: number): number[];
|
|
5184
5236
|
|
|
5185
5237
|
/**
|
|
5186
5238
|
* Formats a Bangladeshi phone number with various formatting options.
|
|
@@ -5595,34 +5647,34 @@ declare function parseAndFormat(phoneNumber: string, options?: {
|
|
|
5595
5647
|
}): string;
|
|
5596
5648
|
|
|
5597
5649
|
/**
|
|
5598
|
-
* Validates if a string contains ONLY
|
|
5650
|
+
* Validates if a string contains ONLY Bangla/Bangla characters and whitespace.
|
|
5599
5651
|
*
|
|
5600
5652
|
* This function checks if the entire string consists exclusively of characters
|
|
5601
|
-
* from the
|
|
5602
|
-
* It returns false if any non-
|
|
5653
|
+
* from the Bangla Unicode range (U+0980 to U+09FF) and whitespace.
|
|
5654
|
+
* It returns false if any non-Bangla, non-whitespace character is present.
|
|
5603
5655
|
*
|
|
5604
5656
|
* **Use Cases:**
|
|
5605
|
-
* - Form validation (ensuring pure
|
|
5606
|
-
* - Content filtering (verifying
|
|
5657
|
+
* - Form validation (ensuring pure Bangla input)
|
|
5658
|
+
* - Content filtering (verifying Bangla-only text)
|
|
5607
5659
|
* - Data validation (checking text purity)
|
|
5608
5660
|
*
|
|
5609
5661
|
* **Allowed Characters:**
|
|
5610
|
-
* -
|
|
5611
|
-
* -
|
|
5612
|
-
* -
|
|
5662
|
+
* - Bangla consonants, vowels, diacritics
|
|
5663
|
+
* - Bangla digits (০-৯)
|
|
5664
|
+
* - Bangla punctuation
|
|
5613
5665
|
* - Whitespace (spaces, tabs, newlines)
|
|
5614
5666
|
*
|
|
5615
5667
|
* **Not Allowed:**
|
|
5616
5668
|
* - English letters (a-z, A-Z)
|
|
5617
5669
|
* - English digits (0-9)
|
|
5618
|
-
* - Special characters not in
|
|
5670
|
+
* - Special characters not in Bangla range
|
|
5619
5671
|
* - Emojis or other Unicode characters
|
|
5620
5672
|
*
|
|
5621
5673
|
* @param text - String to validate
|
|
5622
|
-
* @returns true if string contains only
|
|
5674
|
+
* @returns true if string contains only Bangla characters and whitespace, false otherwise
|
|
5623
5675
|
*
|
|
5624
5676
|
* @example
|
|
5625
|
-
* Valid pure
|
|
5677
|
+
* Valid pure Bangla text:
|
|
5626
5678
|
* ```typescript
|
|
5627
5679
|
* validateBangla('বাংলা'); // true
|
|
5628
5680
|
* validateBangla('শুভ সকাল'); // true
|
|
@@ -5636,7 +5688,7 @@ declare function parseAndFormat(phoneNumber: string, options?: {
|
|
|
5636
5688
|
* validateBangla('Hello বাংলা'); // false (contains English)
|
|
5637
5689
|
* validateBangla('বাংলা 123'); // false (contains English digits)
|
|
5638
5690
|
* validateBangla('Test'); // false (English only)
|
|
5639
|
-
* validateBangla('বাংলা!'); // false (contains non-
|
|
5691
|
+
* validateBangla('বাংলা!'); // false (contains non-Bangla punctuation)
|
|
5640
5692
|
* ```
|
|
5641
5693
|
*
|
|
5642
5694
|
* @example
|
|
@@ -5656,23 +5708,23 @@ declare function parseAndFormat(phoneNumber: string, options?: {
|
|
|
5656
5708
|
* @example
|
|
5657
5709
|
* Form validation:
|
|
5658
5710
|
* ```typescript
|
|
5659
|
-
* function
|
|
5711
|
+
* function validateBanglaName(name: string): boolean {
|
|
5660
5712
|
* return validateBangla(name) && name.trim().length > 0;
|
|
5661
5713
|
* }
|
|
5662
5714
|
*
|
|
5663
|
-
*
|
|
5664
|
-
*
|
|
5715
|
+
* validateBanglaName('মাহমুদ'); // true
|
|
5716
|
+
* validateBanglaName('Mahmud'); // false
|
|
5665
5717
|
* ```
|
|
5666
5718
|
*/
|
|
5667
5719
|
declare function validateBangla(text: string): boolean;
|
|
5668
5720
|
|
|
5669
5721
|
/**
|
|
5670
|
-
* Checks if a character is a
|
|
5722
|
+
* Checks if a character is a Bangla digit.
|
|
5671
5723
|
*
|
|
5672
|
-
*
|
|
5673
|
-
* This function checks if the input string contains at least one
|
|
5724
|
+
* Bangla digits range from ০ (0) to ৯ (9).
|
|
5725
|
+
* This function checks if the input string contains at least one Bangla digit.
|
|
5674
5726
|
*
|
|
5675
|
-
* **
|
|
5727
|
+
* **Bangla Digits:**
|
|
5676
5728
|
* - ০ (shunno) - 0
|
|
5677
5729
|
* - ১ (ek) - 1
|
|
5678
5730
|
* - ২ (dui) - 2
|
|
@@ -5685,10 +5737,10 @@ declare function validateBangla(text: string): boolean;
|
|
|
5685
5737
|
* - ৯ (noy) - 9
|
|
5686
5738
|
*
|
|
5687
5739
|
* @param char - Character or string to check
|
|
5688
|
-
* @returns true if contains at least one
|
|
5740
|
+
* @returns true if contains at least one Bangla digit, false otherwise
|
|
5689
5741
|
*
|
|
5690
5742
|
* @example
|
|
5691
|
-
* Single
|
|
5743
|
+
* Single Bangla digits:
|
|
5692
5744
|
* ```typescript
|
|
5693
5745
|
* isBanglaDigit('০'); // true
|
|
5694
5746
|
* isBanglaDigit('৫'); // true
|
|
@@ -5696,7 +5748,7 @@ declare function validateBangla(text: string): boolean;
|
|
|
5696
5748
|
* ```
|
|
5697
5749
|
*
|
|
5698
5750
|
* @example
|
|
5699
|
-
* Multiple
|
|
5751
|
+
* Multiple Bangla digits:
|
|
5700
5752
|
* ```typescript
|
|
5701
5753
|
* isBanglaDigit('১২৩'); // true
|
|
5702
5754
|
* isBanglaDigit('৪৫৬'); // true
|
|
@@ -5728,21 +5780,21 @@ declare function validateBangla(text: string): boolean;
|
|
|
5728
5780
|
declare function isBanglaDigit(char: string): boolean;
|
|
5729
5781
|
|
|
5730
5782
|
/**
|
|
5731
|
-
* Checks if a string contains
|
|
5783
|
+
* Checks if a string contains Bangla/Bangla characters.
|
|
5732
5784
|
*
|
|
5733
5785
|
* This function tests if the input string contains at least one character
|
|
5734
|
-
* from the
|
|
5735
|
-
* -
|
|
5736
|
-
* -
|
|
5737
|
-
* -
|
|
5738
|
-
* -
|
|
5739
|
-
* -
|
|
5786
|
+
* from the Bangla Unicode range (U+0980 to U+09FF), which includes:
|
|
5787
|
+
* - Bangla consonants (ক খ গ ঘ ঙ চ ছ জ ঝ ঞ etc.)
|
|
5788
|
+
* - Bangla vowels (অ আ ই ঈ উ ঊ etc.)
|
|
5789
|
+
* - Bangla vowel diacritics (া ি ী ু ূ etc.)
|
|
5790
|
+
* - Bangla digits (০ ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯)
|
|
5791
|
+
* - Bangla punctuation and symbols
|
|
5740
5792
|
*
|
|
5741
5793
|
* @param text - String to check
|
|
5742
|
-
* @returns true if contains at least one
|
|
5794
|
+
* @returns true if contains at least one Bangla character, false otherwise
|
|
5743
5795
|
*
|
|
5744
5796
|
* @example
|
|
5745
|
-
* Pure
|
|
5797
|
+
* Pure Bangla text:
|
|
5746
5798
|
* ```typescript
|
|
5747
5799
|
* isBanglaText('বাংলা'); // true
|
|
5748
5800
|
* isBanglaText('হ্যালো'); // true
|
|
@@ -5750,14 +5802,14 @@ declare function isBanglaDigit(char: string): boolean;
|
|
|
5750
5802
|
* ```
|
|
5751
5803
|
*
|
|
5752
5804
|
* @example
|
|
5753
|
-
*
|
|
5805
|
+
* Bangla digits:
|
|
5754
5806
|
* ```typescript
|
|
5755
5807
|
* isBanglaText('১২৩'); // true
|
|
5756
5808
|
* isBanglaText('৫০০'); // true
|
|
5757
5809
|
* ```
|
|
5758
5810
|
*
|
|
5759
5811
|
* @example
|
|
5760
|
-
* Mixed
|
|
5812
|
+
* Mixed Bangla and English:
|
|
5761
5813
|
* ```typescript
|
|
5762
5814
|
* isBanglaText('Hello বাংলা'); // true
|
|
5763
5815
|
* isBanglaText('Price: ১০০ টাকা'); // true
|
|
@@ -5783,63 +5835,63 @@ declare function isBanglaDigit(char: string): boolean;
|
|
|
5783
5835
|
declare function isBanglaText(text: string): boolean;
|
|
5784
5836
|
|
|
5785
5837
|
/**
|
|
5786
|
-
* General utility functions for
|
|
5838
|
+
* General utility functions for Bangla/Bangla text operations.
|
|
5787
5839
|
*
|
|
5788
|
-
* This module provides helper functions for working with
|
|
5789
|
-
* including counting, detecting, sanitizing, and analyzing
|
|
5840
|
+
* This module provides helper functions for working with Bangla text,
|
|
5841
|
+
* including counting, detecting, sanitizing, and analyzing Bangla content.
|
|
5790
5842
|
*
|
|
5791
5843
|
* @module utils/utils
|
|
5792
5844
|
*/
|
|
5793
5845
|
/**
|
|
5794
|
-
* Counts the number of
|
|
5846
|
+
* Counts the number of Bangla characters in a string.
|
|
5795
5847
|
*
|
|
5796
|
-
* This function counts characters from the
|
|
5797
|
-
* excluding whitespace and non-
|
|
5848
|
+
* This function counts characters from the Bangla Unicode range (U+0980 to U+09FF),
|
|
5849
|
+
* excluding whitespace and non-Bangla characters.
|
|
5798
5850
|
*
|
|
5799
5851
|
* @param text - String to analyze
|
|
5800
|
-
* @returns Number of
|
|
5852
|
+
* @returns Number of Bangla characters
|
|
5801
5853
|
*
|
|
5802
5854
|
* @example
|
|
5803
|
-
* Pure
|
|
5855
|
+
* Pure Bangla text:
|
|
5804
5856
|
* ```typescript
|
|
5805
|
-
*
|
|
5806
|
-
*
|
|
5857
|
+
* countBanglaCharacters('বাংলা'); // 5
|
|
5858
|
+
* countBanglaCharacters('হ্যালো'); // 6
|
|
5807
5859
|
* ```
|
|
5808
5860
|
*
|
|
5809
5861
|
* @example
|
|
5810
5862
|
* Mixed content:
|
|
5811
5863
|
* ```typescript
|
|
5812
|
-
*
|
|
5813
|
-
*
|
|
5864
|
+
* countBanglaCharacters('Hello বাংলা'); // 5
|
|
5865
|
+
* countBanglaCharacters('১২৩ টাকা'); // 6
|
|
5814
5866
|
* ```
|
|
5815
5867
|
*
|
|
5816
5868
|
* @example
|
|
5817
5869
|
* With whitespace:
|
|
5818
5870
|
* ```typescript
|
|
5819
|
-
*
|
|
5871
|
+
* countBanglaCharacters('শুভ সকাল'); // 8 (spaces not counted)
|
|
5820
5872
|
* ```
|
|
5821
5873
|
*/
|
|
5822
|
-
declare function
|
|
5874
|
+
declare function countBanglaCharacters(text: string): number;
|
|
5823
5875
|
/**
|
|
5824
|
-
* Counts the number of
|
|
5876
|
+
* Counts the number of Bangla digits in a string.
|
|
5825
5877
|
*
|
|
5826
|
-
*
|
|
5878
|
+
* Bangla digits: ০ ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯
|
|
5827
5879
|
*
|
|
5828
5880
|
* @param text - String to analyze
|
|
5829
|
-
* @returns Number of
|
|
5881
|
+
* @returns Number of Bangla digits
|
|
5830
5882
|
*
|
|
5831
5883
|
* @example
|
|
5832
5884
|
* ```typescript
|
|
5833
|
-
*
|
|
5834
|
-
*
|
|
5835
|
-
*
|
|
5885
|
+
* countBanglaDigits('১২৩'); // 3
|
|
5886
|
+
* countBanglaDigits('মূল্য: ১০০ টাকা'); // 3
|
|
5887
|
+
* countBanglaDigits('Hello 123'); // 0 (English digits not counted)
|
|
5836
5888
|
* ```
|
|
5837
5889
|
*/
|
|
5838
|
-
declare function
|
|
5890
|
+
declare function countBanglaDigits(text: string): number;
|
|
5839
5891
|
/**
|
|
5840
|
-
* Checks if a string contains mixed
|
|
5892
|
+
* Checks if a string contains mixed Bangla and non-Bangla content.
|
|
5841
5893
|
*
|
|
5842
|
-
* Returns true if the string has both
|
|
5894
|
+
* Returns true if the string has both Bangla characters and non-Bangla
|
|
5843
5895
|
* alphanumeric characters.
|
|
5844
5896
|
*
|
|
5845
5897
|
* @param text - String to check
|
|
@@ -5856,147 +5908,147 @@ declare function countBengaliDigits(text: string): number;
|
|
|
5856
5908
|
* @example
|
|
5857
5909
|
* Pure content:
|
|
5858
5910
|
* ```typescript
|
|
5859
|
-
* isMixedContent('বাংলা'); // false (pure
|
|
5911
|
+
* isMixedContent('বাংলা'); // false (pure Bangla)
|
|
5860
5912
|
* isMixedContent('Hello'); // false (pure English)
|
|
5861
|
-
* isMixedContent('১২৩'); // false (
|
|
5913
|
+
* isMixedContent('১২৩'); // false (Bangla digits only)
|
|
5862
5914
|
* ```
|
|
5863
5915
|
*/
|
|
5864
5916
|
declare function isMixedContent(text: string): boolean;
|
|
5865
5917
|
/**
|
|
5866
|
-
* Extracts only
|
|
5918
|
+
* Extracts only Bangla characters from a string.
|
|
5867
5919
|
*
|
|
5868
|
-
* Removes all non-
|
|
5869
|
-
* from the
|
|
5920
|
+
* Removes all non-Bangla characters, keeping only characters
|
|
5921
|
+
* from the Bangla Unicode range (U+0980 to U+09FF).
|
|
5870
5922
|
*
|
|
5871
5923
|
* @param text - String to extract from
|
|
5872
5924
|
* @param preserveWhitespace - Whether to preserve whitespace (default: false)
|
|
5873
|
-
* @returns String containing only
|
|
5925
|
+
* @returns String containing only Bangla characters
|
|
5874
5926
|
*
|
|
5875
5927
|
* @example
|
|
5876
5928
|
* Extract from mixed content:
|
|
5877
5929
|
* ```typescript
|
|
5878
|
-
*
|
|
5879
|
-
*
|
|
5880
|
-
*
|
|
5930
|
+
* extractBanglaChars('Hello বাংলা World'); // 'বাংলা'
|
|
5931
|
+
* extractBanglaChars('Price: ১০০ taka'); // '১০০'
|
|
5932
|
+
* extractBanglaChars('123 বাংলা 456'); // 'বাংলা'
|
|
5881
5933
|
* ```
|
|
5882
5934
|
*
|
|
5883
5935
|
* @example
|
|
5884
5936
|
* With whitespace preservation:
|
|
5885
5937
|
* ```typescript
|
|
5886
|
-
*
|
|
5887
|
-
*
|
|
5938
|
+
* extractBanglaChars('Hello বাংলা ভাষা', true); // 'বাংলা ভাষা'
|
|
5939
|
+
* extractBanglaChars('Test ১২৩ টাকা', true); // '১২৩ টাকা'
|
|
5888
5940
|
* ```
|
|
5889
5941
|
*
|
|
5890
5942
|
* @example
|
|
5891
|
-
* Pure
|
|
5943
|
+
* Pure Bangla text:
|
|
5892
5944
|
* ```typescript
|
|
5893
|
-
*
|
|
5945
|
+
* extractBanglaChars('বাংলা'); // 'বাংলা' (unchanged)
|
|
5894
5946
|
* ```
|
|
5895
5947
|
*/
|
|
5896
|
-
declare function
|
|
5948
|
+
declare function extractBanglaChars(text: string, preserveWhitespace?: boolean): string;
|
|
5897
5949
|
/**
|
|
5898
|
-
* Removes all
|
|
5950
|
+
* Removes all Bangla characters from a string.
|
|
5899
5951
|
*
|
|
5900
|
-
* Keeps only non-
|
|
5901
|
-
* the
|
|
5952
|
+
* Keeps only non-Bangla characters, removing everything from
|
|
5953
|
+
* the Bangla Unicode range.
|
|
5902
5954
|
*
|
|
5903
5955
|
* @param text - String to process
|
|
5904
|
-
* @returns String with
|
|
5956
|
+
* @returns String with Bangla characters removed
|
|
5905
5957
|
*
|
|
5906
5958
|
* @example
|
|
5907
5959
|
* ```typescript
|
|
5908
|
-
*
|
|
5909
|
-
*
|
|
5910
|
-
*
|
|
5960
|
+
* removeBanglaChars('Hello বাংলা World'); // 'Hello World'
|
|
5961
|
+
* removeBanglaChars('Price: ১০০ taka'); // 'Price: taka'
|
|
5962
|
+
* removeBanglaChars('১২৩ টাকা'); // ' '
|
|
5911
5963
|
* ```
|
|
5912
5964
|
*/
|
|
5913
|
-
declare function
|
|
5965
|
+
declare function removeBanglaChars(text: string): string;
|
|
5914
5966
|
/**
|
|
5915
|
-
* Gets the percentage of
|
|
5967
|
+
* Gets the percentage of Bangla characters in a string.
|
|
5916
5968
|
*
|
|
5917
5969
|
* Calculates what percentage of the total non-whitespace characters
|
|
5918
|
-
* are
|
|
5970
|
+
* are Bangla characters.
|
|
5919
5971
|
*
|
|
5920
5972
|
* @param text - String to analyze
|
|
5921
|
-
* @returns Percentage (0-100) of
|
|
5973
|
+
* @returns Percentage (0-100) of Bangla characters
|
|
5922
5974
|
*
|
|
5923
5975
|
* @example
|
|
5924
5976
|
* ```typescript
|
|
5925
|
-
*
|
|
5926
|
-
*
|
|
5927
|
-
*
|
|
5928
|
-
*
|
|
5977
|
+
* getBanglaPercentage('বাংলা'); // 100
|
|
5978
|
+
* getBanglaPercentage('Hello'); // 0
|
|
5979
|
+
* getBanglaPercentage('Hello বাংলা'); // 50 (5 of 10 chars)
|
|
5980
|
+
* getBanglaPercentage(''); // 0
|
|
5929
5981
|
* ```
|
|
5930
5982
|
*/
|
|
5931
|
-
declare function
|
|
5983
|
+
declare function getBanglaPercentage(text: string): number;
|
|
5932
5984
|
/**
|
|
5933
|
-
* Checks if text is primarily
|
|
5985
|
+
* Checks if text is primarily Bangla (more than 50% Bangla characters).
|
|
5934
5986
|
*
|
|
5935
5987
|
* @param text - String to check
|
|
5936
|
-
* @returns true if more than 50% is
|
|
5988
|
+
* @returns true if more than 50% is Bangla, false otherwise
|
|
5937
5989
|
*
|
|
5938
5990
|
* @example
|
|
5939
5991
|
* ```typescript
|
|
5940
|
-
*
|
|
5941
|
-
*
|
|
5942
|
-
*
|
|
5943
|
-
*
|
|
5992
|
+
* isPrimarilyBangla('বাংলা'); // true (100%)
|
|
5993
|
+
* isPrimarilyBangla('বাংলা ভাষা hello'); // true (>50%)
|
|
5994
|
+
* isPrimarilyBangla('Hello বাংলা world test'); // false (<50%)
|
|
5995
|
+
* isPrimarilyBangla('Hello'); // false (0%)
|
|
5944
5996
|
* ```
|
|
5945
5997
|
*/
|
|
5946
|
-
declare function
|
|
5998
|
+
declare function isPrimarilyBangla(text: string): boolean;
|
|
5947
5999
|
/**
|
|
5948
|
-
* Sanitizes
|
|
6000
|
+
* Sanitizes Bangla text by removing non-Bangla characters.
|
|
5949
6001
|
*
|
|
5950
6002
|
* If fallback is provided, returns fallback when result would be empty.
|
|
5951
6003
|
*
|
|
5952
6004
|
* @param text - Text to sanitize
|
|
5953
6005
|
* @param preserveWhitespace - Preserve whitespace (default: true)
|
|
5954
6006
|
* @param fallback - Fallback value if result is empty (default: empty string)
|
|
5955
|
-
* @returns Sanitized
|
|
6007
|
+
* @returns Sanitized Bangla text or fallback
|
|
5956
6008
|
*
|
|
5957
6009
|
* @example
|
|
5958
6010
|
* ```typescript
|
|
5959
|
-
*
|
|
5960
|
-
*
|
|
5961
|
-
*
|
|
6011
|
+
* sanitizeBanglaText('Hello বাংলা World'); // 'বাংলা'
|
|
6012
|
+
* sanitizeBanglaText('Test 123 টাকা'); // 'টাকা'
|
|
6013
|
+
* sanitizeBanglaText('বাংলা ভাষা'); // 'বাংলা ভাষা'
|
|
5962
6014
|
* ```
|
|
5963
6015
|
*
|
|
5964
6016
|
* @example
|
|
5965
6017
|
* With fallback:
|
|
5966
6018
|
* ```typescript
|
|
5967
|
-
*
|
|
5968
|
-
*
|
|
6019
|
+
* sanitizeBanglaText('Hello World', true, 'N/A'); // 'N/A'
|
|
6020
|
+
* sanitizeBanglaText('123', false, 'নেই'); // 'নেই'
|
|
5969
6021
|
* ```
|
|
5970
6022
|
*/
|
|
5971
|
-
declare function
|
|
6023
|
+
declare function sanitizeBanglaText(text: string, preserveWhitespace?: boolean, fallback?: string): string;
|
|
5972
6024
|
/**
|
|
5973
|
-
* Checks if all digits in a string are
|
|
6025
|
+
* Checks if all digits in a string are Bangla digits.
|
|
5974
6026
|
*
|
|
5975
|
-
* Returns true if string contains digits and all digits are
|
|
6027
|
+
* Returns true if string contains digits and all digits are Bangla.
|
|
5976
6028
|
* Returns false if contains English digits or no digits at all.
|
|
5977
6029
|
*
|
|
5978
6030
|
* @param text - String to check
|
|
5979
|
-
* @returns true if all digits are
|
|
6031
|
+
* @returns true if all digits are Bangla, false otherwise
|
|
5980
6032
|
*
|
|
5981
6033
|
* @example
|
|
5982
|
-
* All
|
|
6034
|
+
* All Bangla digits:
|
|
5983
6035
|
* ```typescript
|
|
5984
|
-
*
|
|
5985
|
-
*
|
|
5986
|
-
*
|
|
6036
|
+
* hasOnlyBanglaDigits('১২৩'); // true
|
|
6037
|
+
* hasOnlyBanglaDigits('মূল্য: ১০০'); // true
|
|
6038
|
+
* hasOnlyBanglaDigits('বাংলা'); // false (no digits)
|
|
5987
6039
|
* ```
|
|
5988
6040
|
*
|
|
5989
6041
|
* @example
|
|
5990
6042
|
* Mixed or English digits:
|
|
5991
6043
|
* ```typescript
|
|
5992
|
-
*
|
|
5993
|
-
*
|
|
5994
|
-
*
|
|
6044
|
+
* hasOnlyBanglaDigits('123'); // false (English digits)
|
|
6045
|
+
* hasOnlyBanglaDigits('১২3'); // false (mixed)
|
|
6046
|
+
* hasOnlyBanglaDigits('Price: 100'); // false
|
|
5995
6047
|
* ```
|
|
5996
6048
|
*/
|
|
5997
|
-
declare function
|
|
6049
|
+
declare function hasOnlyBanglaDigits(text: string): boolean;
|
|
5998
6050
|
/**
|
|
5999
|
-
* Normalizes whitespace in
|
|
6051
|
+
* Normalizes whitespace in Bangla text.
|
|
6000
6052
|
*
|
|
6001
6053
|
* Replaces multiple consecutive whitespaces with a single space
|
|
6002
6054
|
* and trims leading/trailing whitespace.
|
|
@@ -6013,60 +6065,60 @@ declare function hasOnlyBengaliDigits(text: string): boolean;
|
|
|
6013
6065
|
*/
|
|
6014
6066
|
declare function normalizeWhitespace(text: string): string;
|
|
6015
6067
|
/**
|
|
6016
|
-
* Splits text into
|
|
6068
|
+
* Splits text into Bangla and non-Bangla parts.
|
|
6017
6069
|
*
|
|
6018
|
-
* Returns an object with separate strings for
|
|
6070
|
+
* Returns an object with separate strings for Bangla and non-Bangla content.
|
|
6019
6071
|
*
|
|
6020
6072
|
* @param text - Text to split
|
|
6021
|
-
* @returns Object with bengali and
|
|
6073
|
+
* @returns Object with bengali and nonBangla strings
|
|
6022
6074
|
*
|
|
6023
6075
|
* @example
|
|
6024
6076
|
* ```typescript
|
|
6025
|
-
*
|
|
6026
|
-
* // { bengali: 'বাংলা',
|
|
6077
|
+
* splitBanglaContent('Hello বাংলা World');
|
|
6078
|
+
* // { bengali: 'বাংলা', nonBangla: 'Hello World' }
|
|
6027
6079
|
*
|
|
6028
|
-
*
|
|
6029
|
-
* // { bengali: '১০০',
|
|
6080
|
+
* splitBanglaContent('Price: ১০০ taka');
|
|
6081
|
+
* // { bengali: '১০০', nonBangla: 'Price: taka' }
|
|
6030
6082
|
* ```
|
|
6031
6083
|
*/
|
|
6032
|
-
declare function
|
|
6084
|
+
declare function splitBanglaContent(text: string): {
|
|
6033
6085
|
bengali: string;
|
|
6034
|
-
|
|
6086
|
+
nonBangla: string;
|
|
6035
6087
|
};
|
|
6036
6088
|
/**
|
|
6037
|
-
* Checks if a string contains any
|
|
6089
|
+
* Checks if a string contains any Bangla consonants.
|
|
6038
6090
|
*
|
|
6039
|
-
*
|
|
6091
|
+
* Bangla consonants: ক খ গ ঘ ঙ চ ছ জ ঝ ঞ ট ঠ ড ঢ ণ ত থ দ ধ ন প ফ ব ভ ম য র ল শ ষ স হ ড় ঢ় য় ৎ
|
|
6040
6092
|
*
|
|
6041
6093
|
* @param text - Text to check
|
|
6042
|
-
* @returns true if contains
|
|
6094
|
+
* @returns true if contains Bangla consonants, false otherwise
|
|
6043
6095
|
*
|
|
6044
6096
|
* @example
|
|
6045
6097
|
* ```typescript
|
|
6046
|
-
*
|
|
6047
|
-
*
|
|
6048
|
-
*
|
|
6049
|
-
*
|
|
6098
|
+
* hasBanglaConsonants('বাংলা'); // true
|
|
6099
|
+
* hasBanglaConsonants('আই'); // false (vowels only)
|
|
6100
|
+
* hasBanglaConsonants('১২৩'); // false (digits only)
|
|
6101
|
+
* hasBanglaConsonants('Hello'); // false
|
|
6050
6102
|
* ```
|
|
6051
6103
|
*/
|
|
6052
|
-
declare function
|
|
6104
|
+
declare function hasBanglaConsonants(text: string): boolean;
|
|
6053
6105
|
/**
|
|
6054
|
-
* Checks if a string contains any
|
|
6106
|
+
* Checks if a string contains any Bangla vowels (independent or diacritics).
|
|
6055
6107
|
*
|
|
6056
|
-
*
|
|
6057
|
-
*
|
|
6108
|
+
* Bangla vowels: অ আ ই ঈ উ ঊ ঋ ৠ ঌ ৡ এ ঐ ও ঔ
|
|
6109
|
+
* Bangla vowel diacritics: া ি ী ু ূ ৃ ৄ ে ৈ ো ৌ
|
|
6058
6110
|
*
|
|
6059
6111
|
* @param text - Text to check
|
|
6060
|
-
* @returns true if contains
|
|
6112
|
+
* @returns true if contains Bangla vowels, false otherwise
|
|
6061
6113
|
*
|
|
6062
6114
|
* @example
|
|
6063
6115
|
* ```typescript
|
|
6064
|
-
*
|
|
6065
|
-
*
|
|
6066
|
-
*
|
|
6067
|
-
*
|
|
6116
|
+
* hasBanglaVowels('আম'); // true
|
|
6117
|
+
* hasBanglaVowels('বাংলা'); // true (has vowel diacritics)
|
|
6118
|
+
* hasBanglaVowels('ক'); // false (consonant only)
|
|
6119
|
+
* hasBanglaVowels('123'); // false
|
|
6068
6120
|
* ```
|
|
6069
6121
|
*/
|
|
6070
|
-
declare function
|
|
6122
|
+
declare function hasBanglaVowels(text: string): boolean;
|
|
6071
6123
|
|
|
6072
|
-
export { BANGLA_DIGITS, BANGLA_MONTHS, BANGLA_SEASONS, BANGLA_WEEKDAYS,
|
|
6124
|
+
export { BANGLA_DIGITS, BANGLA_MONTHS, BANGLA_SEASONS, BANGLA_WEEKDAYS, ENGLISH_DIGITS, OPERATOR_INFO, type OperatorInfo, type ParsedPhoneNumber, VALID_OPERATOR_CODES, addCountryCode, addCurrency, addDays, addDaysToBanglaDate, addMinutesToTime, addTax, applyDiscount, batchFormatCurrency, batchFormatDates, batchFromBanglaNumber, batchParseDates, batchToBangla, batchToBanglaMonth, batchToBanglaNumber, batchToOrdinal, calculateDiscount, calculatePercentage, calculateTax, canParseBanglaDate, ceilCurrency, compareBanglaDates, compareCurrency, compareDates, compareMonths, compareOrdinals, compareTimes, convertToWordsAndDigits, countBanglaCharacters, countBanglaDigits, createOrdinalList, divideCurrency, extractBanglaChars, floorCurrency, formatAndConvert, formatBanglaDate, formatCurrency, formatDate, formatNumber, formatOrdinal, formatPhone, formatTime, formatToday, formatWithUnits, fromBanglaCalendar, fromBanglaMonth, fromBanglaNumber, fromBanglaWeekday, getAbsoluteAmount, getAllBanglaWeekdays, getAllMonths, getAllOperatorCodes, getAllOperators, getAllSeasons, getBanglaDate, getBanglaDateDifference, getBanglaMonthDays, getBanglaMonthLengths, getBanglaPercentage, getCurrentBanglaDate, getCurrentSeason, getCurrentTimeBangla, getDaysBetween, getDaysDifference, getFirstDayOfBanglaMonth, getLastDayOfBanglaMonth, getMonthFromIndex, getMonthIndex, getMonthMapping, getMonthName, getMonthRange, getNextBanglaWeekday, getNextMonth, getNextOrdinal, getNextSeason, getNextWeekday, getOperator, getOrdinalSequence, getOrdinalType, getPreviousBanglaWeekday, getPreviousMonth, getPreviousOrdinal, getPreviousSeason, getPreviousWeekday, getRanking, getSeason, getSeasonByIndex, getSeasonFromMonth, getSeasonIndex, getSeasonInfo, getSeasonMonths, getSpecialOrdinals, getTimePeriod, getWeekdayName, hasBanglaConsonants, hasBanglaDigits, hasBanglaMonth, hasBanglaVowels, hasCountryCode, hasOnlyBanglaDigits, hasSeconds, hasSpecialOrdinal, hasTakaSymbol, hasTakaWord, isBanglaCurrency, isBanglaDateInRange, isBanglaDigit, isBanglaLeapYear, isBanglaOrdinal, isBanglaText, isBanglaWeekend, isCurrencyEqual, isCurrencyInRange, isDateInRange, isFuture, isGreaterThan, isInSpecialOrdinalRange, isLessThan, isMixedContent, isMonthInRange, isMonthInSeason, isNegativeAmount, isNumberInRange, isPast, isPositiveAmount, isPrimarilyBangla, isSameDay, isSameNumber, isSameSeason, isTimeInRange, isToday, isValidBanglaDate, isValidBanglaDateString, isValidBanglaDay, isValidBanglaMonth, isValidBanglaMonthNumber, isValidBanglaNumber, isValidBanglaWeekday, isValidBanglaYear, isValidCurrency, isValidDate, isValidDateForSeason, isValidDateForWeekday, isValidMonth, isValidMonthNumber, isValidNumber, isValidNumberForOrdinal, isValidNumberForWords, isValidOperatorCode, isValidOrdinal, isValidPhoneFormat, isValidSeasonName, isValidTimeInput, isValidTimeString, isValidWeekdayNumber, isWeekend, isZeroAmount, multiplyCurrency, negateAmount, normalizePhoneNumber, normalizeWhitespace, parseAndConvertToBangla, parseAndConvertToMonth, parseAndConvertToOrdinal, parseAndFormat, parseAndFormatCurrency, parseCurrency, parseDate, parsePhoneNumber, parseTime, parseWeekdayInput, relativeDay, relativeTime, removeBanglaChars, removeCountryCode, roundCurrency, safeFormatCurrency, safeFormatDate, safeFormatPhone, safeFormatTime, safeFromBangla, safeFromBanglaMonth, safeFromBanglaNumber, safeFromBanglaWeekday, safeGetSeason, safeGetSeasonFromMonth, safeParseCurrency, safeParseDate, safeRelativeTime, safeToBangla, safeToBanglaMonth, safeToBanglaNumber, safeToBanglaWeekday, safeToOrdinal, sanitizeBanglaDate, sanitizeBanglaMonth, sanitizeBanglaText, sanitizeCurrencyInput, sanitizeDate, sanitizeMonthNumber, sanitizeNumberInput, sanitizeOrdinalInput, sanitizePhoneNumber, sanitizeTimeInput, sanitizeWeekdayInput, secondsToTime, splitAmount, splitBanglaContent, subtractCurrency, sumCurrency, timeDifferenceMinutes, timeToSeconds, toBanglaCalendar, toBanglaMonth, toBanglaNumber, toBanglaWeekday, toOrdinal, toWords, truncateDecimals, validateBangla, validatePhone };
|