bangla-stdlib 1.0.2 → 1.0.4
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 +1219 -1259
- package/dist/index.d.ts +1219 -1259
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
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,108 +593,50 @@ declare function truncateDecimals(value: number, decimals?: number): number;
|
|
|
588
593
|
/**
|
|
589
594
|
* Formats a number as Bangladeshi Taka currency in Bangla.
|
|
590
595
|
*
|
|
591
|
-
*
|
|
592
|
-
* the Taka symbol (৳) and/or word (টাকা). Amounts are automatically formatted
|
|
593
|
-
* to 2 decimal places.
|
|
594
|
-
*
|
|
595
|
-
* **Currency Symbol:** ৳ (Taka sign)
|
|
596
|
-
* **Currency Word:** টাকা (Taka)
|
|
596
|
+
* Uses Bangladeshi number grouping (rightmost 3 digits, then groups of 2).
|
|
597
597
|
*
|
|
598
598
|
* @param amount - The amount to format (number or string)
|
|
599
599
|
* @param options - Formatting options
|
|
600
|
-
* @param options.
|
|
601
|
-
* @param options.
|
|
600
|
+
* @param options.symbol - Show ৳ symbol instead of টাকা word (default: false)
|
|
601
|
+
* @param options.word - Show টাকা word (default: true, false when symbol is true)
|
|
602
|
+
* @param options.useBanglaDigits - Use Bangla digits (default: true)
|
|
602
603
|
* @returns Formatted currency string in Bangla
|
|
603
604
|
* @throws {Error} If amount is NaN or cannot be parsed
|
|
604
605
|
*
|
|
605
606
|
* @example
|
|
606
|
-
*
|
|
607
|
-
* ```typescript
|
|
608
|
-
* formatCurrency(1234.56);
|
|
609
|
-
* // '৳ ১২৩৪.৫৬'
|
|
610
|
-
*
|
|
611
|
-
* formatCurrency(100);
|
|
612
|
-
* // '৳ ১০০.০০'
|
|
613
|
-
*
|
|
614
|
-
* formatCurrency('999.99');
|
|
615
|
-
* // '৳ ৯৯৯.৯৯'
|
|
616
|
-
* ```
|
|
617
|
-
*
|
|
618
|
-
* @example
|
|
619
|
-
* Without symbol:
|
|
620
|
-
* ```typescript
|
|
621
|
-
* formatCurrency(1234.56, { includeSymbol: false });
|
|
622
|
-
* // '১২৩৪.৫৬'
|
|
623
|
-
*
|
|
624
|
-
* formatCurrency(500, { includeSymbol: false });
|
|
625
|
-
* // '৫০০.০০'
|
|
626
|
-
* ```
|
|
627
|
-
*
|
|
628
|
-
* @example
|
|
629
|
-
* With word "টাকা":
|
|
630
|
-
* ```typescript
|
|
631
|
-
* formatCurrency(100, { includeWord: true });
|
|
632
|
-
* // '৳ ১০০.০০ টাকা'
|
|
633
|
-
*
|
|
634
|
-
* formatCurrency(1000, { includeWord: true });
|
|
635
|
-
* // '৳ ১০০০.০০ টাকা'
|
|
636
|
-
*
|
|
637
|
-
* formatCurrency(50, { includeSymbol: false, includeWord: true });
|
|
638
|
-
* // '৫০.০০ টাকা'
|
|
639
|
-
* ```
|
|
640
|
-
*
|
|
641
|
-
* @example
|
|
642
|
-
* Large amounts:
|
|
643
|
-
* ```typescript
|
|
644
|
-
* formatCurrency(1000000);
|
|
645
|
-
* // '৳ ১০০০০০০.০০'
|
|
646
|
-
*
|
|
647
|
-
* formatCurrency(50000000, { includeWord: true });
|
|
648
|
-
* // '৳ ৫০০০০০০০.০০ টাকা'
|
|
649
|
-
* ```
|
|
650
|
-
*
|
|
651
|
-
* @example
|
|
652
|
-
* Small and zero amounts:
|
|
607
|
+
* Default (with word and separators):
|
|
653
608
|
* ```typescript
|
|
654
|
-
* formatCurrency(
|
|
655
|
-
* // '
|
|
656
|
-
*
|
|
657
|
-
* formatCurrency(0.5);
|
|
658
|
-
* // '৳ ০.৫০'
|
|
659
|
-
*
|
|
660
|
-
* formatCurrency(0.01);
|
|
661
|
-
* // '৳ ০.০১'
|
|
609
|
+
* formatCurrency(1500); // '১,৫০০ টাকা'
|
|
610
|
+
* formatCurrency(1234.56); // '১,২৩৪.৫৬ টাকা'
|
|
611
|
+
* formatCurrency(10000000); // '১,০০,০০,০০০ টাকা'
|
|
662
612
|
* ```
|
|
663
613
|
*
|
|
664
614
|
* @example
|
|
665
|
-
*
|
|
615
|
+
* With symbol:
|
|
666
616
|
* ```typescript
|
|
667
|
-
* formatCurrency(
|
|
668
|
-
* // '
|
|
669
|
-
*
|
|
670
|
-
* formatCurrency(-1234.56, { includeWord: true });
|
|
671
|
-
* // '৳ -১২৩৪.৫৬ টাকা'
|
|
617
|
+
* formatCurrency(2500, { symbol: true }); // '৳২,৫০০'
|
|
618
|
+
* formatCurrency(1234.56, { symbol: true }); // '৳১,২৩৪.৫৬'
|
|
672
619
|
* ```
|
|
673
620
|
*
|
|
674
621
|
* @example
|
|
675
|
-
*
|
|
622
|
+
* With English digits:
|
|
676
623
|
* ```typescript
|
|
677
|
-
* formatCurrency(
|
|
678
|
-
* //
|
|
679
|
-
*
|
|
680
|
-
* formatCurrency(NaN);
|
|
681
|
-
* // throws Error: Invalid amount
|
|
624
|
+
* formatCurrency(1234.56, { symbol: true, useBanglaDigits: false });
|
|
625
|
+
* // '৳1,234.56'
|
|
682
626
|
* ```
|
|
683
627
|
*/
|
|
684
628
|
declare function formatCurrency(amount: number | string, options?: {
|
|
629
|
+
symbol?: boolean;
|
|
630
|
+
word?: boolean;
|
|
685
631
|
includeSymbol?: boolean;
|
|
686
632
|
includeWord?: boolean;
|
|
633
|
+
useBanglaDigits?: boolean;
|
|
687
634
|
}): string;
|
|
688
635
|
|
|
689
636
|
/**
|
|
690
637
|
* Parses a Bangla currency string to a number.
|
|
691
638
|
*
|
|
692
|
-
* This function extracts numeric values from
|
|
639
|
+
* This function extracts numeric values from Bangla currency strings,
|
|
693
640
|
* automatically removing currency symbols (৳) and words (টাকা).
|
|
694
641
|
* It supports various formatting styles commonly used in Bangladesh.
|
|
695
642
|
*
|
|
@@ -938,63 +885,9 @@ declare function hasTakaSymbol(value: string): boolean;
|
|
|
938
885
|
declare function hasTakaWord(value: string): boolean;
|
|
939
886
|
|
|
940
887
|
/**
|
|
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
|
-
* ```
|
|
888
|
+
* Currency arithmetic operations
|
|
889
|
+
* Basic mathematical operations with proper rounding
|
|
993
890
|
*/
|
|
994
|
-
declare function batchFormatCurrency(amounts: number[], options?: {
|
|
995
|
-
includeSymbol?: boolean;
|
|
996
|
-
includeWord?: boolean;
|
|
997
|
-
}): string[];
|
|
998
891
|
/**
|
|
999
892
|
* Rounds a currency amount to a specified number of decimal places.
|
|
1000
893
|
*
|
|
@@ -1025,6 +918,20 @@ declare function roundCurrency(amount: number, decimals?: number): number;
|
|
|
1025
918
|
* ```
|
|
1026
919
|
*/
|
|
1027
920
|
declare function sumCurrency(amounts: number[]): number;
|
|
921
|
+
/**
|
|
922
|
+
* Adds two currency amounts.
|
|
923
|
+
*
|
|
924
|
+
* @param amount1 - First amount
|
|
925
|
+
* @param amount2 - Second amount
|
|
926
|
+
* @returns Sum rounded to 2 decimal places
|
|
927
|
+
*
|
|
928
|
+
* @example
|
|
929
|
+
* ```typescript
|
|
930
|
+
* addCurrency(100, 200); // 300
|
|
931
|
+
* addCurrency(123.45, 67.89); // 191.34
|
|
932
|
+
* ```
|
|
933
|
+
*/
|
|
934
|
+
declare function addCurrency(amount1: number, amount2: number): number;
|
|
1028
935
|
/**
|
|
1029
936
|
* Calculates the difference between two currency amounts.
|
|
1030
937
|
*
|
|
@@ -1072,6 +979,11 @@ declare function multiplyCurrency(amount: number, factor: number): number;
|
|
|
1072
979
|
* ```
|
|
1073
980
|
*/
|
|
1074
981
|
declare function divideCurrency(amount: number, divisor: number): number;
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* Currency percentage operations
|
|
985
|
+
* Tax, discount, and percentage calculations
|
|
986
|
+
*/
|
|
1075
987
|
/**
|
|
1076
988
|
* Calculates a percentage of a currency amount.
|
|
1077
989
|
*
|
|
@@ -1117,6 +1029,40 @@ declare function applyDiscount(amount: number, discountPercent: number): number;
|
|
|
1117
1029
|
* ```
|
|
1118
1030
|
*/
|
|
1119
1031
|
declare function addTax(amount: number, taxPercent: number): number;
|
|
1032
|
+
/**
|
|
1033
|
+
* Calculates the tax amount only (without adding to base).
|
|
1034
|
+
*
|
|
1035
|
+
* This is an alias for calculatePercentage but with clearer naming for tax calculations.
|
|
1036
|
+
*
|
|
1037
|
+
* @param amount - The base amount
|
|
1038
|
+
* @param taxPercent - Tax percentage
|
|
1039
|
+
* @returns Tax amount rounded to 2 decimal places
|
|
1040
|
+
*
|
|
1041
|
+
* @example
|
|
1042
|
+
* ```typescript
|
|
1043
|
+
* calculateTax(1000, 15); // 150
|
|
1044
|
+
* calculateTax(500, 10); // 50
|
|
1045
|
+
* ```
|
|
1046
|
+
*/
|
|
1047
|
+
declare function calculateTax(amount: number, taxPercent: number): number;
|
|
1048
|
+
/**
|
|
1049
|
+
* Calculates the discount amount only (without subtracting from base).
|
|
1050
|
+
*
|
|
1051
|
+
* @param amount - The base amount
|
|
1052
|
+
* @param discountPercent - Discount percentage
|
|
1053
|
+
* @returns Discount amount rounded to 2 decimal places
|
|
1054
|
+
*
|
|
1055
|
+
* @example
|
|
1056
|
+
* ```typescript
|
|
1057
|
+
* calculateDiscount(1000, 10); // 100
|
|
1058
|
+
* calculateDiscount(500, 25); // 125
|
|
1059
|
+
* ```
|
|
1060
|
+
*/
|
|
1061
|
+
declare function calculateDiscount(amount: number, discountPercent: number): number;
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Currency rounding and splitting operations
|
|
1065
|
+
*/
|
|
1120
1066
|
/**
|
|
1121
1067
|
* Splits a currency amount into equal parts.
|
|
1122
1068
|
*
|
|
@@ -1132,9 +1078,86 @@ declare function addTax(amount: number, taxPercent: number): number;
|
|
|
1132
1078
|
* ```
|
|
1133
1079
|
*/
|
|
1134
1080
|
declare function splitAmount(amount: number, parts: number): number[];
|
|
1081
|
+
/**
|
|
1082
|
+
* Rounds up a currency amount to the nearest whole number.
|
|
1083
|
+
*
|
|
1084
|
+
* @param amount - The amount to round up
|
|
1085
|
+
* @returns Rounded up amount
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
* ```typescript
|
|
1089
|
+
* ceilCurrency(123.01); // 124.00
|
|
1090
|
+
* ceilCurrency(123.99); // 124.00
|
|
1091
|
+
* ceilCurrency(123); // 123.00
|
|
1092
|
+
* ```
|
|
1093
|
+
*/
|
|
1094
|
+
declare function ceilCurrency(amount: number): number;
|
|
1095
|
+
/**
|
|
1096
|
+
* Rounds down a currency amount to the nearest whole number.
|
|
1097
|
+
*
|
|
1098
|
+
* @param amount - The amount to round down
|
|
1099
|
+
* @returns Rounded down amount
|
|
1100
|
+
*
|
|
1101
|
+
* @example
|
|
1102
|
+
* ```typescript
|
|
1103
|
+
* floorCurrency(123.99); // 123.00
|
|
1104
|
+
* floorCurrency(123.01); // 123.00
|
|
1105
|
+
* floorCurrency(123); // 123.00
|
|
1106
|
+
* ```
|
|
1107
|
+
*/
|
|
1108
|
+
declare function floorCurrency(amount: number): number;
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Currency utility functions
|
|
1112
|
+
* Domain-specific utilities using core patterns
|
|
1113
|
+
*/
|
|
1114
|
+
/**
|
|
1115
|
+
* Safely formats a currency amount with a fallback value.
|
|
1116
|
+
*
|
|
1117
|
+
* @param amount - The amount to format (number or string)
|
|
1118
|
+
* @param options - Formatting options
|
|
1119
|
+
* @param fallback - Value to return if formatting fails (default: '')
|
|
1120
|
+
* @returns Formatted currency string or fallback value
|
|
1121
|
+
*/
|
|
1122
|
+
declare function safeFormatCurrency(amount: number | string, options?: {
|
|
1123
|
+
includeSymbol?: boolean;
|
|
1124
|
+
includeWord?: boolean;
|
|
1125
|
+
}, fallback?: string): string;
|
|
1126
|
+
/**
|
|
1127
|
+
* Safely parses a currency string with a fallback value.
|
|
1128
|
+
*
|
|
1129
|
+
* @param currencyString - The currency string to parse
|
|
1130
|
+
* @param fallback - Value to return if parsing fails (default: 0)
|
|
1131
|
+
* @returns Parsed amount or fallback value
|
|
1132
|
+
*/
|
|
1133
|
+
declare function safeParseCurrency(currencyString: string, fallback?: number): number;
|
|
1134
|
+
/**
|
|
1135
|
+
* Formats an array of currency amounts.
|
|
1136
|
+
*
|
|
1137
|
+
* Uses core validating batch processor to eliminate duplication.
|
|
1138
|
+
*
|
|
1139
|
+
* @param amounts - Array of amounts to format
|
|
1140
|
+
* @param options - Formatting options
|
|
1141
|
+
* @returns Array of formatted currency strings (invalid amounts are skipped)
|
|
1142
|
+
*
|
|
1143
|
+
* @example
|
|
1144
|
+
* ```typescript
|
|
1145
|
+
* batchFormatCurrency([100, 200, 300]);
|
|
1146
|
+
* // ['১০০ টাকা', '২০০ টাকা', '৩০০ টাকা']
|
|
1147
|
+
*
|
|
1148
|
+
* batchFormatCurrency([100, NaN, 200], { symbol: true });
|
|
1149
|
+
* // ['৳১০০', '৳২০০']
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
1152
|
+
declare function batchFormatCurrency(amounts: number[], options?: {
|
|
1153
|
+
includeSymbol?: boolean;
|
|
1154
|
+
includeWord?: boolean;
|
|
1155
|
+
}): string[];
|
|
1135
1156
|
/**
|
|
1136
1157
|
* Compares two currency amounts.
|
|
1137
1158
|
*
|
|
1159
|
+
* Uses core currency comparator to eliminate duplication.
|
|
1160
|
+
*
|
|
1138
1161
|
* @param amount1 - First amount
|
|
1139
1162
|
* @param amount2 - Second amount
|
|
1140
1163
|
* @returns -1 if amount1 < amount2, 0 if equal, 1 if amount1 > amount2
|
|
@@ -1188,9 +1211,9 @@ declare function negateAmount(amount: number): number;
|
|
|
1188
1211
|
*
|
|
1189
1212
|
* @example
|
|
1190
1213
|
* ```typescript
|
|
1191
|
-
* parseAndFormatCurrency('1234.56'); // '
|
|
1192
|
-
* parseAndFormatCurrency(' 500 ', {
|
|
1193
|
-
* parseAndFormatCurrency(100); // '
|
|
1214
|
+
* parseAndFormatCurrency('1234.56'); // '১২৩৪.৫৬ টাকা'
|
|
1215
|
+
* parseAndFormatCurrency(' 500 ', { symbol: true }); // '৳৫০০'
|
|
1216
|
+
* parseAndFormatCurrency(100); // '১০০ টাকা'
|
|
1194
1217
|
* parseAndFormatCurrency('invalid'); // throws Error
|
|
1195
1218
|
* ```
|
|
1196
1219
|
*/
|
|
@@ -1198,97 +1221,84 @@ declare function parseAndFormatCurrency(value: any, options?: {
|
|
|
1198
1221
|
includeSymbol?: boolean;
|
|
1199
1222
|
includeWord?: boolean;
|
|
1200
1223
|
}): string;
|
|
1201
|
-
|
|
1202
1224
|
/**
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
* This function formats a standard JavaScript Date object using Bengali digits,
|
|
1206
|
-
* Bengali month names (based on Gregorian calendar), and Bengali weekday names.
|
|
1225
|
+
* Checks if two currency amounts are equal (after rounding).
|
|
1207
1226
|
*
|
|
1208
|
-
*
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1212
|
-
* **Output Formats:**
|
|
1213
|
-
* - Long (default): "day month year" or "weekday day month year"
|
|
1214
|
-
* - Short: Combines day and month in one part
|
|
1215
|
-
*
|
|
1216
|
-
* **Weekday Names:**
|
|
1217
|
-
* - রবিবার (Robibar) - Sunday
|
|
1218
|
-
* - সোমবার (Sombar) - Monday
|
|
1219
|
-
* - মঙ্গলবার (Mongolbar) - Tuesday
|
|
1220
|
-
* - বুধবার (Budhbar) - Wednesday
|
|
1221
|
-
* - বৃহস্পতিবার (Brihaspotibar) - Thursday
|
|
1222
|
-
* - শুক্রবার (Shukrobar) - Friday
|
|
1223
|
-
* - শনিবার (Shonibar) - Saturday
|
|
1224
|
-
*
|
|
1225
|
-
* @param date - Date object to format
|
|
1226
|
-
* @param options - Formatting options
|
|
1227
|
-
* @param options.includeWeekday - Include weekday name (default: false)
|
|
1228
|
-
* @param options.includeYear - Include year (default: true)
|
|
1229
|
-
* @param options.format - Format style: 'short' or 'long' (default: 'long')
|
|
1230
|
-
* @returns Formatted date string in Bangla
|
|
1227
|
+
* @param amount1 - First amount
|
|
1228
|
+
* @param amount2 - Second amount
|
|
1229
|
+
* @returns true if amounts are equal after rounding to 2 decimals
|
|
1231
1230
|
*
|
|
1232
1231
|
* @example
|
|
1233
|
-
* Basic formatting (with year):
|
|
1234
1232
|
* ```typescript
|
|
1235
|
-
*
|
|
1236
|
-
* //
|
|
1233
|
+
* isCurrencyEqual(100, 100); // true
|
|
1234
|
+
* isCurrencyEqual(100.001, 100.002); // true (both round to 100.00)
|
|
1235
|
+
* isCurrencyEqual(100, 100.01); // false
|
|
1237
1236
|
* ```
|
|
1237
|
+
*/
|
|
1238
|
+
declare function isCurrencyEqual(amount1: number, amount2: number): boolean;
|
|
1239
|
+
/**
|
|
1240
|
+
* Checks if first amount is greater than second (after rounding).
|
|
1238
1241
|
*
|
|
1239
|
-
* @
|
|
1240
|
-
*
|
|
1241
|
-
*
|
|
1242
|
-
* formatDate(new Date(2024, 0, 15), { includeYear: false });
|
|
1243
|
-
* // "১৫ বৈশাখ"
|
|
1244
|
-
* ```
|
|
1242
|
+
* @param amount1 - First amount
|
|
1243
|
+
* @param amount2 - Second amount
|
|
1244
|
+
* @returns true if amount1 > amount2
|
|
1245
1245
|
*
|
|
1246
1246
|
* @example
|
|
1247
|
-
* With weekday:
|
|
1248
1247
|
* ```typescript
|
|
1249
|
-
*
|
|
1250
|
-
*
|
|
1248
|
+
* isGreaterThan(200, 100); // true
|
|
1249
|
+
* isGreaterThan(100, 200); // false
|
|
1250
|
+
* isGreaterThan(100, 100); // false
|
|
1251
1251
|
* ```
|
|
1252
|
+
*/
|
|
1253
|
+
declare function isGreaterThan(amount1: number, amount2: number): boolean;
|
|
1254
|
+
/**
|
|
1255
|
+
* Checks if first amount is less than second (after rounding).
|
|
1256
|
+
*
|
|
1257
|
+
* @param amount1 - First amount
|
|
1258
|
+
* @param amount2 - Second amount
|
|
1259
|
+
* @returns true if amount1 < amount2
|
|
1252
1260
|
*
|
|
1253
1261
|
* @example
|
|
1254
|
-
* Short format:
|
|
1255
1262
|
* ```typescript
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1263
|
+
* isLessThan(100, 200); // true
|
|
1264
|
+
* isLessThan(200, 100); // false
|
|
1265
|
+
* isLessThan(100, 100); // false
|
|
1258
1266
|
* ```
|
|
1267
|
+
*/
|
|
1268
|
+
declare function isLessThan(amount1: number, amount2: number): boolean;
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Formats a Gregorian date using the Bangla calendar with Bangla digits, month names, and weekdays.
|
|
1272
|
+
*
|
|
1273
|
+
* This function converts a JavaScript Date object to the Bangla calendar and
|
|
1274
|
+
* formats it using Bangla digits, Bangla month names, and Bangla weekday names.
|
|
1275
|
+
*
|
|
1276
|
+
* @param date - Date object to format
|
|
1277
|
+
* @param options - Formatting options
|
|
1278
|
+
* @param options.includeWeekday - Include weekday name (default: false)
|
|
1279
|
+
* @param options.includeYear - Include year (default: true)
|
|
1280
|
+
* @param options.format - Format style: 'short' or 'long' (default: 'long')
|
|
1281
|
+
* @returns Formatted date string in Bangla calendar
|
|
1259
1282
|
*
|
|
1260
1283
|
* @example
|
|
1261
|
-
*
|
|
1284
|
+
* Basic formatting:
|
|
1262
1285
|
* ```typescript
|
|
1263
|
-
* formatDate(
|
|
1264
|
-
*
|
|
1265
|
-
* { includeWeekday: true, includeYear: false, format: 'short' }
|
|
1266
|
-
* );
|
|
1267
|
-
* // "সোমবার ১৫ বৈশাখ"
|
|
1286
|
+
* formatDate(new Date(2024, 3, 14));
|
|
1287
|
+
* // "১ বৈশাখ ১৪৩১" (Pohela Boishakh)
|
|
1268
1288
|
* ```
|
|
1269
1289
|
*
|
|
1270
1290
|
* @example
|
|
1271
|
-
*
|
|
1291
|
+
* Without year:
|
|
1272
1292
|
* ```typescript
|
|
1273
|
-
*
|
|
1274
|
-
*
|
|
1275
|
-
* // "আজ: মঙ্গলবার ৭ পৌষ ২০২৫" (example)
|
|
1293
|
+
* formatDate(new Date(2024, 3, 14), { includeYear: false });
|
|
1294
|
+
* // "১ বৈশাখ"
|
|
1276
1295
|
* ```
|
|
1277
1296
|
*
|
|
1278
1297
|
* @example
|
|
1279
|
-
*
|
|
1298
|
+
* With weekday:
|
|
1280
1299
|
* ```typescript
|
|
1281
|
-
*
|
|
1282
|
-
*
|
|
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
|
-
* // "শুক্রবার ২১ জ্যৈষ্ঠ"
|
|
1300
|
+
* formatDate(new Date(2024, 3, 14), { includeWeekday: true });
|
|
1301
|
+
* // "রবিবার ১ বৈশাখ ১৪৩১"
|
|
1292
1302
|
* ```
|
|
1293
1303
|
*/
|
|
1294
1304
|
declare function formatDate(date: Date, options?: {
|
|
@@ -1298,31 +1308,31 @@ declare function formatDate(date: Date, options?: {
|
|
|
1298
1308
|
}): string;
|
|
1299
1309
|
|
|
1300
1310
|
/**
|
|
1301
|
-
* Parses a
|
|
1311
|
+
* Parses a Bangla formatted date string into a JavaScript Date object.
|
|
1302
1312
|
*
|
|
1303
|
-
* This function supports multiple
|
|
1313
|
+
* This function supports multiple Bangla date formats with both Bangla
|
|
1304
1314
|
* and English digits. It handles month names and separator-based formats.
|
|
1305
1315
|
*
|
|
1306
1316
|
* **Supported Formats:**
|
|
1307
1317
|
* 1. Month name format: "day month [year]"
|
|
1308
|
-
* - "১৫ বৈশাখ ১৪৩১" (
|
|
1318
|
+
* - "১৫ বৈশাখ ১৪৩১" (Bangla digits)
|
|
1309
1319
|
* - "15 বৈশাখ 1431" (English digits)
|
|
1310
1320
|
* - "১৫ বৈশাখ" (without year, uses current year)
|
|
1311
1321
|
*
|
|
1312
1322
|
* 2. Separator format: "day/month/year" or "day-month-year"
|
|
1313
|
-
* - "১৫/০৪/২০২৪" (
|
|
1323
|
+
* - "১৫/০৪/২০২৪" (Bangla digits with slash)
|
|
1314
1324
|
* - "15-04-2024" (English digits with dash)
|
|
1315
|
-
* - "১৫/০৪/২০২৪" (mixed
|
|
1325
|
+
* - "১৫/০৪/২০২৪" (mixed Bangla/English)
|
|
1316
1326
|
*
|
|
1317
|
-
* **Note:** This parses to Gregorian dates with
|
|
1318
|
-
* For
|
|
1327
|
+
* **Note:** This parses to Gregorian dates with Bangla formatting.
|
|
1328
|
+
* For Bangla calendar date parsing, use the `calendar` module's `fromBangla` function.
|
|
1319
1329
|
*
|
|
1320
|
-
* @param dateString -
|
|
1330
|
+
* @param dateString - Bangla formatted date string
|
|
1321
1331
|
* @returns JavaScript Date object
|
|
1322
1332
|
* @throws {Error} If the date string cannot be parsed
|
|
1323
1333
|
*
|
|
1324
1334
|
* @example
|
|
1325
|
-
* Month name format with
|
|
1335
|
+
* Month name format with Bangla digits:
|
|
1326
1336
|
* ```typescript
|
|
1327
1337
|
* parseDate('১৫ বৈশাখ ১৪৩১');
|
|
1328
1338
|
* // Date object for the 15th day of month 1 (Boishakh) in year 1431
|
|
@@ -1343,7 +1353,7 @@ declare function formatDate(date: Date, options?: {
|
|
|
1343
1353
|
* ```
|
|
1344
1354
|
*
|
|
1345
1355
|
* @example
|
|
1346
|
-
* Separator format with
|
|
1356
|
+
* Separator format with Bangla digits:
|
|
1347
1357
|
* ```typescript
|
|
1348
1358
|
* parseDate('১৫/০৪/২০২৪');
|
|
1349
1359
|
* // Date object for April 15, 2024
|
|
@@ -1447,94 +1457,94 @@ declare function parseDate(dateString: string): Date;
|
|
|
1447
1457
|
*/
|
|
1448
1458
|
declare function isValidDate(date: Date): boolean;
|
|
1449
1459
|
/**
|
|
1450
|
-
* Checks if a string is a valid
|
|
1460
|
+
* Checks if a string is a valid Bangla date format.
|
|
1451
1461
|
*
|
|
1452
1462
|
* Valid formats include:
|
|
1453
|
-
* - "১৫ বৈশাখ ১৪৩১" (with
|
|
1463
|
+
* - "১৫ বৈশাখ ১৪৩১" (with Bangla digits and month name)
|
|
1454
1464
|
* - "১৫ বৈশাখ" (without year)
|
|
1455
1465
|
* - "15 বৈশাখ 1431" (with English digits and month name)
|
|
1456
|
-
* - "১৫/০৪/২০২৪" or "১৫-০৪-২০২৪" (
|
|
1466
|
+
* - "১৫/০৪/২০২৪" or "১৫-০৪-২০২৪" (Bangla digits with separators)
|
|
1457
1467
|
* - "15/04/2024" or "15-04-2024" (English digits with separators)
|
|
1458
1468
|
*
|
|
1459
1469
|
* @param dateString - String to validate
|
|
1460
|
-
* @returns true if string matches a valid
|
|
1470
|
+
* @returns true if string matches a valid Bangla date format, false otherwise
|
|
1461
1471
|
*
|
|
1462
1472
|
* @example
|
|
1463
1473
|
* Valid formats:
|
|
1464
1474
|
* ```typescript
|
|
1465
|
-
*
|
|
1466
|
-
*
|
|
1467
|
-
*
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1475
|
+
* isValidBanglaDateString('১৫ বৈশাখ ১৪৩১'); // true
|
|
1476
|
+
* isValidBanglaDateString('১৫ বৈশাখ'); // true
|
|
1477
|
+
* isValidBanglaDateString('15 বৈশাখ 1431'); // true
|
|
1478
|
+
* isValidBanglaDateString('১৫/০৪/২০২৪'); // true
|
|
1479
|
+
* isValidBanglaDateString('15-04-2024'); // true
|
|
1470
1480
|
* ```
|
|
1471
1481
|
*
|
|
1472
1482
|
* @example
|
|
1473
1483
|
* Invalid formats:
|
|
1474
1484
|
* ```typescript
|
|
1475
|
-
*
|
|
1476
|
-
*
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1485
|
+
* isValidBanglaDateString('invalid'); // false
|
|
1486
|
+
* isValidBanglaDateString('2024-01-15'); // false (ISO format not supported)
|
|
1487
|
+
* isValidBanglaDateString(''); // false
|
|
1488
|
+
* isValidBanglaDateString(' '); // false
|
|
1479
1489
|
* ```
|
|
1480
1490
|
*/
|
|
1481
|
-
declare function
|
|
1491
|
+
declare function isValidBanglaDateString(dateString: string): boolean;
|
|
1482
1492
|
/**
|
|
1483
|
-
* Checks if a string contains
|
|
1493
|
+
* Checks if a string contains Bangla digits.
|
|
1484
1494
|
*
|
|
1485
|
-
*
|
|
1495
|
+
* Bangla digits: ০ ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯
|
|
1486
1496
|
*
|
|
1487
1497
|
* @param text - String to check
|
|
1488
|
-
* @returns true if string contains at least one
|
|
1498
|
+
* @returns true if string contains at least one Bangla digit, false otherwise
|
|
1489
1499
|
*
|
|
1490
1500
|
* @example
|
|
1491
|
-
* Strings with
|
|
1501
|
+
* Strings with Bangla digits:
|
|
1492
1502
|
* ```typescript
|
|
1493
|
-
*
|
|
1494
|
-
*
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1503
|
+
* hasBanglaDigits('১৫'); // true
|
|
1504
|
+
* hasBanglaDigits('১৫ বৈশাখ'); // true
|
|
1505
|
+
* hasBanglaDigits('Today is ১৫ বৈশাখ'); // true
|
|
1506
|
+
* hasBanglaDigits('১'); // true
|
|
1497
1507
|
* ```
|
|
1498
1508
|
*
|
|
1499
1509
|
* @example
|
|
1500
|
-
* Strings without
|
|
1510
|
+
* Strings without Bangla digits:
|
|
1501
1511
|
* ```typescript
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
*
|
|
1505
|
-
*
|
|
1512
|
+
* hasBanglaDigits('15'); // false
|
|
1513
|
+
* hasBanglaDigits('বৈশাখ'); // false
|
|
1514
|
+
* hasBanglaDigits(''); // false
|
|
1515
|
+
* hasBanglaDigits('hello'); // false
|
|
1506
1516
|
* ```
|
|
1507
1517
|
*/
|
|
1508
|
-
declare function
|
|
1518
|
+
declare function hasBanglaDigits(text: string): boolean;
|
|
1509
1519
|
/**
|
|
1510
|
-
* Checks if a string contains a
|
|
1520
|
+
* Checks if a string contains a Bangla month name.
|
|
1511
1521
|
*
|
|
1512
1522
|
* Valid month names:
|
|
1513
1523
|
* বৈশাখ, জ্যৈষ্ঠ, আষাঢ়, শ্রাবণ, ভাদ্র, আশ্বিন,
|
|
1514
1524
|
* কার্তিক, অগ্রহায়ণ, পৌষ, মাঘ, ফাল্গুন, চৈত্র
|
|
1515
1525
|
*
|
|
1516
1526
|
* @param text - String to check
|
|
1517
|
-
* @returns true if string contains a
|
|
1527
|
+
* @returns true if string contains a Bangla month name, false otherwise
|
|
1518
1528
|
*
|
|
1519
1529
|
* @example
|
|
1520
1530
|
* Strings with month names:
|
|
1521
1531
|
* ```typescript
|
|
1522
|
-
*
|
|
1523
|
-
*
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1532
|
+
* hasBanglaMonth('১৫ বৈশাখ ১৪৩১'); // true
|
|
1533
|
+
* hasBanglaMonth('বৈশাখ'); // true
|
|
1534
|
+
* hasBanglaMonth('Today is বৈশাখ month'); // true
|
|
1535
|
+
* hasBanglaMonth('চৈত্র'); // true
|
|
1526
1536
|
* ```
|
|
1527
1537
|
*
|
|
1528
1538
|
* @example
|
|
1529
1539
|
* Strings without month names:
|
|
1530
1540
|
* ```typescript
|
|
1531
|
-
*
|
|
1532
|
-
*
|
|
1533
|
-
*
|
|
1534
|
-
*
|
|
1541
|
+
* hasBanglaMonth('১৫/০৪/২০২৪'); // false
|
|
1542
|
+
* hasBanglaMonth('15'); // false
|
|
1543
|
+
* hasBanglaMonth('January'); // false
|
|
1544
|
+
* hasBanglaMonth(''); // false
|
|
1535
1545
|
* ```
|
|
1536
1546
|
*/
|
|
1537
|
-
declare function
|
|
1547
|
+
declare function hasBanglaMonth(text: string): boolean;
|
|
1538
1548
|
/**
|
|
1539
1549
|
* Sanitizes a Date object, returning null if invalid.
|
|
1540
1550
|
*
|
|
@@ -1577,369 +1587,384 @@ declare function hasBengaliMonth(text: string): boolean;
|
|
|
1577
1587
|
declare function sanitizeDate(date: Date): Date | null;
|
|
1578
1588
|
|
|
1579
1589
|
/**
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1582
|
-
* This module provides helper functions for working with Bangla date formatting,
|
|
1583
|
-
* including safe conversions, date comparisons, and formatting utilities.
|
|
1584
|
-
*
|
|
1585
|
-
* @module date/utils
|
|
1590
|
+
* Date comparison operations
|
|
1591
|
+
* Uses core comparison utilities
|
|
1586
1592
|
*/
|
|
1587
1593
|
/**
|
|
1588
|
-
*
|
|
1594
|
+
* Compares two dates and returns -1, 0, or 1.
|
|
1589
1595
|
*
|
|
1590
|
-
*
|
|
1591
|
-
* Returns a fallback string for invalid inputs.
|
|
1596
|
+
* Uses core date comparator for consistent comparison logic.
|
|
1592
1597
|
*
|
|
1593
|
-
* @param
|
|
1594
|
-
* @param
|
|
1595
|
-
* @
|
|
1596
|
-
* @
|
|
1598
|
+
* @param date1 - First date
|
|
1599
|
+
* @param date2 - Second date
|
|
1600
|
+
* @returns -1 if date1 < date2, 0 if equal, 1 if date1 > date2
|
|
1601
|
+
* @throws Error if either date is invalid
|
|
1597
1602
|
*
|
|
1598
1603
|
* @example
|
|
1599
|
-
*
|
|
1604
|
+
* First date is earlier:
|
|
1600
1605
|
* ```typescript
|
|
1601
|
-
*
|
|
1602
|
-
* //
|
|
1606
|
+
* compareDates(new Date(2024, 0, 15), new Date(2024, 0, 20));
|
|
1607
|
+
* // -1
|
|
1603
1608
|
* ```
|
|
1604
1609
|
*
|
|
1605
1610
|
* @example
|
|
1606
|
-
*
|
|
1611
|
+
* Dates are equal:
|
|
1607
1612
|
* ```typescript
|
|
1608
|
-
*
|
|
1609
|
-
* //
|
|
1610
|
-
*
|
|
1611
|
-
* safeFormatDate(null as any, {}, 'N/A');
|
|
1612
|
-
* // "N/A"
|
|
1613
|
+
* compareDates(new Date(2024, 0, 15), new Date(2024, 0, 15));
|
|
1614
|
+
* // 0
|
|
1613
1615
|
* ```
|
|
1614
1616
|
*
|
|
1615
1617
|
* @example
|
|
1616
|
-
*
|
|
1618
|
+
* First date is later:
|
|
1617
1619
|
* ```typescript
|
|
1618
|
-
*
|
|
1619
|
-
* //
|
|
1620
|
+
* compareDates(new Date(2024, 0, 20), new Date(2024, 0, 15));
|
|
1621
|
+
* // 1
|
|
1620
1622
|
* ```
|
|
1621
1623
|
*/
|
|
1622
|
-
declare function
|
|
1623
|
-
|
|
1624
|
-
includeYear?: boolean;
|
|
1625
|
-
format?: 'short' | 'long';
|
|
1626
|
-
}, fallback?: string): string;
|
|
1624
|
+
declare function compareDates(date1: Date, date2: Date): -1 | 0 | 1;
|
|
1625
|
+
|
|
1627
1626
|
/**
|
|
1628
|
-
*
|
|
1629
|
-
*
|
|
1630
|
-
|
|
1631
|
-
|
|
1627
|
+
* Date calculation operations
|
|
1628
|
+
* Functions for date arithmetic and differences
|
|
1629
|
+
*/
|
|
1630
|
+
/**
|
|
1631
|
+
* Gets the difference in days between two dates.
|
|
1632
1632
|
*
|
|
1633
|
-
* @param
|
|
1634
|
-
* @param
|
|
1635
|
-
* @returns
|
|
1633
|
+
* @param date1 - First date
|
|
1634
|
+
* @param date2 - Second date
|
|
1635
|
+
* @returns Number of days between dates (date2 - date1)
|
|
1636
|
+
* @throws Error if either date is invalid
|
|
1636
1637
|
*
|
|
1637
1638
|
* @example
|
|
1638
|
-
* Valid date strings:
|
|
1639
1639
|
* ```typescript
|
|
1640
|
-
*
|
|
1641
|
-
*
|
|
1640
|
+
* const date1 = new Date(2024, 0, 1);
|
|
1641
|
+
* const date2 = new Date(2024, 0, 11);
|
|
1642
|
+
* getDaysDifference(date1, date2);
|
|
1643
|
+
* // 10
|
|
1642
1644
|
* ```
|
|
1643
1645
|
*
|
|
1644
1646
|
* @example
|
|
1645
|
-
*
|
|
1647
|
+
* Negative difference:
|
|
1646
1648
|
* ```typescript
|
|
1647
|
-
* const
|
|
1648
|
-
*
|
|
1649
|
-
*
|
|
1650
|
-
*
|
|
1651
|
-
* safeParseDate('not a date', fallbackDate);
|
|
1652
|
-
* // Returns fallbackDate
|
|
1649
|
+
* const date1 = new Date(2024, 0, 11);
|
|
1650
|
+
* const date2 = new Date(2024, 0, 1);
|
|
1651
|
+
* getDaysDifference(date1, date2);
|
|
1652
|
+
* // -10
|
|
1653
1653
|
* ```
|
|
1654
1654
|
*/
|
|
1655
|
-
declare function
|
|
1655
|
+
declare function getDaysDifference(date1: Date, date2: Date): number;
|
|
1656
1656
|
/**
|
|
1657
|
-
*
|
|
1658
|
-
*
|
|
1659
|
-
* Convenience function that formats the current date.
|
|
1657
|
+
* Adds days to a date.
|
|
1660
1658
|
*
|
|
1661
|
-
* @param
|
|
1662
|
-
* @
|
|
1659
|
+
* @param date - Starting date
|
|
1660
|
+
* @param days - Number of days to add (can be negative)
|
|
1661
|
+
* @returns New Date object
|
|
1662
|
+
* @throws Error if date is invalid
|
|
1663
1663
|
*
|
|
1664
1664
|
* @example
|
|
1665
|
+
* Adding days:
|
|
1665
1666
|
* ```typescript
|
|
1666
|
-
*
|
|
1667
|
-
*
|
|
1667
|
+
* const date = new Date(2024, 0, 1);
|
|
1668
|
+
* addDays(date, 10);
|
|
1669
|
+
* // Date for 2024-01-11
|
|
1668
1670
|
* ```
|
|
1669
1671
|
*
|
|
1670
1672
|
* @example
|
|
1671
|
-
*
|
|
1673
|
+
* Subtracting days:
|
|
1672
1674
|
* ```typescript
|
|
1673
|
-
*
|
|
1674
|
-
*
|
|
1675
|
+
* const date = new Date(2024, 0, 11);
|
|
1676
|
+
* addDays(date, -10);
|
|
1677
|
+
* // Date for 2024-01-01
|
|
1675
1678
|
* ```
|
|
1679
|
+
*/
|
|
1680
|
+
declare function addDays(date: Date, days: number): Date;
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* Date range and relative checking operations
|
|
1684
|
+
* Functions for checking if dates are today, past, future, or in ranges
|
|
1685
|
+
*/
|
|
1686
|
+
/**
|
|
1687
|
+
* Checks if a date is today.
|
|
1688
|
+
*
|
|
1689
|
+
* @param date - Date to check
|
|
1690
|
+
* @returns true if date is today, false otherwise
|
|
1676
1691
|
*
|
|
1677
1692
|
* @example
|
|
1678
|
-
* Without year:
|
|
1679
1693
|
* ```typescript
|
|
1680
|
-
*
|
|
1681
|
-
* //
|
|
1694
|
+
* isToday(new Date());
|
|
1695
|
+
* // true
|
|
1696
|
+
*
|
|
1697
|
+
* isToday(new Date(2024, 0, 1));
|
|
1698
|
+
* // false (unless today is 2024-01-01)
|
|
1682
1699
|
* ```
|
|
1683
1700
|
*/
|
|
1684
|
-
declare function
|
|
1685
|
-
includeWeekday?: boolean;
|
|
1686
|
-
includeYear?: boolean;
|
|
1687
|
-
format?: 'short' | 'long';
|
|
1688
|
-
}): string;
|
|
1701
|
+
declare function isToday(date: Date): boolean;
|
|
1689
1702
|
/**
|
|
1690
|
-
*
|
|
1703
|
+
* Checks if a date is in the past.
|
|
1691
1704
|
*
|
|
1692
|
-
* @param
|
|
1693
|
-
* @
|
|
1694
|
-
* @returns Array of formatted date strings
|
|
1705
|
+
* @param date - Date to check
|
|
1706
|
+
* @returns true if date is before now, false otherwise
|
|
1695
1707
|
*
|
|
1696
1708
|
* @example
|
|
1697
1709
|
* ```typescript
|
|
1698
|
-
*
|
|
1699
|
-
*
|
|
1700
|
-
* new Date(2024, 1, 20),
|
|
1701
|
-
* new Date(2024, 2, 25)
|
|
1702
|
-
* ];
|
|
1703
|
-
* batchFormatDates(dates);
|
|
1704
|
-
* // ["১৫ বৈশাখ ২০২৪", "২০ জ্যৈষ্ঠ ২০২৪", "২৫ আষাঢ় ২০২৪"] (examples)
|
|
1705
|
-
* ```
|
|
1710
|
+
* isPast(new Date(2020, 0, 1));
|
|
1711
|
+
* // true
|
|
1706
1712
|
*
|
|
1707
|
-
*
|
|
1708
|
-
*
|
|
1709
|
-
* ```typescript
|
|
1710
|
-
* batchFormatDates(dates, { includeYear: false });
|
|
1711
|
-
* // ["১৫ বৈশাখ", "২০ জ্যৈষ্ঠ", "২৫ আষাঢ়"]
|
|
1713
|
+
* isPast(new Date(2030, 0, 1));
|
|
1714
|
+
* // false
|
|
1712
1715
|
* ```
|
|
1713
1716
|
*/
|
|
1714
|
-
declare function
|
|
1715
|
-
includeWeekday?: boolean;
|
|
1716
|
-
includeYear?: boolean;
|
|
1717
|
-
format?: 'short' | 'long';
|
|
1718
|
-
}): string[];
|
|
1717
|
+
declare function isPast(date: Date): boolean;
|
|
1719
1718
|
/**
|
|
1720
|
-
*
|
|
1719
|
+
* Checks if a date is in the future.
|
|
1721
1720
|
*
|
|
1722
|
-
* @param
|
|
1723
|
-
* @returns
|
|
1721
|
+
* @param date - Date to check
|
|
1722
|
+
* @returns true if date is after now, false otherwise
|
|
1724
1723
|
*
|
|
1725
1724
|
* @example
|
|
1726
1725
|
* ```typescript
|
|
1727
|
-
*
|
|
1728
|
-
*
|
|
1729
|
-
* '২০ জ্যৈষ্ঠ ১৪৩১',
|
|
1730
|
-
* '১৫/০৪/২০২৪'
|
|
1731
|
-
* ];
|
|
1732
|
-
* const dates = batchParseDates(dateStrings);
|
|
1733
|
-
* // Array of Date objects
|
|
1734
|
-
* ```
|
|
1726
|
+
* isFuture(new Date(2030, 0, 1));
|
|
1727
|
+
* // true
|
|
1735
1728
|
*
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1738
|
-
* ```typescript
|
|
1739
|
-
* const mixed = ['১৫ বৈশাখ ১৪৩১', 'invalid'];
|
|
1740
|
-
* const dates = batchParseDates(mixed);
|
|
1741
|
-
* // First element: parsed Date, second element: current Date (fallback)
|
|
1729
|
+
* isFuture(new Date(2020, 0, 1));
|
|
1730
|
+
* // false
|
|
1742
1731
|
* ```
|
|
1743
1732
|
*/
|
|
1744
|
-
declare function
|
|
1733
|
+
declare function isFuture(date: Date): boolean;
|
|
1745
1734
|
/**
|
|
1746
|
-
* Checks if a date
|
|
1735
|
+
* Checks if a date is in a range (inclusive).
|
|
1747
1736
|
*
|
|
1748
|
-
* @param
|
|
1749
|
-
* @
|
|
1737
|
+
* @param date - Date to check
|
|
1738
|
+
* @param start - Start of range (inclusive)
|
|
1739
|
+
* @param end - End of range (inclusive)
|
|
1740
|
+
* @returns true if date is in range, false otherwise
|
|
1750
1741
|
*
|
|
1751
1742
|
* @example
|
|
1752
|
-
*
|
|
1743
|
+
* Date within range:
|
|
1753
1744
|
* ```typescript
|
|
1754
|
-
*
|
|
1755
|
-
*
|
|
1756
|
-
*
|
|
1745
|
+
* isDateInRange(
|
|
1746
|
+
* new Date(2024, 0, 15),
|
|
1747
|
+
* new Date(2024, 0, 10),
|
|
1748
|
+
* new Date(2024, 0, 20)
|
|
1749
|
+
* );
|
|
1750
|
+
* // true
|
|
1757
1751
|
* ```
|
|
1758
1752
|
*
|
|
1759
1753
|
* @example
|
|
1760
|
-
*
|
|
1754
|
+
* Date on boundary:
|
|
1761
1755
|
* ```typescript
|
|
1762
|
-
*
|
|
1763
|
-
*
|
|
1764
|
-
*
|
|
1756
|
+
* isDateInRange(
|
|
1757
|
+
* new Date(2024, 0, 10),
|
|
1758
|
+
* new Date(2024, 0, 10),
|
|
1759
|
+
* new Date(2024, 0, 20)
|
|
1760
|
+
* );
|
|
1761
|
+
* // true
|
|
1762
|
+
* ```
|
|
1763
|
+
*
|
|
1764
|
+
* @example
|
|
1765
|
+
* Date outside range:
|
|
1766
|
+
* ```typescript
|
|
1767
|
+
* isDateInRange(
|
|
1768
|
+
* new Date(2024, 0, 25),
|
|
1769
|
+
* new Date(2024, 0, 10),
|
|
1770
|
+
* new Date(2024, 0, 20)
|
|
1771
|
+
* );
|
|
1772
|
+
* // false
|
|
1765
1773
|
* ```
|
|
1766
1774
|
*/
|
|
1767
|
-
declare function
|
|
1775
|
+
declare function isDateInRange(date: Date, start: Date, end: Date): boolean;
|
|
1776
|
+
|
|
1768
1777
|
/**
|
|
1769
|
-
*
|
|
1778
|
+
* Date utility functions
|
|
1779
|
+
* Domain-specific utilities using core patterns
|
|
1780
|
+
*/
|
|
1781
|
+
/**
|
|
1782
|
+
* Safely formats a date with fallback value.
|
|
1770
1783
|
*
|
|
1771
|
-
*
|
|
1772
|
-
*
|
|
1773
|
-
*
|
|
1784
|
+
* Unlike formatDate, this function doesn't throw on invalid dates.
|
|
1785
|
+
* Returns a fallback string for invalid inputs.
|
|
1786
|
+
*
|
|
1787
|
+
* @param date - Date object to format
|
|
1788
|
+
* @param options - Formatting options
|
|
1789
|
+
* @param fallback - Fallback string if formatting fails (default: empty string)
|
|
1790
|
+
* @returns Formatted date string or fallback
|
|
1774
1791
|
*
|
|
1775
1792
|
* @example
|
|
1776
|
-
*
|
|
1793
|
+
* Valid dates:
|
|
1777
1794
|
* ```typescript
|
|
1778
|
-
*
|
|
1779
|
-
* // -
|
|
1795
|
+
* safeFormatDate(new Date(2024, 0, 15));
|
|
1796
|
+
* // "১৫ বৈশাখ ২০২৪" (example - depends on conversion)
|
|
1780
1797
|
* ```
|
|
1781
1798
|
*
|
|
1782
1799
|
* @example
|
|
1783
|
-
*
|
|
1800
|
+
* Invalid dates with fallback:
|
|
1784
1801
|
* ```typescript
|
|
1785
|
-
*
|
|
1786
|
-
*
|
|
1787
|
-
*
|
|
1802
|
+
* safeFormatDate(new Date('invalid'), {}, 'তারিখ নেই');
|
|
1803
|
+
* // "তারিখ নেই"
|
|
1804
|
+
*
|
|
1805
|
+
* safeFormatDate(null as any, {}, 'N/A');
|
|
1806
|
+
* // "N/A"
|
|
1788
1807
|
* ```
|
|
1789
1808
|
*
|
|
1790
1809
|
* @example
|
|
1791
|
-
*
|
|
1810
|
+
* Default fallback:
|
|
1792
1811
|
* ```typescript
|
|
1793
|
-
*
|
|
1794
|
-
* //
|
|
1812
|
+
* safeFormatDate(new Date('invalid'));
|
|
1813
|
+
* // ""
|
|
1795
1814
|
* ```
|
|
1796
1815
|
*/
|
|
1797
|
-
declare function
|
|
1816
|
+
declare function safeFormatDate(date: Date, options?: {
|
|
1817
|
+
includeWeekday?: boolean;
|
|
1818
|
+
includeYear?: boolean;
|
|
1819
|
+
format?: 'short' | 'long';
|
|
1820
|
+
}, fallback?: string): string;
|
|
1798
1821
|
/**
|
|
1799
|
-
*
|
|
1822
|
+
* Safely parses a Bangla date string with fallback.
|
|
1800
1823
|
*
|
|
1801
|
-
*
|
|
1802
|
-
*
|
|
1824
|
+
* Unlike parseDate, this function doesn't throw on invalid strings.
|
|
1825
|
+
* Returns a fallback Date for invalid inputs.
|
|
1826
|
+
*
|
|
1827
|
+
* @param dateString - Bangla date string to parse
|
|
1828
|
+
* @param fallback - Fallback Date if parsing fails (default: current date)
|
|
1829
|
+
* @returns Parsed Date object or fallback
|
|
1803
1830
|
*
|
|
1804
1831
|
* @example
|
|
1832
|
+
* Valid date strings:
|
|
1805
1833
|
* ```typescript
|
|
1806
|
-
*
|
|
1807
|
-
* //
|
|
1808
|
-
*
|
|
1809
|
-
* isToday(new Date(2024, 0, 1));
|
|
1810
|
-
* // false (unless today is 2024-01-01)
|
|
1834
|
+
* safeParseDate('১৫ বৈশাখ ১৪৩১');
|
|
1835
|
+
* // Date object for the parsed date
|
|
1811
1836
|
* ```
|
|
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
1837
|
*
|
|
1820
1838
|
* @example
|
|
1839
|
+
* Invalid strings with fallback:
|
|
1821
1840
|
* ```typescript
|
|
1822
|
-
*
|
|
1823
|
-
*
|
|
1841
|
+
* const fallbackDate = new Date(2024, 0, 1);
|
|
1842
|
+
* safeParseDate('invalid', fallbackDate);
|
|
1843
|
+
* // Returns fallbackDate
|
|
1824
1844
|
*
|
|
1825
|
-
*
|
|
1826
|
-
* //
|
|
1845
|
+
* safeParseDate('not a date', fallbackDate);
|
|
1846
|
+
* // Returns fallbackDate
|
|
1827
1847
|
* ```
|
|
1828
1848
|
*/
|
|
1829
|
-
declare function
|
|
1849
|
+
declare function safeParseDate(dateString: string, fallback?: Date): Date;
|
|
1830
1850
|
/**
|
|
1831
|
-
*
|
|
1851
|
+
* Formats today's date in Bangla.
|
|
1852
|
+
*
|
|
1853
|
+
* Convenience function that formats the current date.
|
|
1854
|
+
*
|
|
1855
|
+
* @param options - Formatting options
|
|
1856
|
+
* @returns Formatted current date string
|
|
1832
1857
|
*
|
|
1833
|
-
* @
|
|
1834
|
-
*
|
|
1858
|
+
* @example
|
|
1859
|
+
* ```typescript
|
|
1860
|
+
* formatToday();
|
|
1861
|
+
* // "৭ বৈশাখ ২০২৫" (example for current date)
|
|
1862
|
+
* ```
|
|
1835
1863
|
*
|
|
1836
1864
|
* @example
|
|
1865
|
+
* With weekday:
|
|
1837
1866
|
* ```typescript
|
|
1838
|
-
*
|
|
1839
|
-
* //
|
|
1867
|
+
* formatToday({ includeWeekday: true });
|
|
1868
|
+
* // "মঙ্গলবার ৭ বৈশাখ ২০২৫" (example)
|
|
1869
|
+
* ```
|
|
1840
1870
|
*
|
|
1841
|
-
*
|
|
1842
|
-
*
|
|
1871
|
+
* @example
|
|
1872
|
+
* Without year:
|
|
1873
|
+
* ```typescript
|
|
1874
|
+
* formatToday({ includeYear: false });
|
|
1875
|
+
* // "৭ বৈশাখ"
|
|
1843
1876
|
* ```
|
|
1844
1877
|
*/
|
|
1845
|
-
declare function
|
|
1878
|
+
declare function formatToday(options?: {
|
|
1879
|
+
includeWeekday?: boolean;
|
|
1880
|
+
includeYear?: boolean;
|
|
1881
|
+
format?: 'short' | 'long';
|
|
1882
|
+
}): string;
|
|
1846
1883
|
/**
|
|
1847
|
-
*
|
|
1884
|
+
* Formats an array of dates in Bangla.
|
|
1848
1885
|
*
|
|
1849
|
-
* @param
|
|
1850
|
-
* @param
|
|
1851
|
-
* @returns
|
|
1886
|
+
* @param dates - Array of Date objects
|
|
1887
|
+
* @param options - Formatting options
|
|
1888
|
+
* @returns Array of formatted date strings
|
|
1852
1889
|
*
|
|
1853
1890
|
* @example
|
|
1854
1891
|
* ```typescript
|
|
1855
|
-
* const
|
|
1856
|
-
*
|
|
1857
|
-
*
|
|
1858
|
-
*
|
|
1892
|
+
* const dates = [
|
|
1893
|
+
* new Date(2024, 0, 15),
|
|
1894
|
+
* new Date(2024, 1, 20),
|
|
1895
|
+
* new Date(2024, 2, 25)
|
|
1896
|
+
* ];
|
|
1897
|
+
* batchFormatDates(dates);
|
|
1898
|
+
* // ["১৫ বৈশাখ ২০২৪", "২০ জ্যৈষ্ঠ ২০২৪", "২৫ আষাঢ় ২০২৪"] (examples)
|
|
1859
1899
|
* ```
|
|
1860
1900
|
*
|
|
1861
1901
|
* @example
|
|
1862
|
-
*
|
|
1902
|
+
* Without year:
|
|
1863
1903
|
* ```typescript
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
* getDaysDifference(date1, date2);
|
|
1867
|
-
* // -10
|
|
1904
|
+
* batchFormatDates(dates, { includeYear: false });
|
|
1905
|
+
* // ["১৫ বৈশাখ", "২০ জ্যৈষ্ঠ", "২৫ আষাঢ়"]
|
|
1868
1906
|
* ```
|
|
1869
1907
|
*/
|
|
1870
|
-
declare function
|
|
1908
|
+
declare function batchFormatDates(dates: Date[], options?: {
|
|
1909
|
+
includeWeekday?: boolean;
|
|
1910
|
+
includeYear?: boolean;
|
|
1911
|
+
format?: 'short' | 'long';
|
|
1912
|
+
}): string[];
|
|
1871
1913
|
/**
|
|
1872
|
-
*
|
|
1914
|
+
* Parses an array of Bangla date strings.
|
|
1873
1915
|
*
|
|
1874
|
-
* @param
|
|
1875
|
-
* @
|
|
1876
|
-
* @returns New Date object
|
|
1916
|
+
* @param dateStrings - Array of Bangla date strings
|
|
1917
|
+
* @returns Array of Date objects
|
|
1877
1918
|
*
|
|
1878
1919
|
* @example
|
|
1879
|
-
* Adding days:
|
|
1880
1920
|
* ```typescript
|
|
1881
|
-
* const
|
|
1882
|
-
*
|
|
1883
|
-
*
|
|
1921
|
+
* const dateStrings = [
|
|
1922
|
+
* '১৫ বৈশাখ ১৪৩১',
|
|
1923
|
+
* '২০ জ্যৈষ্ঠ ১৪৩১',
|
|
1924
|
+
* '১৫/০৪/২০২৪'
|
|
1925
|
+
* ];
|
|
1926
|
+
* const dates = batchParseDates(dateStrings);
|
|
1927
|
+
* // Array of Date objects
|
|
1884
1928
|
* ```
|
|
1885
1929
|
*
|
|
1886
1930
|
* @example
|
|
1887
|
-
*
|
|
1931
|
+
* Handling invalid dates:
|
|
1888
1932
|
* ```typescript
|
|
1889
|
-
* const
|
|
1890
|
-
*
|
|
1891
|
-
* // Date
|
|
1933
|
+
* const mixed = ['১৫ বৈশাখ ১৪৩১', 'invalid'];
|
|
1934
|
+
* const dates = batchParseDates(mixed);
|
|
1935
|
+
* // First element: parsed Date, second element: current Date (fallback)
|
|
1892
1936
|
* ```
|
|
1893
1937
|
*/
|
|
1894
|
-
declare function
|
|
1938
|
+
declare function batchParseDates(dateStrings: string[]): Date[];
|
|
1895
1939
|
/**
|
|
1896
|
-
* Checks if a date
|
|
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
|
|
1940
|
+
* Checks if a date string can be parsed.
|
|
1902
1941
|
*
|
|
1903
|
-
* @
|
|
1904
|
-
*
|
|
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
|
-
* ```
|
|
1942
|
+
* @param dateString - String to check
|
|
1943
|
+
* @returns true if string can be parsed, false otherwise
|
|
1913
1944
|
*
|
|
1914
1945
|
* @example
|
|
1915
|
-
*
|
|
1946
|
+
* Valid strings:
|
|
1916
1947
|
* ```typescript
|
|
1917
|
-
*
|
|
1918
|
-
*
|
|
1919
|
-
*
|
|
1920
|
-
* new Date(2024, 0, 20)
|
|
1921
|
-
* );
|
|
1922
|
-
* // true
|
|
1948
|
+
* canParseBanglaDate('১৫ বৈশাখ ১৪৩১'); // true
|
|
1949
|
+
* canParseBanglaDate('১৫/০৪/২০২৪'); // true
|
|
1950
|
+
* canParseBanglaDate('15 বৈশাখ 1431'); // true
|
|
1923
1951
|
* ```
|
|
1924
1952
|
*
|
|
1925
1953
|
* @example
|
|
1926
|
-
*
|
|
1954
|
+
* Invalid strings:
|
|
1927
1955
|
* ```typescript
|
|
1928
|
-
*
|
|
1929
|
-
*
|
|
1930
|
-
*
|
|
1931
|
-
* new Date(2024, 0, 20)
|
|
1932
|
-
* );
|
|
1933
|
-
* // false
|
|
1956
|
+
* canParseBanglaDate('invalid'); // false
|
|
1957
|
+
* canParseBanglaDate('2024-01-15'); // false
|
|
1958
|
+
* canParseBanglaDate(''); // false
|
|
1934
1959
|
* ```
|
|
1935
1960
|
*/
|
|
1936
|
-
declare function
|
|
1961
|
+
declare function canParseBanglaDate(dateString: string): boolean;
|
|
1937
1962
|
|
|
1938
1963
|
/**
|
|
1939
1964
|
* Converts a month number (1-12) to Bangla month name.
|
|
1940
1965
|
*
|
|
1941
|
-
* This function maps standard month numbers to
|
|
1942
|
-
* The
|
|
1966
|
+
* This function maps standard month numbers to Bangla calendar month names.
|
|
1967
|
+
* The Bangla calendar has 12 months, each with its traditional name.
|
|
1943
1968
|
*
|
|
1944
1969
|
* **Month Mapping:**
|
|
1945
1970
|
* 1. বৈশাখ (Boishakh)
|
|
@@ -2005,7 +2030,7 @@ declare function toBanglaMonth(monthNumber: number): string;
|
|
|
2005
2030
|
* Converts a Bangla month name to month number (1-12).
|
|
2006
2031
|
*
|
|
2007
2032
|
* This function performs the reverse operation of toBanglaMonth,
|
|
2008
|
-
* converting
|
|
2033
|
+
* converting Bangla month names to their numeric equivalents.
|
|
2009
2034
|
*
|
|
2010
2035
|
* **Valid Month Names:**
|
|
2011
2036
|
* - বৈশাখ → 1
|
|
@@ -2072,44 +2097,18 @@ declare function fromBanglaMonth(monthName: string): number;
|
|
|
2072
2097
|
/**
|
|
2073
2098
|
* Gets the Bangla month name from a Date object.
|
|
2074
2099
|
*
|
|
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.
|
|
2100
|
+
* This function converts the given date to the Bangla calendar and returns
|
|
2101
|
+
* the corresponding Bangla month name.
|
|
2082
2102
|
*
|
|
2083
2103
|
* @param date - Date object
|
|
2084
2104
|
* @returns Bangla month name
|
|
2085
2105
|
*
|
|
2086
2106
|
* @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
2107
|
* Getting month name from specific dates:
|
|
2096
2108
|
* ```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 শ্রাবণ'
|
|
2109
|
+
* getMonthName(new Date(2024, 3, 14)); // 'বৈশাখ' (Pohela Boishakh)
|
|
2110
|
+
* getMonthName(new Date(2024, 0, 15)); // 'পৌষ' (January falls in Poush)
|
|
2111
|
+
* getMonthName(new Date(2024, 6, 15)); // 'শ্রাবণ' (July falls in Srabon)
|
|
2113
2112
|
* ```
|
|
2114
2113
|
*/
|
|
2115
2114
|
declare function getMonthName(date: Date): string;
|
|
@@ -2867,14 +2866,14 @@ declare function getDaysBetween(from: number, to: number): number;
|
|
|
2867
2866
|
/**
|
|
2868
2867
|
* Gets the Bangla season name from a Date object.
|
|
2869
2868
|
*
|
|
2870
|
-
* This function determines the current
|
|
2871
|
-
* It follows the traditional
|
|
2869
|
+
* This function determines the current Bangla season based on the Bangla month of the given date.
|
|
2870
|
+
* It follows the traditional Bangla calendar system which divides the year into six seasons.
|
|
2872
2871
|
*
|
|
2873
|
-
* **
|
|
2872
|
+
* **Bangla Seasons (ঋতু) — 2 months per season:**
|
|
2874
2873
|
* - গ্রীষ্ম (Grisshô - Summer): months 1-2 (বৈশাখ-জ্যৈষ্ঠ)
|
|
2875
|
-
* - বর্ষা (Bôrsha - Monsoon): months 3-
|
|
2876
|
-
* - শরৎ (Shôrôt - Autumn): months 6
|
|
2877
|
-
* - হেমন্ত (Hemonto - Late Autumn):
|
|
2874
|
+
* - বর্ষা (Bôrsha - Monsoon): months 3-4 (আষাঢ়-শ্রাবণ)
|
|
2875
|
+
* - শরৎ (Shôrôt - Autumn): months 5-6 (ভাদ্র-আশ্বিন)
|
|
2876
|
+
* - হেমন্ত (Hemonto - Late Autumn): months 7-8 (কার্তিক-অগ্রহায়ণ)
|
|
2878
2877
|
* - শীত (Sheet - Winter): months 9-10 (পৌষ-মাঘ)
|
|
2879
2878
|
* - বসন্ত (Bôshonto - Spring): months 11-12 (ফাল্গুন-চৈত্র)
|
|
2880
2879
|
*
|
|
@@ -2884,10 +2883,10 @@ declare function getDaysBetween(from: number, to: number): number;
|
|
|
2884
2883
|
* @example
|
|
2885
2884
|
* Basic usage:
|
|
2886
2885
|
* ```typescript
|
|
2887
|
-
* const date1 = new Date('2024-04-15'); //
|
|
2886
|
+
* const date1 = new Date('2024-04-15'); // Bangla month 1 (Boishakh)
|
|
2888
2887
|
* getSeason(date1); // 'গ্রীষ্ম'
|
|
2889
2888
|
*
|
|
2890
|
-
* const date2 = new Date('2024-07-15'); //
|
|
2889
|
+
* const date2 = new Date('2024-07-15'); // Bangla month 4 (Monsoon period)
|
|
2891
2890
|
* getSeason(date2); // 'বর্ষা'
|
|
2892
2891
|
* ```
|
|
2893
2892
|
*
|
|
@@ -2932,20 +2931,20 @@ declare function getDaysBetween(from: number, to: number): number;
|
|
|
2932
2931
|
declare function getSeason(date: Date): string;
|
|
2933
2932
|
|
|
2934
2933
|
/**
|
|
2935
|
-
* Gets the Bangla season name from a
|
|
2934
|
+
* Gets the Bangla season name from a Bangla month number.
|
|
2936
2935
|
*
|
|
2937
|
-
* This function maps
|
|
2938
|
-
* according to the traditional
|
|
2936
|
+
* This function maps Bangla month numbers (1-12) to their corresponding seasons
|
|
2937
|
+
* according to the traditional Bangla calendar system.
|
|
2939
2938
|
*
|
|
2940
|
-
* **Month to Season Mapping:**
|
|
2939
|
+
* **Month to Season Mapping (2 months per season):**
|
|
2941
2940
|
* - Months 1-2 (বৈশাখ-জ্যৈষ্ঠ) → গ্রীষ্ম (Summer)
|
|
2942
|
-
* - Months 3-
|
|
2943
|
-
* - Months 6
|
|
2944
|
-
* -
|
|
2941
|
+
* - Months 3-4 (আষাঢ়-শ্রাবণ) → বর্ষা (Monsoon)
|
|
2942
|
+
* - Months 5-6 (ভাদ্র-আশ্বিন) → শরৎ (Autumn)
|
|
2943
|
+
* - Months 7-8 (কার্তিক-অগ্রহায়ণ) → হেমন্ত (Late Autumn)
|
|
2945
2944
|
* - Months 9-10 (পৌষ-মাঘ) → শীত (Winter)
|
|
2946
2945
|
* - Months 11-12 (ফাল্গুন-চৈত্র) → বসন্ত (Spring)
|
|
2947
2946
|
*
|
|
2948
|
-
* @param monthNumber -
|
|
2947
|
+
* @param monthNumber - Bangla month number (1-12)
|
|
2949
2948
|
* @returns Bangla season name
|
|
2950
2949
|
* @throws {Error} If monthNumber is not between 1 and 12
|
|
2951
2950
|
*
|
|
@@ -2968,13 +2967,13 @@ declare function getSeason(date: Date): string;
|
|
|
2968
2967
|
* // Monsoon months
|
|
2969
2968
|
* getSeasonFromMonth(3); // 'বর্ষা' (Asharh)
|
|
2970
2969
|
* getSeasonFromMonth(4); // 'বর্ষা' (Shrabon)
|
|
2971
|
-
* getSeasonFromMonth(5); // 'বর্ষা' (Bhadro)
|
|
2972
2970
|
*
|
|
2973
2971
|
* // Autumn months
|
|
2972
|
+
* getSeasonFromMonth(5); // 'শরৎ' (Bhadro)
|
|
2974
2973
|
* getSeasonFromMonth(6); // 'শরৎ' (Ashwin)
|
|
2975
|
-
* getSeasonFromMonth(7); // 'শরৎ' (Kartik)
|
|
2976
2974
|
*
|
|
2977
|
-
* // Late Autumn
|
|
2975
|
+
* // Late Autumn months
|
|
2976
|
+
* getSeasonFromMonth(7); // 'হেমন্ত' (Kartik)
|
|
2978
2977
|
* getSeasonFromMonth(8); // 'হেমন্ত' (Ogrohayon)
|
|
2979
2978
|
*
|
|
2980
2979
|
* // Winter months
|
|
@@ -3100,13 +3099,13 @@ declare function getAllSeasons(): string[];
|
|
|
3100
3099
|
* Gets the month numbers for a given season.
|
|
3101
3100
|
*
|
|
3102
3101
|
* This function returns an array of month numbers (1-12) that belong to
|
|
3103
|
-
* the specified season in the
|
|
3102
|
+
* the specified season in the Bangla calendar system.
|
|
3104
3103
|
*
|
|
3105
|
-
* **Season to Month Mapping:**
|
|
3104
|
+
* **Season to Month Mapping (2 months per season):**
|
|
3106
3105
|
* - গ্রীষ্ম (Summer): months 1-2 (বৈশাখ-জ্যৈষ্ঠ)
|
|
3107
|
-
* - বর্ষা (Monsoon): months 3-
|
|
3108
|
-
* - শরৎ (Autumn): months 6
|
|
3109
|
-
* - হেমন্ত (Late Autumn):
|
|
3106
|
+
* - বর্ষা (Monsoon): months 3-4 (আষাঢ়-শ্রাবণ)
|
|
3107
|
+
* - শরৎ (Autumn): months 5-6 (ভাদ্র-আশ্বিন)
|
|
3108
|
+
* - হেমন্ত (Late Autumn): months 7-8 (কার্তিক-অগ্রহায়ণ)
|
|
3110
3109
|
* - শীত (Winter): months 9-10 (পৌষ-মাঘ)
|
|
3111
3110
|
* - বসন্ত (Spring): months 11-12 (ফাল্গুন-চৈত্র)
|
|
3112
3111
|
*
|
|
@@ -3117,9 +3116,9 @@ declare function getAllSeasons(): string[];
|
|
|
3117
3116
|
* @example
|
|
3118
3117
|
* ```typescript
|
|
3119
3118
|
* getSeasonMonths('গ্রীষ্ম'); // [1, 2]
|
|
3120
|
-
* getSeasonMonths('বর্ষা'); // [3, 4
|
|
3121
|
-
* getSeasonMonths('শরৎ'); // [
|
|
3122
|
-
* getSeasonMonths('হেমন্ত'); // [8]
|
|
3119
|
+
* getSeasonMonths('বর্ষা'); // [3, 4]
|
|
3120
|
+
* getSeasonMonths('শরৎ'); // [5, 6]
|
|
3121
|
+
* getSeasonMonths('হেমন্ত'); // [7, 8]
|
|
3123
3122
|
* getSeasonMonths('শীত'); // [9, 10]
|
|
3124
3123
|
* getSeasonMonths('বসন্ত'); // [11, 12]
|
|
3125
3124
|
* ```
|
|
@@ -3494,6 +3493,8 @@ declare function safeToOrdinal(number: number, fallback?: string): string;
|
|
|
3494
3493
|
* This function processes multiple numbers at once, converting each to
|
|
3495
3494
|
* its ordinal form. Invalid numbers are skipped.
|
|
3496
3495
|
*
|
|
3496
|
+
* Uses core validating batch processor to eliminate duplication.
|
|
3497
|
+
*
|
|
3497
3498
|
* @param numbers - Array of numbers to convert
|
|
3498
3499
|
* @returns Array of ordinal strings (invalid numbers are skipped)
|
|
3499
3500
|
*
|
|
@@ -3509,7 +3510,7 @@ declare function safeToOrdinal(number: number, fallback?: string): string;
|
|
|
3509
3510
|
* // ['দশম', 'বিংশ', 'ত্রিংশ']
|
|
3510
3511
|
* ```
|
|
3511
3512
|
*/
|
|
3512
|
-
declare
|
|
3513
|
+
declare const batchToOrdinal: (inputs: number[]) => string[];
|
|
3513
3514
|
/**
|
|
3514
3515
|
* Parses and converts input to ordinal in one step.
|
|
3515
3516
|
*
|
|
@@ -3734,10 +3735,12 @@ declare function createOrdinalList<T>(items: T[], startFrom?: number): Array<{
|
|
|
3734
3735
|
* It can accept either a Date object or a time string in HH:mm or HH:mm:ss format.
|
|
3735
3736
|
*
|
|
3736
3737
|
* **12-Hour Format Periods:**
|
|
3737
|
-
* - রাত (night): 12:00 AM -
|
|
3738
|
-
* - সকাল (morning):
|
|
3739
|
-
* - দুপুর (noon): 12:00 PM -
|
|
3740
|
-
* - বিকাল (afternoon
|
|
3738
|
+
* - রাত (night): 12:00 AM - 5:59 AM (hours 0-5)
|
|
3739
|
+
* - সকাল (morning): 6:00 AM - 11:59 AM (hours 6-11)
|
|
3740
|
+
* - দুপুর (noon/afternoon): 12:00 PM - 2:59 PM (hours 12-14)
|
|
3741
|
+
* - বিকাল (late afternoon): 3:00 PM - 5:59 PM (hours 15-17)
|
|
3742
|
+
* - সন্ধ্যা (evening): 6:00 PM - 7:59 PM (hours 18-19)
|
|
3743
|
+
* - রাত (night): 8:00 PM - 11:59 PM (hours 20-23)
|
|
3741
3744
|
*
|
|
3742
3745
|
* @param date - Date object or time string (HH:mm or HH:mm:ss format)
|
|
3743
3746
|
* @param options - Formatting options
|
|
@@ -3755,47 +3758,15 @@ declare function createOrdinalList<T>(items: T[], startFrom?: number): Array<{
|
|
|
3755
3758
|
* ```
|
|
3756
3759
|
*
|
|
3757
3760
|
* @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
3761
|
* 12-hour format with Bangla periods:
|
|
3766
3762
|
* ```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: ১০:৩০ সকাল"
|
|
3763
|
+
* formatTime('09:30', { use12Hour: true }); // 'সকাল ০৯:৩০'
|
|
3764
|
+
* formatTime('14:30', { use12Hour: true }); // 'দুপুর ০২:৩০'
|
|
3765
|
+
* formatTime('16:00', { use12Hour: true }); // 'বিকাল ০৪:০০'
|
|
3766
|
+
* formatTime('18:30', { use12Hour: true }); // 'সন্ধ্যা ০৬:৩০'
|
|
3767
|
+
* formatTime('22:00', { use12Hour: true }); // 'রাত ১০:০০'
|
|
3768
|
+
* formatTime('04:30', { use12Hour: true }); // 'রাত ০৪:৩০'
|
|
3769
|
+
* formatTime('00:00', { use12Hour: true }); // 'রাত ১২:০০'
|
|
3799
3770
|
* ```
|
|
3800
3771
|
*/
|
|
3801
3772
|
declare function formatTime(date: Date | string, options?: {
|
|
@@ -3967,6 +3938,59 @@ declare function relativeTime(date: Date, baseDate?: Date): string;
|
|
|
3967
3938
|
*/
|
|
3968
3939
|
declare function relativeDay(date: Date, baseDate?: Date): string;
|
|
3969
3940
|
|
|
3941
|
+
/**
|
|
3942
|
+
* Time conversion utilities
|
|
3943
|
+
* Functions for parsing and converting time strings
|
|
3944
|
+
*/
|
|
3945
|
+
/**
|
|
3946
|
+
* Parses a time string and returns hours, minutes, and seconds.
|
|
3947
|
+
*
|
|
3948
|
+
* @param timeString - Time string in HH:mm or HH:mm:ss format
|
|
3949
|
+
* @returns Object with hours, minutes, and seconds
|
|
3950
|
+
* @throws Error if the time string is invalid
|
|
3951
|
+
*
|
|
3952
|
+
* @example
|
|
3953
|
+
* ```typescript
|
|
3954
|
+
* parseTime('14:30'); // { hours: 14, minutes: 30, seconds: 0 }
|
|
3955
|
+
* parseTime('09:15:45'); // { hours: 9, minutes: 15, seconds: 45 }
|
|
3956
|
+
* parseTime('23:59:59'); // { hours: 23, minutes: 59, seconds: 59 }
|
|
3957
|
+
* ```
|
|
3958
|
+
*/
|
|
3959
|
+
declare function parseTime(timeString: string): {
|
|
3960
|
+
hours: number;
|
|
3961
|
+
minutes: number;
|
|
3962
|
+
seconds: number;
|
|
3963
|
+
};
|
|
3964
|
+
/**
|
|
3965
|
+
* Converts a time string to total seconds since midnight.
|
|
3966
|
+
*
|
|
3967
|
+
* @param timeString - Time string in HH:mm or HH:mm:ss format
|
|
3968
|
+
* @returns Total seconds since midnight
|
|
3969
|
+
*
|
|
3970
|
+
* @example
|
|
3971
|
+
* ```typescript
|
|
3972
|
+
* timeToSeconds('01:00'); // 3600
|
|
3973
|
+
* timeToSeconds('01:30'); // 5400
|
|
3974
|
+
* timeToSeconds('12:00:00'); // 43200
|
|
3975
|
+
* ```
|
|
3976
|
+
*/
|
|
3977
|
+
declare function timeToSeconds(timeString: string): number;
|
|
3978
|
+
/**
|
|
3979
|
+
* Converts seconds since midnight to a time string.
|
|
3980
|
+
*
|
|
3981
|
+
* @param totalSeconds - Total seconds since midnight
|
|
3982
|
+
* @returns Time string in HH:mm:ss format
|
|
3983
|
+
* @throws Error if seconds is out of valid range
|
|
3984
|
+
*
|
|
3985
|
+
* @example
|
|
3986
|
+
* ```typescript
|
|
3987
|
+
* secondsToTime(3600); // '01:00:00'
|
|
3988
|
+
* secondsToTime(5400); // '01:30:00'
|
|
3989
|
+
* secondsToTime(43200); // '12:00:00'
|
|
3990
|
+
* ```
|
|
3991
|
+
*/
|
|
3992
|
+
declare function secondsToTime(totalSeconds: number): string;
|
|
3993
|
+
|
|
3970
3994
|
/**
|
|
3971
3995
|
* Validates if a string represents a valid time format.
|
|
3972
3996
|
*
|
|
@@ -4014,74 +4038,30 @@ declare function isValidTimeInput(value: any): boolean;
|
|
|
4014
4038
|
* @param timeString - The time string to check
|
|
4015
4039
|
* @returns true if the time string includes seconds, false otherwise
|
|
4016
4040
|
*
|
|
4017
|
-
* @example
|
|
4018
|
-
* ```typescript
|
|
4019
|
-
* hasSeconds('14:30:45'); // true
|
|
4020
|
-
* hasSeconds('14:30'); // false
|
|
4021
|
-
* ```
|
|
4022
|
-
*/
|
|
4023
|
-
declare function hasSeconds(timeString: string): boolean;
|
|
4024
|
-
/**
|
|
4025
|
-
* Sanitizes time string input by trimming whitespace.
|
|
4026
|
-
*
|
|
4027
|
-
* @param input - The time string to sanitize
|
|
4028
|
-
* @returns Sanitized time string
|
|
4029
|
-
*
|
|
4030
|
-
* @example
|
|
4031
|
-
* ```typescript
|
|
4032
|
-
* sanitizeTimeInput(' 14:30 '); // '14:30'
|
|
4033
|
-
* sanitizeTimeInput('09:15:45 '); // '09:15:45'
|
|
4034
|
-
* ```
|
|
4035
|
-
*/
|
|
4036
|
-
declare function sanitizeTimeInput(input: string): string;
|
|
4037
|
-
|
|
4038
|
-
/**
|
|
4039
|
-
* Parses a time string and returns hours, minutes, and seconds.
|
|
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
|
|
4041
|
+
* @example
|
|
4042
|
+
* ```typescript
|
|
4043
|
+
* hasSeconds('14:30:45'); // true
|
|
4044
|
+
* hasSeconds('14:30'); // false
|
|
4068
4045
|
* ```
|
|
4069
4046
|
*/
|
|
4070
|
-
declare function
|
|
4047
|
+
declare function hasSeconds(timeString: string): boolean;
|
|
4071
4048
|
/**
|
|
4072
|
-
*
|
|
4049
|
+
* Sanitizes time string input by trimming whitespace.
|
|
4073
4050
|
*
|
|
4074
|
-
* @param
|
|
4075
|
-
* @returns
|
|
4051
|
+
* @param input - The time string to sanitize
|
|
4052
|
+
* @returns Sanitized time string
|
|
4076
4053
|
*
|
|
4077
4054
|
* @example
|
|
4078
4055
|
* ```typescript
|
|
4079
|
-
*
|
|
4080
|
-
*
|
|
4081
|
-
* secondsToTime(43200); // '12:00:00'
|
|
4056
|
+
* sanitizeTimeInput(' 14:30 '); // '14:30'
|
|
4057
|
+
* sanitizeTimeInput('09:15:45 '); // '09:15:45'
|
|
4082
4058
|
* ```
|
|
4083
4059
|
*/
|
|
4084
|
-
declare function
|
|
4060
|
+
declare function sanitizeTimeInput(input: string): string;
|
|
4061
|
+
|
|
4062
|
+
/**
|
|
4063
|
+
* Time comparison operations
|
|
4064
|
+
*/
|
|
4085
4065
|
/**
|
|
4086
4066
|
* Compares two time strings and returns -1, 0, or 1.
|
|
4087
4067
|
*
|
|
@@ -4098,21 +4078,28 @@ declare function secondsToTime(totalSeconds: number): string;
|
|
|
4098
4078
|
*/
|
|
4099
4079
|
declare function compareTimes(time1: string, time2: string): number;
|
|
4100
4080
|
/**
|
|
4101
|
-
* Checks if
|
|
4081
|
+
* Checks if two dates are on the same day.
|
|
4102
4082
|
*
|
|
4103
|
-
* @param
|
|
4104
|
-
* @param
|
|
4105
|
-
* @
|
|
4106
|
-
* @returns true if time is within range, false otherwise
|
|
4083
|
+
* @param date1 - First date
|
|
4084
|
+
* @param date2 - Second date
|
|
4085
|
+
* @returns true if dates are on the same day, false otherwise
|
|
4107
4086
|
*
|
|
4108
4087
|
* @example
|
|
4109
4088
|
* ```typescript
|
|
4110
|
-
*
|
|
4111
|
-
*
|
|
4112
|
-
*
|
|
4089
|
+
* const date1 = new Date(2024, 0, 15, 10, 30);
|
|
4090
|
+
* const date2 = new Date(2024, 0, 15, 14, 45);
|
|
4091
|
+
* isSameDay(date1, date2); // true
|
|
4092
|
+
*
|
|
4093
|
+
* const date3 = new Date(2024, 0, 16, 10, 30);
|
|
4094
|
+
* isSameDay(date1, date3); // false
|
|
4113
4095
|
* ```
|
|
4114
4096
|
*/
|
|
4115
|
-
declare function
|
|
4097
|
+
declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
4098
|
+
|
|
4099
|
+
/**
|
|
4100
|
+
* Time calculation operations
|
|
4101
|
+
* Functions for time arithmetic and differences
|
|
4102
|
+
*/
|
|
4116
4103
|
/**
|
|
4117
4104
|
* Adds a duration (in minutes) to a time string.
|
|
4118
4105
|
*
|
|
@@ -4143,6 +4130,31 @@ declare function addMinutesToTime(timeString: string, minutes: number): string;
|
|
|
4143
4130
|
* ```
|
|
4144
4131
|
*/
|
|
4145
4132
|
declare function timeDifferenceMinutes(time1: string, time2: string): number;
|
|
4133
|
+
|
|
4134
|
+
/**
|
|
4135
|
+
* Time range checking operations
|
|
4136
|
+
*/
|
|
4137
|
+
/**
|
|
4138
|
+
* Checks if a time string falls within a given time range.
|
|
4139
|
+
*
|
|
4140
|
+
* @param time - Time to check
|
|
4141
|
+
* @param startTime - Start of range (inclusive)
|
|
4142
|
+
* @param endTime - End of range (inclusive)
|
|
4143
|
+
* @returns true if time is within range, false otherwise
|
|
4144
|
+
*
|
|
4145
|
+
* @example
|
|
4146
|
+
* ```typescript
|
|
4147
|
+
* isTimeInRange('10:00', '09:00', '11:00'); // true
|
|
4148
|
+
* isTimeInRange('08:00', '09:00', '11:00'); // false
|
|
4149
|
+
* isTimeInRange('09:00', '09:00', '11:00'); // true (inclusive)
|
|
4150
|
+
* ```
|
|
4151
|
+
*/
|
|
4152
|
+
declare function isTimeInRange(time: string, startTime: string, endTime: string): boolean;
|
|
4153
|
+
|
|
4154
|
+
/**
|
|
4155
|
+
* Time utility functions
|
|
4156
|
+
* Domain-specific utilities
|
|
4157
|
+
*/
|
|
4146
4158
|
/**
|
|
4147
4159
|
* Safely formats time with a fallback value.
|
|
4148
4160
|
*
|
|
@@ -4217,33 +4229,112 @@ declare function getCurrentTimeBangla(options?: {
|
|
|
4217
4229
|
includeSeconds?: boolean;
|
|
4218
4230
|
use12Hour?: boolean;
|
|
4219
4231
|
}): string;
|
|
4232
|
+
|
|
4220
4233
|
/**
|
|
4221
|
-
*
|
|
4234
|
+
* Formats a Gregorian date as a Bangla calendar date string with Bangla text.
|
|
4222
4235
|
*
|
|
4223
|
-
*
|
|
4224
|
-
*
|
|
4225
|
-
*
|
|
4236
|
+
* This function converts a Gregorian date to the Bangla calendar and formats it
|
|
4237
|
+
* with Bangla digits and month names. It's ideal for displaying dates in
|
|
4238
|
+
* Bangla cultural contexts.
|
|
4239
|
+
*
|
|
4240
|
+
* **Output Format:**
|
|
4241
|
+
* - Default: "day month year" (e.g., "১৫ বৈশাখ ১৪৩১")
|
|
4242
|
+
* - With weekday: "weekday day month year" (e.g., "রবিবার ১৫ বৈশাখ ১৪৩১")
|
|
4243
|
+
* - Without year: "day month" (e.g., "১৫ বৈশাখ")
|
|
4244
|
+
*
|
|
4245
|
+
* **Weekday Names:**
|
|
4246
|
+
* - রবিবার (Robibar) - Sunday
|
|
4247
|
+
* - সোমবার (Sombar) - Monday
|
|
4248
|
+
* - মঙ্গলবার (Mongolbar) - Tuesday
|
|
4249
|
+
* - বুধবার (Budhbar) - Wednesday
|
|
4250
|
+
* - বৃহস্পতিবার (Brihaspotibar) - Thursday
|
|
4251
|
+
* - শুক্রবার (Shukrobar) - Friday
|
|
4252
|
+
* - শনিবার (Shonibar) - Saturday
|
|
4253
|
+
*
|
|
4254
|
+
* @param date - Gregorian Date object to format
|
|
4255
|
+
* @param options - Formatting options
|
|
4256
|
+
* @param options.includeYear - Include Bangla year in output (default: true)
|
|
4257
|
+
* @param options.includeWeekday - Include weekday name in output (default: false)
|
|
4258
|
+
* @returns Formatted Bangla date string
|
|
4226
4259
|
*
|
|
4227
4260
|
* @example
|
|
4261
|
+
* Basic formatting (with year):
|
|
4228
4262
|
* ```typescript
|
|
4229
|
-
*
|
|
4230
|
-
*
|
|
4231
|
-
*
|
|
4263
|
+
* getBanglaDate(new Date(2024, 3, 14));
|
|
4264
|
+
* // "১ বৈশাখ ১৪৩১" (Pohela Boishakh 1431)
|
|
4265
|
+
* ```
|
|
4232
4266
|
*
|
|
4233
|
-
*
|
|
4234
|
-
*
|
|
4267
|
+
* @example
|
|
4268
|
+
* Without year:
|
|
4269
|
+
* ```typescript
|
|
4270
|
+
* getBanglaDate(new Date(2024, 3, 14), { includeYear: false });
|
|
4271
|
+
* // "১ বৈশাখ"
|
|
4272
|
+
* ```
|
|
4273
|
+
*
|
|
4274
|
+
* @example
|
|
4275
|
+
* With weekday:
|
|
4276
|
+
* ```typescript
|
|
4277
|
+
* getBanglaDate(new Date(2024, 3, 14), { includeWeekday: true });
|
|
4278
|
+
* // "রবিবার ১ বৈশাখ ১৪৩১" (if April 14, 2024 is Sunday)
|
|
4279
|
+
* ```
|
|
4280
|
+
*
|
|
4281
|
+
* @example
|
|
4282
|
+
* With weekday, without year:
|
|
4283
|
+
* ```typescript
|
|
4284
|
+
* getBanglaDate(
|
|
4285
|
+
* new Date(2024, 3, 14),
|
|
4286
|
+
* { includeWeekday: true, includeYear: false }
|
|
4287
|
+
* );
|
|
4288
|
+
* // "রবিবার ১ বৈশাখ"
|
|
4289
|
+
* ```
|
|
4290
|
+
*
|
|
4291
|
+
* @example
|
|
4292
|
+
* Display current date in Bangla:
|
|
4293
|
+
* ```typescript
|
|
4294
|
+
* const today = new Date();
|
|
4295
|
+
* const bengaliToday = getBanglaDate(today, { includeWeekday: true });
|
|
4296
|
+
* console.log(`আজ: ${bengaliToday}`);
|
|
4297
|
+
* // "আজ: মঙ্গলবার ২৪ পৌষ ১৪৩১" (example)
|
|
4298
|
+
* ```
|
|
4299
|
+
*
|
|
4300
|
+
* @example
|
|
4301
|
+
* Birthday display:
|
|
4302
|
+
* ```typescript
|
|
4303
|
+
* const birthday = new Date(2024, 6, 15);
|
|
4304
|
+
* const bengaliBirthday = getBanglaDate(birthday);
|
|
4305
|
+
* console.log(`জন্মদিন: ${bengaliBirthday}`);
|
|
4306
|
+
* // "জন্মদিন: ১ শ্রাবণ ১৪৩১" (example)
|
|
4307
|
+
* ```
|
|
4308
|
+
*
|
|
4309
|
+
* @example
|
|
4310
|
+
* Event calendar:
|
|
4311
|
+
* ```typescript
|
|
4312
|
+
* const events = [
|
|
4313
|
+
* new Date(2024, 3, 14),
|
|
4314
|
+
* new Date(2024, 11, 16),
|
|
4315
|
+
* new Date(2025, 1, 21)
|
|
4316
|
+
* ];
|
|
4317
|
+
* events.forEach(event => {
|
|
4318
|
+
* console.log(getBanglaDate(event, { includeWeekday: true }));
|
|
4319
|
+
* });
|
|
4320
|
+
* // "রবিবার ১ বৈশাখ ১৪৩১"
|
|
4321
|
+
* // "সোমবার ২ পৌষ ১৪৩১"
|
|
4322
|
+
* // "শুক্রবার ৯ ফাল্গুন ১৪৩১"
|
|
4235
4323
|
* ```
|
|
4236
4324
|
*/
|
|
4237
|
-
declare function
|
|
4325
|
+
declare function getBanglaDate(date: Date, options?: {
|
|
4326
|
+
includeYear?: boolean;
|
|
4327
|
+
includeWeekday?: boolean;
|
|
4328
|
+
}): string;
|
|
4238
4329
|
|
|
4239
4330
|
/**
|
|
4240
|
-
* Converts a Gregorian date to
|
|
4331
|
+
* Converts a Gregorian date to Bangla calendar date.
|
|
4241
4332
|
*
|
|
4242
4333
|
* This function performs accurate conversion from the Gregorian calendar
|
|
4243
|
-
* to the
|
|
4244
|
-
* The
|
|
4334
|
+
* to the Bangla calendar (also known as Bangla calendar or Bangla calendar).
|
|
4335
|
+
* The Bangla calendar year is typically 593-594 years behind the Gregorian calendar.
|
|
4245
4336
|
*
|
|
4246
|
-
* **
|
|
4337
|
+
* **Bangla Calendar System:**
|
|
4247
4338
|
* - New Year (Pohela Boishakh): April 14 (Gregorian)
|
|
4248
4339
|
* - 12 months with varying lengths (31, 30, or 29/30 days)
|
|
4249
4340
|
* - Leap year adjustment in Falgun (month 11)
|
|
@@ -4263,29 +4354,29 @@ declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
|
4263
4354
|
* 12. চৈত্র (Chaitra) - 30 days
|
|
4264
4355
|
*
|
|
4265
4356
|
* @param date - Gregorian Date object to convert
|
|
4266
|
-
* @returns
|
|
4357
|
+
* @returns Bangla date object with year, month (1-12), and day properties
|
|
4267
4358
|
*
|
|
4268
4359
|
* @example
|
|
4269
|
-
*
|
|
4360
|
+
* Bangla New Year (Pohela Boishakh):
|
|
4270
4361
|
* ```typescript
|
|
4271
|
-
*
|
|
4362
|
+
* toBangla(new Date(2024, 3, 14)); // April 14, 2024
|
|
4272
4363
|
* // { year: 1431, month: 1, day: 1 }
|
|
4273
4364
|
* ```
|
|
4274
4365
|
*
|
|
4275
4366
|
* @example
|
|
4276
4367
|
* Mid-year dates:
|
|
4277
4368
|
* ```typescript
|
|
4278
|
-
*
|
|
4369
|
+
* toBangla(new Date(2024, 6, 15)); // July 15, 2024
|
|
4279
4370
|
* // { year: 1431, month: 4, day: 1 } (approx - Srabon)
|
|
4280
4371
|
*
|
|
4281
|
-
*
|
|
4372
|
+
* toBangla(new Date(2024, 11, 31)); // December 31, 2024
|
|
4282
4373
|
* // { year: 1431, month: 9, day: 17 } (approx - Poush)
|
|
4283
4374
|
* ```
|
|
4284
4375
|
*
|
|
4285
4376
|
* @example
|
|
4286
|
-
* Before
|
|
4377
|
+
* Before Bangla New Year (same Gregorian year):
|
|
4287
4378
|
* ```typescript
|
|
4288
|
-
*
|
|
4379
|
+
* toBangla(new Date(2024, 0, 15)); // January 15, 2024
|
|
4289
4380
|
* // { year: 1430, month: 10, day: 2 } (approx - Magh)
|
|
4290
4381
|
* ```
|
|
4291
4382
|
*
|
|
@@ -4293,7 +4384,7 @@ declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
|
4293
4384
|
* Practical usage:
|
|
4294
4385
|
* ```typescript
|
|
4295
4386
|
* const today = new Date();
|
|
4296
|
-
* const bengaliDate =
|
|
4387
|
+
* const bengaliDate = toBangla(today);
|
|
4297
4388
|
* console.log(`${bengaliDate.day}/${bengaliDate.month}/${bengaliDate.year}`);
|
|
4298
4389
|
* // "24/9/1431" (example)
|
|
4299
4390
|
* ```
|
|
@@ -4302,57 +4393,57 @@ declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
|
4302
4393
|
* Leap year handling:
|
|
4303
4394
|
* ```typescript
|
|
4304
4395
|
* // 2020 is a leap year, affecting Falgun (month 11)
|
|
4305
|
-
*
|
|
4306
|
-
* // Month 11 (Falgun) will have 30 days in
|
|
4396
|
+
* toBangla(new Date(2021, 2, 14)); // March 14, 2021
|
|
4397
|
+
* // Month 11 (Falgun) will have 30 days in Bangla year 1427
|
|
4307
4398
|
* ```
|
|
4308
4399
|
*/
|
|
4309
|
-
declare function
|
|
4400
|
+
declare function toBanglaCalendar(date: Date): {
|
|
4310
4401
|
year: number;
|
|
4311
4402
|
month: number;
|
|
4312
4403
|
day: number;
|
|
4313
4404
|
};
|
|
4314
4405
|
|
|
4315
4406
|
/**
|
|
4316
|
-
* Converts a
|
|
4407
|
+
* Converts a Bangla calendar date to Gregorian date.
|
|
4317
4408
|
*
|
|
4318
|
-
* This function performs the reverse operation of
|
|
4319
|
-
* from the
|
|
4409
|
+
* This function performs the reverse operation of toBangla, converting
|
|
4410
|
+
* from the Bangla calendar to the Gregorian calendar. It accurately
|
|
4320
4411
|
* handles month boundaries, year transitions, and leap years.
|
|
4321
4412
|
*
|
|
4322
4413
|
* **Input Format:**
|
|
4323
|
-
* - year:
|
|
4324
|
-
* - month:
|
|
4414
|
+
* - year: Bangla year (positive integer)
|
|
4415
|
+
* - month: Bangla month (1-12)
|
|
4325
4416
|
* - day: Day of month (1-31, depending on month)
|
|
4326
4417
|
*
|
|
4327
|
-
* **
|
|
4328
|
-
* -
|
|
4329
|
-
* - 1 Boishakh (
|
|
4418
|
+
* **Bangla to Gregorian Mapping:**
|
|
4419
|
+
* - Bangla year + 593 or 594 = Gregorian year (depends on date)
|
|
4420
|
+
* - 1 Boishakh (Bangla New Year) = April 14 (Gregorian)
|
|
4330
4421
|
*
|
|
4331
|
-
* @param bengaliDate -
|
|
4422
|
+
* @param bengaliDate - Bangla date object with year, month, and day properties
|
|
4332
4423
|
* @returns Gregorian Date object
|
|
4333
|
-
* @throws {Error} If the
|
|
4424
|
+
* @throws {Error} If the Bangla date is invalid
|
|
4334
4425
|
*
|
|
4335
4426
|
* @example
|
|
4336
|
-
*
|
|
4427
|
+
* Bangla New Year to Gregorian:
|
|
4337
4428
|
* ```typescript
|
|
4338
|
-
*
|
|
4429
|
+
* fromBangla({ year: 1431, month: 1, day: 1 });
|
|
4339
4430
|
* // Date object for April 14, 2024 (Pohela Boishakh)
|
|
4340
4431
|
* ```
|
|
4341
4432
|
*
|
|
4342
4433
|
* @example
|
|
4343
4434
|
* Mid-year conversions:
|
|
4344
4435
|
* ```typescript
|
|
4345
|
-
*
|
|
4436
|
+
* fromBangla({ year: 1431, month: 6, day: 15 });
|
|
4346
4437
|
* // Date object for October 1, 2024 (approx - Ashwin)
|
|
4347
4438
|
*
|
|
4348
|
-
*
|
|
4439
|
+
* fromBangla({ year: 1431, month: 9, day: 1 });
|
|
4349
4440
|
* // Date object for December 16, 2024 (approx - Poush)
|
|
4350
4441
|
* ```
|
|
4351
4442
|
*
|
|
4352
4443
|
* @example
|
|
4353
4444
|
* End of year:
|
|
4354
4445
|
* ```typescript
|
|
4355
|
-
*
|
|
4446
|
+
* fromBangla({ year: 1431, month: 12, day: 30 });
|
|
4356
4447
|
* // Date object for April 13, 2025 (last day before new year)
|
|
4357
4448
|
* ```
|
|
4358
4449
|
*
|
|
@@ -4360,7 +4451,7 @@ declare function toBengali(date: Date): {
|
|
|
4360
4451
|
* Practical usage (event scheduling):
|
|
4361
4452
|
* ```typescript
|
|
4362
4453
|
* const bengaliEvent = { year: 1431, month: 1, day: 1 };
|
|
4363
|
-
* const gregorianDate =
|
|
4454
|
+
* const gregorianDate = fromBangla(bengaliEvent);
|
|
4364
4455
|
* console.log(`Event date: ${gregorianDate.toLocaleDateString()}`);
|
|
4365
4456
|
* // "Event date: 4/14/2024"
|
|
4366
4457
|
* ```
|
|
@@ -4369,7 +4460,7 @@ declare function toBengali(date: Date): {
|
|
|
4369
4460
|
* Leap year handling:
|
|
4370
4461
|
* ```typescript
|
|
4371
4462
|
* // Falgun 30 in a leap year
|
|
4372
|
-
*
|
|
4463
|
+
* fromBangla({ year: 1427, month: 11, day: 30 });
|
|
4373
4464
|
* // Valid conversion (2020 is a leap year)
|
|
4374
4465
|
*
|
|
4375
4466
|
* // Falgun 30 in a non-leap year would be invalid
|
|
@@ -4380,291 +4471,194 @@ declare function toBengali(date: Date): {
|
|
|
4380
4471
|
* Round-trip conversion:
|
|
4381
4472
|
* ```typescript
|
|
4382
4473
|
* const original = new Date(2024, 6, 15);
|
|
4383
|
-
* const bengali =
|
|
4384
|
-
* const converted =
|
|
4474
|
+
* const bengali = toBangla(original);
|
|
4475
|
+
* const converted = fromBangla(bengali);
|
|
4385
4476
|
* // converted should equal original date
|
|
4386
4477
|
* ```
|
|
4387
4478
|
*/
|
|
4388
|
-
declare function
|
|
4479
|
+
declare function fromBanglaCalendar(b: {
|
|
4389
4480
|
year: number;
|
|
4390
4481
|
month: number;
|
|
4391
4482
|
day: number;
|
|
4392
4483
|
}): Date;
|
|
4393
4484
|
|
|
4394
4485
|
/**
|
|
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.
|
|
4486
|
+
* Validation utilities for Bangla calendar operations.
|
|
4493
4487
|
*
|
|
4494
|
-
* This module provides non-throwing validation functions for
|
|
4488
|
+
* This module provides non-throwing validation functions for Bangla calendar dates.
|
|
4495
4489
|
* All validators return boolean values or null for sanitization functions.
|
|
4496
4490
|
*
|
|
4497
4491
|
* @module calendar/validate
|
|
4498
4492
|
*/
|
|
4499
4493
|
/**
|
|
4500
|
-
* Checks if a year is a valid
|
|
4494
|
+
* Checks if a year is a valid Bangla calendar year.
|
|
4501
4495
|
*
|
|
4502
|
-
* Valid
|
|
4496
|
+
* Valid Bangla years are positive integers. The Bangla calendar
|
|
4503
4497
|
* is typically 593-594 years behind the Gregorian calendar.
|
|
4504
4498
|
*
|
|
4505
4499
|
* @param year - Year to validate
|
|
4506
|
-
* @returns true if year is a valid
|
|
4500
|
+
* @returns true if year is a valid Bangla year, false otherwise
|
|
4507
4501
|
*
|
|
4508
4502
|
* @example
|
|
4509
4503
|
* Valid years:
|
|
4510
4504
|
* ```typescript
|
|
4511
|
-
*
|
|
4512
|
-
*
|
|
4513
|
-
*
|
|
4505
|
+
* isValidBanglaYear(1431); // true
|
|
4506
|
+
* isValidBanglaYear(1400); // true
|
|
4507
|
+
* isValidBanglaYear(1); // true
|
|
4514
4508
|
* ```
|
|
4515
4509
|
*
|
|
4516
4510
|
* @example
|
|
4517
4511
|
* Invalid years:
|
|
4518
4512
|
* ```typescript
|
|
4519
|
-
*
|
|
4520
|
-
*
|
|
4521
|
-
*
|
|
4522
|
-
*
|
|
4513
|
+
* isValidBanglaYear(0); // false
|
|
4514
|
+
* isValidBanglaYear(-10); // false
|
|
4515
|
+
* isValidBanglaYear(1431.5); // false
|
|
4516
|
+
* isValidBanglaYear('1431' as any); // false
|
|
4523
4517
|
* ```
|
|
4524
4518
|
*/
|
|
4525
|
-
declare function
|
|
4519
|
+
declare function isValidBanglaYear(year: number): boolean;
|
|
4526
4520
|
/**
|
|
4527
|
-
* Checks if a month is a valid
|
|
4521
|
+
* Checks if a month number is a valid Bangla calendar month (1-12).
|
|
4528
4522
|
*
|
|
4529
|
-
*
|
|
4523
|
+
* Bangla calendar has 12 months:
|
|
4530
4524
|
* 1=বৈশাখ, 2=জ্যৈষ্ঠ, 3=আষাঢ়, 4=শ্রাবণ, 5=ভাদ্র, 6=আশ্বিন,
|
|
4531
4525
|
* 7=কার্তিক, 8=অগ্রহায়ণ, 9=পৌষ, 10=মাঘ, 11=ফাল্গুন, 12=চৈত্র
|
|
4532
4526
|
*
|
|
4533
|
-
* @param month - Month to validate (1-12)
|
|
4527
|
+
* @param month - Month number to validate (1-12)
|
|
4534
4528
|
* @returns true if month is valid, false otherwise
|
|
4535
4529
|
*
|
|
4536
4530
|
* @example
|
|
4537
4531
|
* Valid months:
|
|
4538
4532
|
* ```typescript
|
|
4539
|
-
*
|
|
4540
|
-
*
|
|
4541
|
-
*
|
|
4533
|
+
* isValidBanglaMonthNumber(1); // true (Boishakh)
|
|
4534
|
+
* isValidBanglaMonthNumber(6); // true (Ashwin)
|
|
4535
|
+
* isValidBanglaMonthNumber(12); // true (Chaitra)
|
|
4542
4536
|
* ```
|
|
4543
4537
|
*
|
|
4544
4538
|
* @example
|
|
4545
4539
|
* Invalid months:
|
|
4546
4540
|
* ```typescript
|
|
4547
|
-
*
|
|
4548
|
-
*
|
|
4549
|
-
*
|
|
4541
|
+
* isValidBanglaMonthNumber(0); // false
|
|
4542
|
+
* isValidBanglaMonthNumber(13); // false
|
|
4543
|
+
* isValidBanglaMonthNumber(6.5); // false
|
|
4550
4544
|
* ```
|
|
4551
4545
|
*/
|
|
4552
|
-
declare function
|
|
4546
|
+
declare function isValidBanglaMonthNumber(month: number): boolean;
|
|
4553
4547
|
/**
|
|
4554
|
-
* Checks if a day is valid for a given
|
|
4548
|
+
* Checks if a day is valid for a given Bangla month and year.
|
|
4555
4549
|
*
|
|
4556
|
-
*
|
|
4550
|
+
* Bangla calendar month lengths:
|
|
4557
4551
|
* - Months 1-5 (বৈশাখ-ভাদ্র): 31 days
|
|
4558
4552
|
* - Months 6-10 (আশ্বিন-মাঘ): 30 days
|
|
4559
4553
|
* - Month 11 (ফাল্গুন): 29 or 30 days (depends on Gregorian leap year)
|
|
4560
4554
|
* - Month 12 (চৈত্র): 30 days
|
|
4561
4555
|
*
|
|
4562
4556
|
* @param day - Day to validate
|
|
4563
|
-
* @param month -
|
|
4564
|
-
* @param year -
|
|
4557
|
+
* @param month - Bangla month (1-12)
|
|
4558
|
+
* @param year - Bangla year
|
|
4565
4559
|
* @returns true if day is valid for the given month/year, false otherwise
|
|
4566
4560
|
*
|
|
4567
4561
|
* @example
|
|
4568
4562
|
* Valid days:
|
|
4569
4563
|
* ```typescript
|
|
4570
|
-
*
|
|
4571
|
-
*
|
|
4572
|
-
*
|
|
4564
|
+
* isValidBanglaDay(15, 1, 1431); // true (Boishakh has 31 days)
|
|
4565
|
+
* isValidBanglaDay(31, 1, 1431); // true (last day of Boishakh)
|
|
4566
|
+
* isValidBanglaDay(30, 6, 1431); // true (Ashwin has 30 days)
|
|
4573
4567
|
* ```
|
|
4574
4568
|
*
|
|
4575
4569
|
* @example
|
|
4576
4570
|
* Invalid days:
|
|
4577
4571
|
* ```typescript
|
|
4578
|
-
*
|
|
4579
|
-
*
|
|
4580
|
-
*
|
|
4581
|
-
*
|
|
4572
|
+
* isValidBanglaDay(32, 1, 1431); // false (Boishakh has only 31 days)
|
|
4573
|
+
* isValidBanglaDay(31, 6, 1431); // false (Ashwin has only 30 days)
|
|
4574
|
+
* isValidBanglaDay(0, 1, 1431); // false (day must be >= 1)
|
|
4575
|
+
* isValidBanglaDay(15.5, 1, 1431); // false (must be integer)
|
|
4582
4576
|
* ```
|
|
4583
4577
|
*
|
|
4584
4578
|
* @example
|
|
4585
4579
|
* Leap year handling:
|
|
4586
4580
|
* ```typescript
|
|
4587
|
-
* // 1427
|
|
4588
|
-
*
|
|
4581
|
+
* // 1427 Bangla corresponds to 2020 Gregorian (leap year)
|
|
4582
|
+
* isValidBanglaDay(30, 11, 1427); // true (Falgun has 30 days in leap year)
|
|
4589
4583
|
*
|
|
4590
|
-
* // 1428
|
|
4591
|
-
*
|
|
4592
|
-
*
|
|
4584
|
+
* // 1428 Bangla corresponds to 2021 Gregorian (not leap year)
|
|
4585
|
+
* isValidBanglaDay(30, 11, 1428); // false (Falgun has only 29 days)
|
|
4586
|
+
* isValidBanglaDay(29, 11, 1428); // true
|
|
4593
4587
|
* ```
|
|
4594
4588
|
*/
|
|
4595
|
-
declare function
|
|
4589
|
+
declare function isValidBanglaDay(day: number, month: number, year: number): boolean;
|
|
4596
4590
|
/**
|
|
4597
|
-
* Checks if a
|
|
4591
|
+
* Checks if a Bangla date object is valid.
|
|
4598
4592
|
*
|
|
4599
|
-
* A valid
|
|
4593
|
+
* A valid Bangla date object must have valid year, month, and day properties
|
|
4600
4594
|
* that form a valid date combination.
|
|
4601
4595
|
*
|
|
4602
|
-
* @param date -
|
|
4596
|
+
* @param date - Bangla date object with year, month, day properties
|
|
4603
4597
|
* @returns true if the date object is valid, false otherwise
|
|
4604
4598
|
*
|
|
4605
4599
|
* @example
|
|
4606
4600
|
* Valid dates:
|
|
4607
4601
|
* ```typescript
|
|
4608
|
-
*
|
|
4609
|
-
*
|
|
4610
|
-
*
|
|
4602
|
+
* isValidBanglaDate({ year: 1431, month: 1, day: 1 }); // true
|
|
4603
|
+
* isValidBanglaDate({ year: 1431, month: 6, day: 15 }); // true
|
|
4604
|
+
* isValidBanglaDate({ year: 1431, month: 12, day: 30 }); // true
|
|
4611
4605
|
* ```
|
|
4612
4606
|
*
|
|
4613
4607
|
* @example
|
|
4614
4608
|
* Invalid dates:
|
|
4615
4609
|
* ```typescript
|
|
4616
|
-
*
|
|
4617
|
-
*
|
|
4618
|
-
*
|
|
4619
|
-
*
|
|
4610
|
+
* isValidBanglaDate({ year: 1431, month: 13, day: 1 }); // false (invalid month)
|
|
4611
|
+
* isValidBanglaDate({ year: 1431, month: 1, day: 32 }); // false (day > 31)
|
|
4612
|
+
* isValidBanglaDate({ year: 0, month: 1, day: 1 }); // false (invalid year)
|
|
4613
|
+
* isValidBanglaDate({ year: 1431, month: 6, day: 31 }); // false (Ashwin has only 30 days)
|
|
4620
4614
|
* ```
|
|
4621
4615
|
*
|
|
4622
4616
|
* @example
|
|
4623
4617
|
* Type validation:
|
|
4624
4618
|
* ```typescript
|
|
4625
|
-
*
|
|
4626
|
-
*
|
|
4627
|
-
*
|
|
4619
|
+
* isValidBanglaDate({ year: 1431, month: 1 } as any); // false (missing day)
|
|
4620
|
+
* isValidBanglaDate({ year: '1431', month: 1, day: 1 } as any); // false (year not number)
|
|
4621
|
+
* isValidBanglaDate(null as any); // false
|
|
4628
4622
|
* ```
|
|
4629
4623
|
*/
|
|
4630
|
-
declare function
|
|
4624
|
+
declare function isValidBanglaDate(date: {
|
|
4631
4625
|
year: number;
|
|
4632
4626
|
month: number;
|
|
4633
4627
|
day: number;
|
|
4634
4628
|
}): boolean;
|
|
4635
4629
|
/**
|
|
4636
|
-
* Sanitizes a
|
|
4630
|
+
* Sanitizes a Bangla date object, returning null if invalid.
|
|
4637
4631
|
*
|
|
4638
|
-
* This function validates all components of a
|
|
4632
|
+
* This function validates all components of a Bangla date and returns
|
|
4639
4633
|
* the date object if valid, or null if any component is invalid.
|
|
4640
4634
|
*
|
|
4641
|
-
* @param date -
|
|
4635
|
+
* @param date - Bangla date object to sanitize
|
|
4642
4636
|
* @returns The date object if valid, null otherwise
|
|
4643
4637
|
*
|
|
4644
4638
|
* @example
|
|
4645
4639
|
* Valid dates:
|
|
4646
4640
|
* ```typescript
|
|
4647
|
-
*
|
|
4641
|
+
* sanitizeBanglaDate({ year: 1431, month: 1, day: 1 });
|
|
4648
4642
|
* // { year: 1431, month: 1, day: 1 }
|
|
4649
4643
|
*
|
|
4650
|
-
*
|
|
4644
|
+
* sanitizeBanglaDate({ year: 1431, month: 6, day: 15 });
|
|
4651
4645
|
* // { year: 1431, month: 6, day: 15 }
|
|
4652
4646
|
* ```
|
|
4653
4647
|
*
|
|
4654
4648
|
* @example
|
|
4655
4649
|
* Invalid dates:
|
|
4656
4650
|
* ```typescript
|
|
4657
|
-
*
|
|
4658
|
-
*
|
|
4659
|
-
*
|
|
4660
|
-
*
|
|
4651
|
+
* sanitizeBanglaDate({ year: 1431, month: 13, day: 1 }); // null
|
|
4652
|
+
* sanitizeBanglaDate({ year: 1431, month: 1, day: 32 }); // null
|
|
4653
|
+
* sanitizeBanglaDate({ year: 0, month: 1, day: 1 }); // null
|
|
4654
|
+
* sanitizeBanglaDate(null as any); // null
|
|
4661
4655
|
* ```
|
|
4662
4656
|
*
|
|
4663
4657
|
* @example
|
|
4664
4658
|
* Practical usage (form validation):
|
|
4665
4659
|
* ```typescript
|
|
4666
4660
|
* const userInput = { year: 1431, month: 1, day: 15 };
|
|
4667
|
-
* const validDate =
|
|
4661
|
+
* const validDate = sanitizeBanglaDate(userInput);
|
|
4668
4662
|
*
|
|
4669
4663
|
* if (validDate) {
|
|
4670
4664
|
* console.log('Valid date:', validDate);
|
|
@@ -4673,7 +4667,7 @@ declare function isValidBengaliDate(date: {
|
|
|
4673
4667
|
* }
|
|
4674
4668
|
* ```
|
|
4675
4669
|
*/
|
|
4676
|
-
declare function
|
|
4670
|
+
declare function sanitizeBanglaDate(date: {
|
|
4677
4671
|
year: number;
|
|
4678
4672
|
month: number;
|
|
4679
4673
|
day: number;
|
|
@@ -4684,48 +4678,48 @@ declare function sanitizeBengaliDate(date: {
|
|
|
4684
4678
|
} | null;
|
|
4685
4679
|
|
|
4686
4680
|
/**
|
|
4687
|
-
* Utility functions for
|
|
4681
|
+
* Utility functions for Bangla calendar operations.
|
|
4688
4682
|
*
|
|
4689
|
-
* This module provides helper functions for working with
|
|
4683
|
+
* This module provides helper functions for working with Bangla calendar dates,
|
|
4690
4684
|
* including safe conversions, date arithmetic, comparisons, and formatting utilities.
|
|
4691
4685
|
*
|
|
4692
4686
|
* @module calendar/utils
|
|
4693
4687
|
*/
|
|
4694
4688
|
/**
|
|
4695
|
-
* Safely converts a Gregorian date to
|
|
4689
|
+
* Safely converts a Gregorian date to Bangla date with fallback.
|
|
4696
4690
|
*
|
|
4697
|
-
* Unlike
|
|
4691
|
+
* Unlike toBangla, this function doesn't throw on invalid dates.
|
|
4698
4692
|
* Returns a fallback date object for invalid inputs.
|
|
4699
4693
|
*
|
|
4700
4694
|
* @param date - Gregorian Date object
|
|
4701
4695
|
* @param fallback - Fallback value if conversion fails
|
|
4702
|
-
* @returns
|
|
4696
|
+
* @returns Bangla date object or fallback
|
|
4703
4697
|
*
|
|
4704
4698
|
* @example
|
|
4705
4699
|
* Valid dates:
|
|
4706
4700
|
* ```typescript
|
|
4707
|
-
* const bengaliDate =
|
|
4701
|
+
* const bengaliDate = safeToBangla(new Date(2024, 0, 15));
|
|
4708
4702
|
* // { year: 1430, month: 10, day: 2 }
|
|
4709
4703
|
* ```
|
|
4710
4704
|
*
|
|
4711
4705
|
* @example
|
|
4712
4706
|
* Invalid dates with fallback:
|
|
4713
4707
|
* ```typescript
|
|
4714
|
-
*
|
|
4708
|
+
* safeToBangla(new Date('invalid'), { year: 1431, month: 1, day: 1 });
|
|
4715
4709
|
* // { year: 1431, month: 1, day: 1 }
|
|
4716
4710
|
*
|
|
4717
|
-
*
|
|
4711
|
+
* safeToBangla(null as any, { year: 1431, month: 1, day: 1 });
|
|
4718
4712
|
* // { year: 1431, month: 1, day: 1 }
|
|
4719
4713
|
* ```
|
|
4720
4714
|
*
|
|
4721
4715
|
* @example
|
|
4722
|
-
* Default fallback (current
|
|
4716
|
+
* Default fallback (current Bangla date):
|
|
4723
4717
|
* ```typescript
|
|
4724
|
-
*
|
|
4725
|
-
* // Returns current
|
|
4718
|
+
* safeToBangla(new Date('invalid'));
|
|
4719
|
+
* // Returns current Bangla date
|
|
4726
4720
|
* ```
|
|
4727
4721
|
*/
|
|
4728
|
-
declare function
|
|
4722
|
+
declare function safeToBangla(date: Date, fallback?: {
|
|
4729
4723
|
year: number;
|
|
4730
4724
|
month: number;
|
|
4731
4725
|
day: number;
|
|
@@ -4735,19 +4729,19 @@ declare function safeToBengali(date: Date, fallback?: {
|
|
|
4735
4729
|
day: number;
|
|
4736
4730
|
};
|
|
4737
4731
|
/**
|
|
4738
|
-
* Safely converts a
|
|
4732
|
+
* Safely converts a Bangla date to Gregorian date with fallback.
|
|
4739
4733
|
*
|
|
4740
|
-
* Unlike
|
|
4734
|
+
* Unlike fromBangla, this function doesn't throw on invalid dates.
|
|
4741
4735
|
* Returns a fallback Date object for invalid inputs.
|
|
4742
4736
|
*
|
|
4743
|
-
* @param bengaliDate -
|
|
4737
|
+
* @param bengaliDate - Bangla date object with year, month, day
|
|
4744
4738
|
* @param fallback - Fallback Date if conversion fails (default: current date)
|
|
4745
4739
|
* @returns Gregorian Date object or fallback
|
|
4746
4740
|
*
|
|
4747
4741
|
* @example
|
|
4748
4742
|
* Valid conversions:
|
|
4749
4743
|
* ```typescript
|
|
4750
|
-
*
|
|
4744
|
+
* safeFromBangla({ year: 1431, month: 1, day: 1 });
|
|
4751
4745
|
* // Date object for 2024-04-14
|
|
4752
4746
|
* ```
|
|
4753
4747
|
*
|
|
@@ -4755,101 +4749,101 @@ declare function safeToBengali(date: Date, fallback?: {
|
|
|
4755
4749
|
* Invalid dates with fallback:
|
|
4756
4750
|
* ```typescript
|
|
4757
4751
|
* const fallbackDate = new Date(2024, 0, 1);
|
|
4758
|
-
*
|
|
4752
|
+
* safeFromBangla({ year: 1431, month: 13, day: 1 }, fallbackDate);
|
|
4759
4753
|
* // Returns fallbackDate
|
|
4760
4754
|
*
|
|
4761
|
-
*
|
|
4755
|
+
* safeFromBangla({ year: 0, month: 1, day: 1 }, fallbackDate);
|
|
4762
4756
|
* // Returns fallbackDate
|
|
4763
4757
|
* ```
|
|
4764
4758
|
*/
|
|
4765
|
-
declare function
|
|
4759
|
+
declare function safeFromBangla(bengaliDate: {
|
|
4766
4760
|
year: number;
|
|
4767
4761
|
month: number;
|
|
4768
4762
|
day: number;
|
|
4769
4763
|
}, fallback?: Date): Date;
|
|
4770
4764
|
/**
|
|
4771
|
-
* Gets the number of days in a
|
|
4765
|
+
* Gets the number of days in a Bangla month.
|
|
4772
4766
|
*
|
|
4773
|
-
*
|
|
4767
|
+
* Bangla calendar month lengths (Bangladesh Revised Calendar):
|
|
4774
4768
|
* - Months 1-5: 31 days
|
|
4775
4769
|
* - Months 6-10: 30 days
|
|
4776
|
-
* - Month 11:
|
|
4770
|
+
* - Month 11: 30 or 31 days (31 in leap year)
|
|
4777
4771
|
* - Month 12: 30 days
|
|
4778
4772
|
*
|
|
4779
|
-
* @param month -
|
|
4780
|
-
* @param year -
|
|
4773
|
+
* @param month - Bangla month (1-12)
|
|
4774
|
+
* @param year - Bangla year (for leap year calculation)
|
|
4781
4775
|
* @returns Number of days in the month, or 0 if invalid
|
|
4782
4776
|
*
|
|
4783
4777
|
* @example
|
|
4784
4778
|
* First five months (31 days):
|
|
4785
4779
|
* ```typescript
|
|
4786
|
-
*
|
|
4787
|
-
*
|
|
4788
|
-
*
|
|
4780
|
+
* getBanglaMonthDays(1, 1431); // 31 (Boishakh)
|
|
4781
|
+
* getBanglaMonthDays(2, 1431); // 31 (Joishtho)
|
|
4782
|
+
* getBanglaMonthDays(5, 1431); // 31 (Bhadro)
|
|
4789
4783
|
* ```
|
|
4790
4784
|
*
|
|
4791
4785
|
* @example
|
|
4792
4786
|
* Months 6-10 and 12 (30 days):
|
|
4793
4787
|
* ```typescript
|
|
4794
|
-
*
|
|
4795
|
-
*
|
|
4796
|
-
*
|
|
4788
|
+
* getBanglaMonthDays(6, 1431); // 30 (Ashwin)
|
|
4789
|
+
* getBanglaMonthDays(10, 1431); // 30 (Magh)
|
|
4790
|
+
* getBanglaMonthDays(12, 1431); // 30 (Chaitra)
|
|
4797
4791
|
* ```
|
|
4798
4792
|
*
|
|
4799
4793
|
* @example
|
|
4800
4794
|
* Falgun (month 11) - leap year handling:
|
|
4801
4795
|
* ```typescript
|
|
4802
|
-
*
|
|
4803
|
-
*
|
|
4796
|
+
* getBanglaMonthDays(11, 1426); // 31 (Falgun 1426 → Feb-Mar 2020, leap year)
|
|
4797
|
+
* getBanglaMonthDays(11, 1427); // 30 (Falgun 1427 → Feb-Mar 2021, not leap year)
|
|
4804
4798
|
* ```
|
|
4805
4799
|
*
|
|
4806
4800
|
* @example
|
|
4807
4801
|
* Invalid inputs:
|
|
4808
4802
|
* ```typescript
|
|
4809
|
-
*
|
|
4810
|
-
*
|
|
4803
|
+
* getBanglaMonthDays(0, 1431); // 0
|
|
4804
|
+
* getBanglaMonthDays(13, 1431); // 0
|
|
4811
4805
|
* ```
|
|
4812
4806
|
*/
|
|
4813
|
-
declare function
|
|
4807
|
+
declare function getBanglaMonthDays(month: number, year: number): number;
|
|
4814
4808
|
/**
|
|
4815
|
-
* Adds days to a
|
|
4809
|
+
* Adds days to a Bangla date.
|
|
4816
4810
|
*
|
|
4817
4811
|
* This function properly handles month and year boundaries, including
|
|
4818
4812
|
* varying month lengths and leap years.
|
|
4819
4813
|
*
|
|
4820
|
-
* @param bengaliDate - Starting
|
|
4814
|
+
* @param bengaliDate - Starting Bangla date
|
|
4821
4815
|
* @param days - Number of days to add (can be negative to subtract)
|
|
4822
|
-
* @returns New
|
|
4816
|
+
* @returns New Bangla date object
|
|
4823
4817
|
*
|
|
4824
4818
|
* @example
|
|
4825
4819
|
* Adding days within same month:
|
|
4826
4820
|
* ```typescript
|
|
4827
|
-
*
|
|
4821
|
+
* addDaysToBanglaDate({ year: 1431, month: 1, day: 10 }, 5);
|
|
4828
4822
|
* // { year: 1431, month: 1, day: 15 }
|
|
4829
4823
|
* ```
|
|
4830
4824
|
*
|
|
4831
4825
|
* @example
|
|
4832
4826
|
* Adding days across months:
|
|
4833
4827
|
* ```typescript
|
|
4834
|
-
*
|
|
4828
|
+
* addDaysToBanglaDate({ year: 1431, month: 1, day: 30 }, 5);
|
|
4835
4829
|
* // { year: 1431, month: 2, day: 4 } (crosses to Joishtho)
|
|
4836
4830
|
* ```
|
|
4837
4831
|
*
|
|
4838
4832
|
* @example
|
|
4839
4833
|
* Adding days across years:
|
|
4840
4834
|
* ```typescript
|
|
4841
|
-
*
|
|
4835
|
+
* addDaysToBanglaDate({ year: 1431, month: 12, day: 29 }, 5);
|
|
4842
4836
|
* // { year: 1432, month: 1, day: 3 } (crosses to new year)
|
|
4843
4837
|
* ```
|
|
4844
4838
|
*
|
|
4845
4839
|
* @example
|
|
4846
4840
|
* Subtracting days:
|
|
4847
4841
|
* ```typescript
|
|
4848
|
-
*
|
|
4842
|
+
* addDaysToBanglaDate({ year: 1431, month: 2, day: 5 }, -10);
|
|
4849
4843
|
* // { year: 1431, month: 1, day: 26 }
|
|
4850
4844
|
* ```
|
|
4851
4845
|
*/
|
|
4852
|
-
declare function
|
|
4846
|
+
declare function addDaysToBanglaDate(bengaliDate: {
|
|
4853
4847
|
year: number;
|
|
4854
4848
|
month: number;
|
|
4855
4849
|
day: number;
|
|
@@ -4859,18 +4853,18 @@ declare function addDaysToBengaliDate(bengaliDate: {
|
|
|
4859
4853
|
day: number;
|
|
4860
4854
|
};
|
|
4861
4855
|
/**
|
|
4862
|
-
* Calculates the difference in days between two
|
|
4856
|
+
* Calculates the difference in days between two Bangla dates.
|
|
4863
4857
|
*
|
|
4864
4858
|
* The result is positive if the second date is later, negative if earlier.
|
|
4865
4859
|
*
|
|
4866
|
-
* @param date1 - First
|
|
4867
|
-
* @param date2 - Second
|
|
4860
|
+
* @param date1 - First Bangla date
|
|
4861
|
+
* @param date2 - Second Bangla date
|
|
4868
4862
|
* @returns Number of days between dates (date2 - date1)
|
|
4869
4863
|
*
|
|
4870
4864
|
* @example
|
|
4871
4865
|
* Difference within same month:
|
|
4872
4866
|
* ```typescript
|
|
4873
|
-
* const diff =
|
|
4867
|
+
* const diff = getBanglaDateDifference(
|
|
4874
4868
|
* { year: 1431, month: 1, day: 10 },
|
|
4875
4869
|
* { year: 1431, month: 1, day: 15 }
|
|
4876
4870
|
* );
|
|
@@ -4880,7 +4874,7 @@ declare function addDaysToBengaliDate(bengaliDate: {
|
|
|
4880
4874
|
* @example
|
|
4881
4875
|
* Difference across months:
|
|
4882
4876
|
* ```typescript
|
|
4883
|
-
* const diff =
|
|
4877
|
+
* const diff = getBanglaDateDifference(
|
|
4884
4878
|
* { year: 1431, month: 1, day: 1 },
|
|
4885
4879
|
* { year: 1431, month: 2, day: 1 }
|
|
4886
4880
|
* );
|
|
@@ -4890,7 +4884,7 @@ declare function addDaysToBengaliDate(bengaliDate: {
|
|
|
4890
4884
|
* @example
|
|
4891
4885
|
* Negative difference (earlier date):
|
|
4892
4886
|
* ```typescript
|
|
4893
|
-
* const diff =
|
|
4887
|
+
* const diff = getBanglaDateDifference(
|
|
4894
4888
|
* { year: 1431, month: 1, day: 15 },
|
|
4895
4889
|
* { year: 1431, month: 1, day: 10 }
|
|
4896
4890
|
* );
|
|
@@ -4900,14 +4894,14 @@ declare function addDaysToBengaliDate(bengaliDate: {
|
|
|
4900
4894
|
* @example
|
|
4901
4895
|
* Across years:
|
|
4902
4896
|
* ```typescript
|
|
4903
|
-
* const diff =
|
|
4897
|
+
* const diff = getBanglaDateDifference(
|
|
4904
4898
|
* { year: 1431, month: 1, day: 1 },
|
|
4905
4899
|
* { year: 1432, month: 1, day: 1 }
|
|
4906
4900
|
* );
|
|
4907
|
-
* // 366 (days in
|
|
4901
|
+
* // 366 (days in Bangla year 1431)
|
|
4908
4902
|
* ```
|
|
4909
4903
|
*/
|
|
4910
|
-
declare function
|
|
4904
|
+
declare function getBanglaDateDifference(date1: {
|
|
4911
4905
|
year: number;
|
|
4912
4906
|
month: number;
|
|
4913
4907
|
day: number;
|
|
@@ -4917,16 +4911,16 @@ declare function getBengaliDateDifference(date1: {
|
|
|
4917
4911
|
day: number;
|
|
4918
4912
|
}): number;
|
|
4919
4913
|
/**
|
|
4920
|
-
* Compares two
|
|
4914
|
+
* Compares two Bangla dates.
|
|
4921
4915
|
*
|
|
4922
|
-
* @param date1 - First
|
|
4923
|
-
* @param date2 - Second
|
|
4916
|
+
* @param date1 - First Bangla date
|
|
4917
|
+
* @param date2 - Second Bangla date
|
|
4924
4918
|
* @returns -1 if date1 < date2, 0 if equal, 1 if date1 > date2
|
|
4925
4919
|
*
|
|
4926
4920
|
* @example
|
|
4927
4921
|
* First date is earlier:
|
|
4928
4922
|
* ```typescript
|
|
4929
|
-
*
|
|
4923
|
+
* compareBanglaDates(
|
|
4930
4924
|
* { year: 1431, month: 1, day: 10 },
|
|
4931
4925
|
* { year: 1431, month: 1, day: 15 }
|
|
4932
4926
|
* ); // -1
|
|
@@ -4935,7 +4929,7 @@ declare function getBengaliDateDifference(date1: {
|
|
|
4935
4929
|
* @example
|
|
4936
4930
|
* Dates are equal:
|
|
4937
4931
|
* ```typescript
|
|
4938
|
-
*
|
|
4932
|
+
* compareBanglaDates(
|
|
4939
4933
|
* { year: 1431, month: 1, day: 10 },
|
|
4940
4934
|
* { year: 1431, month: 1, day: 10 }
|
|
4941
4935
|
* ); // 0
|
|
@@ -4944,13 +4938,13 @@ declare function getBengaliDateDifference(date1: {
|
|
|
4944
4938
|
* @example
|
|
4945
4939
|
* First date is later:
|
|
4946
4940
|
* ```typescript
|
|
4947
|
-
*
|
|
4941
|
+
* compareBanglaDates(
|
|
4948
4942
|
* { year: 1431, month: 2, day: 1 },
|
|
4949
4943
|
* { year: 1431, month: 1, day: 31 }
|
|
4950
4944
|
* ); // 1
|
|
4951
4945
|
* ```
|
|
4952
4946
|
*/
|
|
4953
|
-
declare function
|
|
4947
|
+
declare function compareBanglaDates(date1: {
|
|
4954
4948
|
year: number;
|
|
4955
4949
|
month: number;
|
|
4956
4950
|
day: number;
|
|
@@ -4960,9 +4954,9 @@ declare function compareBengaliDates(date1: {
|
|
|
4960
4954
|
day: number;
|
|
4961
4955
|
}): -1 | 0 | 1;
|
|
4962
4956
|
/**
|
|
4963
|
-
* Checks if a
|
|
4957
|
+
* Checks if a Bangla date is in a range (inclusive).
|
|
4964
4958
|
*
|
|
4965
|
-
* @param date -
|
|
4959
|
+
* @param date - Bangla date to check
|
|
4966
4960
|
* @param start - Start of range (inclusive)
|
|
4967
4961
|
* @param end - End of range (inclusive)
|
|
4968
4962
|
* @returns true if date is in range, false otherwise
|
|
@@ -4970,7 +4964,7 @@ declare function compareBengaliDates(date1: {
|
|
|
4970
4964
|
* @example
|
|
4971
4965
|
* Date within range:
|
|
4972
4966
|
* ```typescript
|
|
4973
|
-
*
|
|
4967
|
+
* isBanglaDateInRange(
|
|
4974
4968
|
* { year: 1431, month: 1, day: 15 },
|
|
4975
4969
|
* { year: 1431, month: 1, day: 10 },
|
|
4976
4970
|
* { year: 1431, month: 1, day: 20 }
|
|
@@ -4980,7 +4974,7 @@ declare function compareBengaliDates(date1: {
|
|
|
4980
4974
|
* @example
|
|
4981
4975
|
* Date on boundaries:
|
|
4982
4976
|
* ```typescript
|
|
4983
|
-
*
|
|
4977
|
+
* isBanglaDateInRange(
|
|
4984
4978
|
* { year: 1431, month: 1, day: 10 },
|
|
4985
4979
|
* { year: 1431, month: 1, day: 10 },
|
|
4986
4980
|
* { year: 1431, month: 1, day: 20 }
|
|
@@ -4990,14 +4984,14 @@ declare function compareBengaliDates(date1: {
|
|
|
4990
4984
|
* @example
|
|
4991
4985
|
* Date outside range:
|
|
4992
4986
|
* ```typescript
|
|
4993
|
-
*
|
|
4987
|
+
* isBanglaDateInRange(
|
|
4994
4988
|
* { year: 1431, month: 2, day: 1 },
|
|
4995
4989
|
* { year: 1431, month: 1, day: 10 },
|
|
4996
4990
|
* { year: 1431, month: 1, day: 20 }
|
|
4997
4991
|
* ); // false
|
|
4998
4992
|
* ```
|
|
4999
4993
|
*/
|
|
5000
|
-
declare function
|
|
4994
|
+
declare function isBanglaDateInRange(date: {
|
|
5001
4995
|
year: number;
|
|
5002
4996
|
month: number;
|
|
5003
4997
|
day: number;
|
|
@@ -5011,106 +5005,106 @@ declare function isBengaliDateInRange(date: {
|
|
|
5011
5005
|
day: number;
|
|
5012
5006
|
}): boolean;
|
|
5013
5007
|
/**
|
|
5014
|
-
* Gets the first day of a
|
|
5008
|
+
* Gets the first day of a Bangla month.
|
|
5015
5009
|
*
|
|
5016
|
-
* @param month -
|
|
5017
|
-
* @param year -
|
|
5018
|
-
* @returns
|
|
5010
|
+
* @param month - Bangla month (1-12)
|
|
5011
|
+
* @param year - Bangla year
|
|
5012
|
+
* @returns Bangla date object for the first day of the month
|
|
5019
5013
|
*
|
|
5020
5014
|
* @example
|
|
5021
5015
|
* ```typescript
|
|
5022
|
-
*
|
|
5016
|
+
* getFirstDayOfBanglaMonth(1, 1431);
|
|
5023
5017
|
* // { year: 1431, month: 1, day: 1 }
|
|
5024
5018
|
*
|
|
5025
|
-
*
|
|
5019
|
+
* getFirstDayOfBanglaMonth(6, 1431);
|
|
5026
5020
|
* // { year: 1431, month: 6, day: 1 }
|
|
5027
5021
|
* ```
|
|
5028
5022
|
*/
|
|
5029
|
-
declare function
|
|
5023
|
+
declare function getFirstDayOfBanglaMonth(month: number, year: number): {
|
|
5030
5024
|
year: number;
|
|
5031
5025
|
month: number;
|
|
5032
5026
|
day: number;
|
|
5033
5027
|
};
|
|
5034
5028
|
/**
|
|
5035
|
-
* Gets the last day of a
|
|
5029
|
+
* Gets the last day of a Bangla month.
|
|
5036
5030
|
*
|
|
5037
|
-
* @param month -
|
|
5038
|
-
* @param year -
|
|
5039
|
-
* @returns
|
|
5031
|
+
* @param month - Bangla month (1-12)
|
|
5032
|
+
* @param year - Bangla year
|
|
5033
|
+
* @returns Bangla date object for the last day of the month
|
|
5040
5034
|
*
|
|
5041
5035
|
* @example
|
|
5042
5036
|
* Months with 31 days:
|
|
5043
5037
|
* ```typescript
|
|
5044
|
-
*
|
|
5038
|
+
* getLastDayOfBanglaMonth(1, 1431);
|
|
5045
5039
|
* // { year: 1431, month: 1, day: 31 } (Boishakh)
|
|
5046
5040
|
* ```
|
|
5047
5041
|
*
|
|
5048
5042
|
* @example
|
|
5049
5043
|
* Months with 30 days:
|
|
5050
5044
|
* ```typescript
|
|
5051
|
-
*
|
|
5045
|
+
* getLastDayOfBanglaMonth(6, 1431);
|
|
5052
5046
|
* // { year: 1431, month: 6, day: 30 } (Ashwin)
|
|
5053
5047
|
* ```
|
|
5054
5048
|
*
|
|
5055
5049
|
* @example
|
|
5056
5050
|
* Falgun with leap year:
|
|
5057
5051
|
* ```typescript
|
|
5058
|
-
*
|
|
5059
|
-
* // { year:
|
|
5052
|
+
* getLastDayOfBanglaMonth(11, 1426);
|
|
5053
|
+
* // { year: 1426, month: 11, day: 31 } (leap year)
|
|
5060
5054
|
*
|
|
5061
|
-
*
|
|
5062
|
-
* // { year:
|
|
5055
|
+
* getLastDayOfBanglaMonth(11, 1427);
|
|
5056
|
+
* // { year: 1427, month: 11, day: 30 } (non-leap year)
|
|
5063
5057
|
* ```
|
|
5064
5058
|
*/
|
|
5065
|
-
declare function
|
|
5059
|
+
declare function getLastDayOfBanglaMonth(month: number, year: number): {
|
|
5066
5060
|
year: number;
|
|
5067
5061
|
month: number;
|
|
5068
5062
|
day: number;
|
|
5069
5063
|
};
|
|
5070
5064
|
/**
|
|
5071
|
-
* Checks if a
|
|
5065
|
+
* Checks if a Bangla year is a leap year.
|
|
5072
5066
|
*
|
|
5073
|
-
*
|
|
5074
|
-
* The
|
|
5067
|
+
* Bangla leap years correspond to Gregorian leap years.
|
|
5068
|
+
* The Bangla calendar adjusts Falgun (month 11) from 29 to 30 days in leap years.
|
|
5075
5069
|
*
|
|
5076
|
-
* @param year -
|
|
5070
|
+
* @param year - Bangla year
|
|
5077
5071
|
* @returns true if leap year, false otherwise
|
|
5078
5072
|
*
|
|
5079
5073
|
* @example
|
|
5080
5074
|
* Leap years:
|
|
5081
5075
|
* ```typescript
|
|
5082
|
-
*
|
|
5083
|
-
*
|
|
5076
|
+
* isBanglaLeapYear(1427); // true (corresponds to 2020, a leap year)
|
|
5077
|
+
* isBanglaLeapYear(1420); // true (corresponds to 2013... wait, let me recalculate)
|
|
5084
5078
|
* ```
|
|
5085
5079
|
*
|
|
5086
5080
|
* @example
|
|
5087
5081
|
* Non-leap years:
|
|
5088
5082
|
* ```typescript
|
|
5089
|
-
*
|
|
5090
|
-
*
|
|
5083
|
+
* isBanglaLeapYear(1428); // false (corresponds to 2021)
|
|
5084
|
+
* isBanglaLeapYear(1429); // false (corresponds to 2022)
|
|
5091
5085
|
* ```
|
|
5092
5086
|
*/
|
|
5093
|
-
declare function
|
|
5087
|
+
declare function isBanglaLeapYear(year: number): boolean;
|
|
5094
5088
|
/**
|
|
5095
|
-
* Formats a
|
|
5089
|
+
* Formats a Bangla date as a string with Bangla digits.
|
|
5096
5090
|
*
|
|
5097
|
-
* This is a convenience wrapper around
|
|
5091
|
+
* This is a convenience wrapper around getBanglaDate.
|
|
5098
5092
|
*
|
|
5099
|
-
* @param bengaliDate -
|
|
5093
|
+
* @param bengaliDate - Bangla date object
|
|
5100
5094
|
* @param options - Formatting options
|
|
5101
|
-
* @returns Formatted
|
|
5095
|
+
* @returns Formatted Bangla date string
|
|
5102
5096
|
*
|
|
5103
5097
|
* @example
|
|
5104
5098
|
* Basic formatting:
|
|
5105
5099
|
* ```typescript
|
|
5106
|
-
*
|
|
5100
|
+
* formatBanglaDate({ year: 1431, month: 1, day: 15 });
|
|
5107
5101
|
* // "১৫ বৈশাখ ১৪৩১"
|
|
5108
5102
|
* ```
|
|
5109
5103
|
*
|
|
5110
5104
|
* @example
|
|
5111
5105
|
* Without year:
|
|
5112
5106
|
* ```typescript
|
|
5113
|
-
*
|
|
5107
|
+
* formatBanglaDate(
|
|
5114
5108
|
* { year: 1431, month: 1, day: 15 },
|
|
5115
5109
|
* { includeYear: false }
|
|
5116
5110
|
* );
|
|
@@ -5120,14 +5114,14 @@ declare function isBengaliLeapYear(year: number): boolean;
|
|
|
5120
5114
|
* @example
|
|
5121
5115
|
* With weekday:
|
|
5122
5116
|
* ```typescript
|
|
5123
|
-
*
|
|
5117
|
+
* formatBanglaDate(
|
|
5124
5118
|
* { year: 1431, month: 1, day: 1 },
|
|
5125
5119
|
* { includeWeekday: true }
|
|
5126
5120
|
* );
|
|
5127
5121
|
* // "রবিবার ১ বৈশাখ ১৪৩১" (if 1 Boishakh 1431 is a Sunday)
|
|
5128
5122
|
* ```
|
|
5129
5123
|
*/
|
|
5130
|
-
declare function
|
|
5124
|
+
declare function formatBanglaDate(bengaliDate: {
|
|
5131
5125
|
year: number;
|
|
5132
5126
|
month: number;
|
|
5133
5127
|
day: number;
|
|
@@ -5136,26 +5130,26 @@ declare function formatBengaliDate(bengaliDate: {
|
|
|
5136
5130
|
includeWeekday?: boolean;
|
|
5137
5131
|
}): string;
|
|
5138
5132
|
/**
|
|
5139
|
-
* Gets the current date in
|
|
5133
|
+
* Gets the current date in Bangla calendar.
|
|
5140
5134
|
*
|
|
5141
|
-
* @returns Current
|
|
5135
|
+
* @returns Current Bangla date object
|
|
5142
5136
|
*
|
|
5143
5137
|
* @example
|
|
5144
5138
|
* ```typescript
|
|
5145
|
-
* const today =
|
|
5139
|
+
* const today = getCurrentBanglaDate();
|
|
5146
5140
|
* // { year: 1431, month: 9, day: 24 } (example for 2025-01-07)
|
|
5147
5141
|
* ```
|
|
5148
5142
|
*/
|
|
5149
|
-
declare function
|
|
5143
|
+
declare function getCurrentBanglaDate(): {
|
|
5150
5144
|
year: number;
|
|
5151
5145
|
month: number;
|
|
5152
5146
|
day: number;
|
|
5153
5147
|
};
|
|
5154
5148
|
/**
|
|
5155
|
-
* Batch converts an array of Gregorian dates to
|
|
5149
|
+
* Batch converts an array of Gregorian dates to Bangla dates.
|
|
5156
5150
|
*
|
|
5157
5151
|
* @param dates - Array of Gregorian Date objects
|
|
5158
|
-
* @returns Array of
|
|
5152
|
+
* @returns Array of Bangla date objects
|
|
5159
5153
|
*
|
|
5160
5154
|
* @example
|
|
5161
5155
|
* ```typescript
|
|
@@ -5164,7 +5158,7 @@ declare function getCurrentBengaliDate(): {
|
|
|
5164
5158
|
* new Date(2024, 3, 15),
|
|
5165
5159
|
* new Date(2024, 3, 16)
|
|
5166
5160
|
* ];
|
|
5167
|
-
* const bengaliDates =
|
|
5161
|
+
* const bengaliDates = batchToBangla(dates);
|
|
5168
5162
|
* // [
|
|
5169
5163
|
* // { year: 1431, month: 1, day: 1 },
|
|
5170
5164
|
* // { year: 1431, month: 1, day: 2 },
|
|
@@ -5172,108 +5166,58 @@ declare function getCurrentBengaliDate(): {
|
|
|
5172
5166
|
* // ]
|
|
5173
5167
|
* ```
|
|
5174
5168
|
*/
|
|
5175
|
-
declare function
|
|
5169
|
+
declare function batchToBangla(dates: Date[]): Array<{
|
|
5176
5170
|
year: number;
|
|
5177
5171
|
month: number;
|
|
5178
5172
|
day: number;
|
|
5179
5173
|
}>;
|
|
5180
5174
|
/**
|
|
5181
|
-
* Gets the month lengths for a given
|
|
5175
|
+
* Gets the month lengths for a given Bangla year.
|
|
5182
5176
|
*/
|
|
5183
|
-
declare function
|
|
5177
|
+
declare function getBanglaMonthLengths(bengaliYear: number): number[];
|
|
5184
5178
|
|
|
5185
5179
|
/**
|
|
5186
5180
|
* Formats a Bangladeshi phone number with various formatting options.
|
|
5187
5181
|
*
|
|
5188
|
-
*
|
|
5189
|
-
* returns it formatted according to the specified options. It supports
|
|
5190
|
-
* different formatting styles, country code inclusion, and Bangla digit conversion.
|
|
5191
|
-
*
|
|
5192
|
-
* **Format Options:**
|
|
5193
|
-
* - `spaced` (default): 017 1234 5678
|
|
5194
|
-
* - `dashed`: 017-1234-5678
|
|
5195
|
-
* - `compact`: 01712345678
|
|
5182
|
+
* Defaults to Bangla digits with dashed format for a natural Bangla experience.
|
|
5196
5183
|
*
|
|
5197
5184
|
* @param phoneNumber - Phone number to format (with or without country code)
|
|
5198
5185
|
* @param options - Formatting options
|
|
5199
5186
|
* @param options.includeCountryCode - Add +880 country code (default: false)
|
|
5200
|
-
* @param options.useBanglaDigits - Convert digits to Bangla numerals (default:
|
|
5201
|
-
* @param options.
|
|
5187
|
+
* @param options.useBanglaDigits - Convert digits to Bangla numerals (default: true)
|
|
5188
|
+
* @param options.style - Format style: 'dashed', 'spaced', or 'compact' (default: 'dashed')
|
|
5202
5189
|
* @returns Formatted phone number
|
|
5203
5190
|
* @throws {Error} If phone number has invalid length
|
|
5204
5191
|
*
|
|
5205
5192
|
* @example
|
|
5206
|
-
*
|
|
5207
|
-
* ```typescript
|
|
5208
|
-
* formatPhone('01712345678');
|
|
5209
|
-
* // '017 1234 5678'
|
|
5210
|
-
*
|
|
5211
|
-
* formatPhone('+8801712345678');
|
|
5212
|
-
* // '017 1234 5678'
|
|
5213
|
-
*
|
|
5214
|
-
* formatPhone('017 1234 5678');
|
|
5215
|
-
* // '017 1234 5678'
|
|
5216
|
-
* ```
|
|
5217
|
-
*
|
|
5218
|
-
* @example
|
|
5219
|
-
* Different format styles:
|
|
5193
|
+
* Default (Bangla digits, dashed):
|
|
5220
5194
|
* ```typescript
|
|
5221
|
-
* formatPhone('01712345678'
|
|
5222
|
-
* // '017-1234-5678'
|
|
5223
|
-
*
|
|
5224
|
-
* formatPhone('01712345678', { format: 'compact' });
|
|
5225
|
-
* // '01712345678'
|
|
5226
|
-
*
|
|
5227
|
-
* formatPhone('01712345678', { format: 'spaced' });
|
|
5228
|
-
* // '017 1234 5678'
|
|
5195
|
+
* formatPhone('01712345678'); // '০১৭১-২৩৪৫৬৭৮'
|
|
5229
5196
|
* ```
|
|
5230
5197
|
*
|
|
5231
5198
|
* @example
|
|
5232
|
-
*
|
|
5199
|
+
* Spaced format:
|
|
5233
5200
|
* ```typescript
|
|
5234
|
-
* formatPhone('01712345678', {
|
|
5235
|
-
* // '+880 017 1234 5678'
|
|
5236
|
-
*
|
|
5237
|
-
* formatPhone('01712345678', {
|
|
5238
|
-
* includeCountryCode: true,
|
|
5239
|
-
* format: 'dashed'
|
|
5240
|
-
* });
|
|
5241
|
-
* // '+880 017-1234-5678'
|
|
5201
|
+
* formatPhone('01712345678', { style: 'spaced' }); // '০১৭১ ২৩৪ ৫৬৭৮'
|
|
5242
5202
|
* ```
|
|
5243
5203
|
*
|
|
5244
5204
|
* @example
|
|
5245
|
-
*
|
|
5205
|
+
* Compact with country code:
|
|
5246
5206
|
* ```typescript
|
|
5247
|
-
* formatPhone('01712345678', {
|
|
5248
|
-
* // '
|
|
5249
|
-
*
|
|
5250
|
-
* formatPhone('01712345678', {
|
|
5251
|
-
* useBanglaDigits: true,
|
|
5252
|
-
* format: 'dashed'
|
|
5253
|
-
* });
|
|
5254
|
-
* // '০১৭-১২৩৪-৫৬৭৮'
|
|
5255
|
-
*
|
|
5256
|
-
* formatPhone('01712345678', {
|
|
5257
|
-
* useBanglaDigits: true,
|
|
5258
|
-
* includeCountryCode: true
|
|
5259
|
-
* });
|
|
5260
|
-
* // '+৮৮০ ০১৭ ১২৩৪ ৫৬৭৮'
|
|
5207
|
+
* formatPhone('01712345678', { style: 'compact', includeCountryCode: true });
|
|
5208
|
+
* // '+৮৮০১৭১২৩৪৫৬৭৮'
|
|
5261
5209
|
* ```
|
|
5262
5210
|
*
|
|
5263
5211
|
* @example
|
|
5264
|
-
*
|
|
5212
|
+
* English digits:
|
|
5265
5213
|
* ```typescript
|
|
5266
|
-
* formatPhone('
|
|
5267
|
-
* includeCountryCode: true,
|
|
5268
|
-
* useBanglaDigits: true,
|
|
5269
|
-
* format: 'dashed'
|
|
5270
|
-
* });
|
|
5271
|
-
* // '+৮৮০ ০১৭-১২৩৪-৫৬৭৮'
|
|
5214
|
+
* formatPhone('01712345678', { useBanglaDigits: false }); // '0171-2345678'
|
|
5272
5215
|
* ```
|
|
5273
5216
|
*/
|
|
5274
5217
|
declare function formatPhone(phoneNumber: string, options?: {
|
|
5275
5218
|
includeCountryCode?: boolean;
|
|
5276
5219
|
useBanglaDigits?: boolean;
|
|
5220
|
+
style?: 'spaced' | 'dashed' | 'compact';
|
|
5277
5221
|
format?: 'spaced' | 'dashed' | 'compact';
|
|
5278
5222
|
}): string;
|
|
5279
5223
|
|
|
@@ -5427,6 +5371,22 @@ interface ParsedPhoneNumber {
|
|
|
5427
5371
|
* ```
|
|
5428
5372
|
*/
|
|
5429
5373
|
declare function getOperator(phoneNumber: string): OperatorInfo | null;
|
|
5374
|
+
/**
|
|
5375
|
+
* Gets the mobile operator name as a string.
|
|
5376
|
+
*
|
|
5377
|
+
* This is a convenience wrapper around getOperator that returns just the name.
|
|
5378
|
+
*
|
|
5379
|
+
* @param phoneNumber - Bangladeshi phone number
|
|
5380
|
+
* @returns Operator name string or null if invalid
|
|
5381
|
+
*
|
|
5382
|
+
* @example
|
|
5383
|
+
* ```typescript
|
|
5384
|
+
* getOperatorName('01712345678'); // 'Grameenphone'
|
|
5385
|
+
* getOperatorName('01812345678'); // 'Robi'
|
|
5386
|
+
* getOperatorName('invalid'); // null
|
|
5387
|
+
* ```
|
|
5388
|
+
*/
|
|
5389
|
+
declare function getOperatorName(phoneNumber: string): string | null;
|
|
5430
5390
|
/**
|
|
5431
5391
|
* Parses a phone number into its components.
|
|
5432
5392
|
*
|
|
@@ -5595,34 +5555,34 @@ declare function parseAndFormat(phoneNumber: string, options?: {
|
|
|
5595
5555
|
}): string;
|
|
5596
5556
|
|
|
5597
5557
|
/**
|
|
5598
|
-
* Validates if a string contains ONLY
|
|
5558
|
+
* Validates if a string contains ONLY Bangla/Bangla characters and whitespace.
|
|
5599
5559
|
*
|
|
5600
5560
|
* This function checks if the entire string consists exclusively of characters
|
|
5601
|
-
* from the
|
|
5602
|
-
* It returns false if any non-
|
|
5561
|
+
* from the Bangla Unicode range (U+0980 to U+09FF) and whitespace.
|
|
5562
|
+
* It returns false if any non-Bangla, non-whitespace character is present.
|
|
5603
5563
|
*
|
|
5604
5564
|
* **Use Cases:**
|
|
5605
|
-
* - Form validation (ensuring pure
|
|
5606
|
-
* - Content filtering (verifying
|
|
5565
|
+
* - Form validation (ensuring pure Bangla input)
|
|
5566
|
+
* - Content filtering (verifying Bangla-only text)
|
|
5607
5567
|
* - Data validation (checking text purity)
|
|
5608
5568
|
*
|
|
5609
5569
|
* **Allowed Characters:**
|
|
5610
|
-
* -
|
|
5611
|
-
* -
|
|
5612
|
-
* -
|
|
5570
|
+
* - Bangla consonants, vowels, diacritics
|
|
5571
|
+
* - Bangla digits (০-৯)
|
|
5572
|
+
* - Bangla punctuation
|
|
5613
5573
|
* - Whitespace (spaces, tabs, newlines)
|
|
5614
5574
|
*
|
|
5615
5575
|
* **Not Allowed:**
|
|
5616
5576
|
* - English letters (a-z, A-Z)
|
|
5617
5577
|
* - English digits (0-9)
|
|
5618
|
-
* - Special characters not in
|
|
5578
|
+
* - Special characters not in Bangla range
|
|
5619
5579
|
* - Emojis or other Unicode characters
|
|
5620
5580
|
*
|
|
5621
5581
|
* @param text - String to validate
|
|
5622
|
-
* @returns true if string contains only
|
|
5582
|
+
* @returns true if string contains only Bangla characters and whitespace, false otherwise
|
|
5623
5583
|
*
|
|
5624
5584
|
* @example
|
|
5625
|
-
* Valid pure
|
|
5585
|
+
* Valid pure Bangla text:
|
|
5626
5586
|
* ```typescript
|
|
5627
5587
|
* validateBangla('বাংলা'); // true
|
|
5628
5588
|
* validateBangla('শুভ সকাল'); // true
|
|
@@ -5636,7 +5596,7 @@ declare function parseAndFormat(phoneNumber: string, options?: {
|
|
|
5636
5596
|
* validateBangla('Hello বাংলা'); // false (contains English)
|
|
5637
5597
|
* validateBangla('বাংলা 123'); // false (contains English digits)
|
|
5638
5598
|
* validateBangla('Test'); // false (English only)
|
|
5639
|
-
* validateBangla('বাংলা!'); // false (contains non-
|
|
5599
|
+
* validateBangla('বাংলা!'); // false (contains non-Bangla punctuation)
|
|
5640
5600
|
* ```
|
|
5641
5601
|
*
|
|
5642
5602
|
* @example
|
|
@@ -5656,23 +5616,23 @@ declare function parseAndFormat(phoneNumber: string, options?: {
|
|
|
5656
5616
|
* @example
|
|
5657
5617
|
* Form validation:
|
|
5658
5618
|
* ```typescript
|
|
5659
|
-
* function
|
|
5619
|
+
* function validateBanglaName(name: string): boolean {
|
|
5660
5620
|
* return validateBangla(name) && name.trim().length > 0;
|
|
5661
5621
|
* }
|
|
5662
5622
|
*
|
|
5663
|
-
*
|
|
5664
|
-
*
|
|
5623
|
+
* validateBanglaName('মাহমুদ'); // true
|
|
5624
|
+
* validateBanglaName('Mahmud'); // false
|
|
5665
5625
|
* ```
|
|
5666
5626
|
*/
|
|
5667
5627
|
declare function validateBangla(text: string): boolean;
|
|
5668
5628
|
|
|
5669
5629
|
/**
|
|
5670
|
-
* Checks if a character is a
|
|
5630
|
+
* Checks if a character is a Bangla digit.
|
|
5671
5631
|
*
|
|
5672
|
-
*
|
|
5673
|
-
* This function checks if the input string contains at least one
|
|
5632
|
+
* Bangla digits range from ০ (0) to ৯ (9).
|
|
5633
|
+
* This function checks if the input string contains at least one Bangla digit.
|
|
5674
5634
|
*
|
|
5675
|
-
* **
|
|
5635
|
+
* **Bangla Digits:**
|
|
5676
5636
|
* - ০ (shunno) - 0
|
|
5677
5637
|
* - ১ (ek) - 1
|
|
5678
5638
|
* - ২ (dui) - 2
|
|
@@ -5685,10 +5645,10 @@ declare function validateBangla(text: string): boolean;
|
|
|
5685
5645
|
* - ৯ (noy) - 9
|
|
5686
5646
|
*
|
|
5687
5647
|
* @param char - Character or string to check
|
|
5688
|
-
* @returns true if contains at least one
|
|
5648
|
+
* @returns true if contains at least one Bangla digit, false otherwise
|
|
5689
5649
|
*
|
|
5690
5650
|
* @example
|
|
5691
|
-
* Single
|
|
5651
|
+
* Single Bangla digits:
|
|
5692
5652
|
* ```typescript
|
|
5693
5653
|
* isBanglaDigit('০'); // true
|
|
5694
5654
|
* isBanglaDigit('৫'); // true
|
|
@@ -5696,7 +5656,7 @@ declare function validateBangla(text: string): boolean;
|
|
|
5696
5656
|
* ```
|
|
5697
5657
|
*
|
|
5698
5658
|
* @example
|
|
5699
|
-
* Multiple
|
|
5659
|
+
* Multiple Bangla digits:
|
|
5700
5660
|
* ```typescript
|
|
5701
5661
|
* isBanglaDigit('১২৩'); // true
|
|
5702
5662
|
* isBanglaDigit('৪৫৬'); // true
|
|
@@ -5728,21 +5688,21 @@ declare function validateBangla(text: string): boolean;
|
|
|
5728
5688
|
declare function isBanglaDigit(char: string): boolean;
|
|
5729
5689
|
|
|
5730
5690
|
/**
|
|
5731
|
-
* Checks if a string contains
|
|
5691
|
+
* Checks if a string contains Bangla/Bangla characters.
|
|
5732
5692
|
*
|
|
5733
5693
|
* This function tests if the input string contains at least one character
|
|
5734
|
-
* from the
|
|
5735
|
-
* -
|
|
5736
|
-
* -
|
|
5737
|
-
* -
|
|
5738
|
-
* -
|
|
5739
|
-
* -
|
|
5694
|
+
* from the Bangla Unicode range (U+0980 to U+09FF), which includes:
|
|
5695
|
+
* - Bangla consonants (ক খ গ ঘ ঙ চ ছ জ ঝ ঞ etc.)
|
|
5696
|
+
* - Bangla vowels (অ আ ই ঈ উ ঊ etc.)
|
|
5697
|
+
* - Bangla vowel diacritics (া ি ী ু ূ etc.)
|
|
5698
|
+
* - Bangla digits (০ ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯)
|
|
5699
|
+
* - Bangla punctuation and symbols
|
|
5740
5700
|
*
|
|
5741
5701
|
* @param text - String to check
|
|
5742
|
-
* @returns true if contains at least one
|
|
5702
|
+
* @returns true if contains at least one Bangla character, false otherwise
|
|
5743
5703
|
*
|
|
5744
5704
|
* @example
|
|
5745
|
-
* Pure
|
|
5705
|
+
* Pure Bangla text:
|
|
5746
5706
|
* ```typescript
|
|
5747
5707
|
* isBanglaText('বাংলা'); // true
|
|
5748
5708
|
* isBanglaText('হ্যালো'); // true
|
|
@@ -5750,14 +5710,14 @@ declare function isBanglaDigit(char: string): boolean;
|
|
|
5750
5710
|
* ```
|
|
5751
5711
|
*
|
|
5752
5712
|
* @example
|
|
5753
|
-
*
|
|
5713
|
+
* Bangla digits:
|
|
5754
5714
|
* ```typescript
|
|
5755
5715
|
* isBanglaText('১২৩'); // true
|
|
5756
5716
|
* isBanglaText('৫০০'); // true
|
|
5757
5717
|
* ```
|
|
5758
5718
|
*
|
|
5759
5719
|
* @example
|
|
5760
|
-
* Mixed
|
|
5720
|
+
* Mixed Bangla and English:
|
|
5761
5721
|
* ```typescript
|
|
5762
5722
|
* isBanglaText('Hello বাংলা'); // true
|
|
5763
5723
|
* isBanglaText('Price: ১০০ টাকা'); // true
|
|
@@ -5783,63 +5743,63 @@ declare function isBanglaDigit(char: string): boolean;
|
|
|
5783
5743
|
declare function isBanglaText(text: string): boolean;
|
|
5784
5744
|
|
|
5785
5745
|
/**
|
|
5786
|
-
* General utility functions for
|
|
5746
|
+
* General utility functions for Bangla/Bangla text operations.
|
|
5787
5747
|
*
|
|
5788
|
-
* This module provides helper functions for working with
|
|
5789
|
-
* including counting, detecting, sanitizing, and analyzing
|
|
5748
|
+
* This module provides helper functions for working with Bangla text,
|
|
5749
|
+
* including counting, detecting, sanitizing, and analyzing Bangla content.
|
|
5790
5750
|
*
|
|
5791
5751
|
* @module utils/utils
|
|
5792
5752
|
*/
|
|
5793
5753
|
/**
|
|
5794
|
-
* Counts the number of
|
|
5754
|
+
* Counts the number of Bangla characters in a string.
|
|
5795
5755
|
*
|
|
5796
|
-
* This function counts characters from the
|
|
5797
|
-
* excluding whitespace and non-
|
|
5756
|
+
* This function counts characters from the Bangla Unicode range (U+0980 to U+09FF),
|
|
5757
|
+
* excluding whitespace and non-Bangla characters.
|
|
5798
5758
|
*
|
|
5799
5759
|
* @param text - String to analyze
|
|
5800
|
-
* @returns Number of
|
|
5760
|
+
* @returns Number of Bangla characters
|
|
5801
5761
|
*
|
|
5802
5762
|
* @example
|
|
5803
|
-
* Pure
|
|
5763
|
+
* Pure Bangla text:
|
|
5804
5764
|
* ```typescript
|
|
5805
|
-
*
|
|
5806
|
-
*
|
|
5765
|
+
* countBanglaCharacters('বাংলা'); // 5
|
|
5766
|
+
* countBanglaCharacters('হ্যালো'); // 6
|
|
5807
5767
|
* ```
|
|
5808
5768
|
*
|
|
5809
5769
|
* @example
|
|
5810
5770
|
* Mixed content:
|
|
5811
5771
|
* ```typescript
|
|
5812
|
-
*
|
|
5813
|
-
*
|
|
5772
|
+
* countBanglaCharacters('Hello বাংলা'); // 5
|
|
5773
|
+
* countBanglaCharacters('১২৩ টাকা'); // 6
|
|
5814
5774
|
* ```
|
|
5815
5775
|
*
|
|
5816
5776
|
* @example
|
|
5817
5777
|
* With whitespace:
|
|
5818
5778
|
* ```typescript
|
|
5819
|
-
*
|
|
5779
|
+
* countBanglaCharacters('শুভ সকাল'); // 8 (spaces not counted)
|
|
5820
5780
|
* ```
|
|
5821
5781
|
*/
|
|
5822
|
-
declare function
|
|
5782
|
+
declare function countBanglaCharacters(text: string): number;
|
|
5823
5783
|
/**
|
|
5824
|
-
* Counts the number of
|
|
5784
|
+
* Counts the number of Bangla digits in a string.
|
|
5825
5785
|
*
|
|
5826
|
-
*
|
|
5786
|
+
* Bangla digits: ০ ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯
|
|
5827
5787
|
*
|
|
5828
5788
|
* @param text - String to analyze
|
|
5829
|
-
* @returns Number of
|
|
5789
|
+
* @returns Number of Bangla digits
|
|
5830
5790
|
*
|
|
5831
5791
|
* @example
|
|
5832
5792
|
* ```typescript
|
|
5833
|
-
*
|
|
5834
|
-
*
|
|
5835
|
-
*
|
|
5793
|
+
* countBanglaDigits('১২৩'); // 3
|
|
5794
|
+
* countBanglaDigits('মূল্য: ১০০ টাকা'); // 3
|
|
5795
|
+
* countBanglaDigits('Hello 123'); // 0 (English digits not counted)
|
|
5836
5796
|
* ```
|
|
5837
5797
|
*/
|
|
5838
|
-
declare function
|
|
5798
|
+
declare function countBanglaDigits(text: string): number;
|
|
5839
5799
|
/**
|
|
5840
|
-
* Checks if a string contains mixed
|
|
5800
|
+
* Checks if a string contains mixed Bangla and non-Bangla content.
|
|
5841
5801
|
*
|
|
5842
|
-
* Returns true if the string has both
|
|
5802
|
+
* Returns true if the string has both Bangla characters and non-Bangla
|
|
5843
5803
|
* alphanumeric characters.
|
|
5844
5804
|
*
|
|
5845
5805
|
* @param text - String to check
|
|
@@ -5856,147 +5816,147 @@ declare function countBengaliDigits(text: string): number;
|
|
|
5856
5816
|
* @example
|
|
5857
5817
|
* Pure content:
|
|
5858
5818
|
* ```typescript
|
|
5859
|
-
* isMixedContent('বাংলা'); // false (pure
|
|
5819
|
+
* isMixedContent('বাংলা'); // false (pure Bangla)
|
|
5860
5820
|
* isMixedContent('Hello'); // false (pure English)
|
|
5861
|
-
* isMixedContent('১২৩'); // false (
|
|
5821
|
+
* isMixedContent('১২৩'); // false (Bangla digits only)
|
|
5862
5822
|
* ```
|
|
5863
5823
|
*/
|
|
5864
5824
|
declare function isMixedContent(text: string): boolean;
|
|
5865
5825
|
/**
|
|
5866
|
-
* Extracts only
|
|
5826
|
+
* Extracts only Bangla characters from a string.
|
|
5867
5827
|
*
|
|
5868
|
-
* Removes all non-
|
|
5869
|
-
* from the
|
|
5828
|
+
* Removes all non-Bangla characters, keeping only characters
|
|
5829
|
+
* from the Bangla Unicode range (U+0980 to U+09FF).
|
|
5870
5830
|
*
|
|
5871
5831
|
* @param text - String to extract from
|
|
5872
5832
|
* @param preserveWhitespace - Whether to preserve whitespace (default: false)
|
|
5873
|
-
* @returns String containing only
|
|
5833
|
+
* @returns String containing only Bangla characters
|
|
5874
5834
|
*
|
|
5875
5835
|
* @example
|
|
5876
5836
|
* Extract from mixed content:
|
|
5877
5837
|
* ```typescript
|
|
5878
|
-
*
|
|
5879
|
-
*
|
|
5880
|
-
*
|
|
5838
|
+
* extractBanglaChars('Hello বাংলা World'); // 'বাংলা'
|
|
5839
|
+
* extractBanglaChars('Price: ১০০ taka'); // '১০০'
|
|
5840
|
+
* extractBanglaChars('123 বাংলা 456'); // 'বাংলা'
|
|
5881
5841
|
* ```
|
|
5882
5842
|
*
|
|
5883
5843
|
* @example
|
|
5884
5844
|
* With whitespace preservation:
|
|
5885
5845
|
* ```typescript
|
|
5886
|
-
*
|
|
5887
|
-
*
|
|
5846
|
+
* extractBanglaChars('Hello বাংলা ভাষা', true); // 'বাংলা ভাষা'
|
|
5847
|
+
* extractBanglaChars('Test ১২৩ টাকা', true); // '১২৩ টাকা'
|
|
5888
5848
|
* ```
|
|
5889
5849
|
*
|
|
5890
5850
|
* @example
|
|
5891
|
-
* Pure
|
|
5851
|
+
* Pure Bangla text:
|
|
5892
5852
|
* ```typescript
|
|
5893
|
-
*
|
|
5853
|
+
* extractBanglaChars('বাংলা'); // 'বাংলা' (unchanged)
|
|
5894
5854
|
* ```
|
|
5895
5855
|
*/
|
|
5896
|
-
declare function
|
|
5856
|
+
declare function extractBanglaChars(text: string, preserveWhitespace?: boolean): string;
|
|
5897
5857
|
/**
|
|
5898
|
-
* Removes all
|
|
5858
|
+
* Removes all Bangla characters from a string.
|
|
5899
5859
|
*
|
|
5900
|
-
* Keeps only non-
|
|
5901
|
-
* the
|
|
5860
|
+
* Keeps only non-Bangla characters, removing everything from
|
|
5861
|
+
* the Bangla Unicode range.
|
|
5902
5862
|
*
|
|
5903
5863
|
* @param text - String to process
|
|
5904
|
-
* @returns String with
|
|
5864
|
+
* @returns String with Bangla characters removed
|
|
5905
5865
|
*
|
|
5906
5866
|
* @example
|
|
5907
5867
|
* ```typescript
|
|
5908
|
-
*
|
|
5909
|
-
*
|
|
5910
|
-
*
|
|
5868
|
+
* removeBanglaChars('Hello বাংলা World'); // 'Hello World'
|
|
5869
|
+
* removeBanglaChars('Price: ১০০ taka'); // 'Price: taka'
|
|
5870
|
+
* removeBanglaChars('১২৩ টাকা'); // ' '
|
|
5911
5871
|
* ```
|
|
5912
5872
|
*/
|
|
5913
|
-
declare function
|
|
5873
|
+
declare function removeBanglaChars(text: string): string;
|
|
5914
5874
|
/**
|
|
5915
|
-
* Gets the percentage of
|
|
5875
|
+
* Gets the percentage of Bangla characters in a string.
|
|
5916
5876
|
*
|
|
5917
5877
|
* Calculates what percentage of the total non-whitespace characters
|
|
5918
|
-
* are
|
|
5878
|
+
* are Bangla characters.
|
|
5919
5879
|
*
|
|
5920
5880
|
* @param text - String to analyze
|
|
5921
|
-
* @returns Percentage (0-100) of
|
|
5881
|
+
* @returns Percentage (0-100) of Bangla characters
|
|
5922
5882
|
*
|
|
5923
5883
|
* @example
|
|
5924
5884
|
* ```typescript
|
|
5925
|
-
*
|
|
5926
|
-
*
|
|
5927
|
-
*
|
|
5928
|
-
*
|
|
5885
|
+
* getBanglaPercentage('বাংলা'); // 100
|
|
5886
|
+
* getBanglaPercentage('Hello'); // 0
|
|
5887
|
+
* getBanglaPercentage('Hello বাংলা'); // 50 (5 of 10 chars)
|
|
5888
|
+
* getBanglaPercentage(''); // 0
|
|
5929
5889
|
* ```
|
|
5930
5890
|
*/
|
|
5931
|
-
declare function
|
|
5891
|
+
declare function getBanglaPercentage(text: string): number;
|
|
5932
5892
|
/**
|
|
5933
|
-
* Checks if text is primarily
|
|
5893
|
+
* Checks if text is primarily Bangla (more than 50% Bangla characters).
|
|
5934
5894
|
*
|
|
5935
5895
|
* @param text - String to check
|
|
5936
|
-
* @returns true if more than 50% is
|
|
5896
|
+
* @returns true if more than 50% is Bangla, false otherwise
|
|
5937
5897
|
*
|
|
5938
5898
|
* @example
|
|
5939
5899
|
* ```typescript
|
|
5940
|
-
*
|
|
5941
|
-
*
|
|
5942
|
-
*
|
|
5943
|
-
*
|
|
5900
|
+
* isPrimarilyBangla('বাংলা'); // true (100%)
|
|
5901
|
+
* isPrimarilyBangla('বাংলা ভাষা hello'); // true (>50%)
|
|
5902
|
+
* isPrimarilyBangla('Hello বাংলা world test'); // false (<50%)
|
|
5903
|
+
* isPrimarilyBangla('Hello'); // false (0%)
|
|
5944
5904
|
* ```
|
|
5945
5905
|
*/
|
|
5946
|
-
declare function
|
|
5906
|
+
declare function isPrimarilyBangla(text: string): boolean;
|
|
5947
5907
|
/**
|
|
5948
|
-
* Sanitizes
|
|
5908
|
+
* Sanitizes Bangla text by removing non-Bangla characters.
|
|
5949
5909
|
*
|
|
5950
5910
|
* If fallback is provided, returns fallback when result would be empty.
|
|
5951
5911
|
*
|
|
5952
5912
|
* @param text - Text to sanitize
|
|
5953
5913
|
* @param preserveWhitespace - Preserve whitespace (default: true)
|
|
5954
5914
|
* @param fallback - Fallback value if result is empty (default: empty string)
|
|
5955
|
-
* @returns Sanitized
|
|
5915
|
+
* @returns Sanitized Bangla text or fallback
|
|
5956
5916
|
*
|
|
5957
5917
|
* @example
|
|
5958
5918
|
* ```typescript
|
|
5959
|
-
*
|
|
5960
|
-
*
|
|
5961
|
-
*
|
|
5919
|
+
* sanitizeBanglaText('Hello বাংলা World'); // 'বাংলা'
|
|
5920
|
+
* sanitizeBanglaText('Test 123 টাকা'); // 'টাকা'
|
|
5921
|
+
* sanitizeBanglaText('বাংলা ভাষা'); // 'বাংলা ভাষা'
|
|
5962
5922
|
* ```
|
|
5963
5923
|
*
|
|
5964
5924
|
* @example
|
|
5965
5925
|
* With fallback:
|
|
5966
5926
|
* ```typescript
|
|
5967
|
-
*
|
|
5968
|
-
*
|
|
5927
|
+
* sanitizeBanglaText('Hello World', true, 'N/A'); // 'N/A'
|
|
5928
|
+
* sanitizeBanglaText('123', false, 'নেই'); // 'নেই'
|
|
5969
5929
|
* ```
|
|
5970
5930
|
*/
|
|
5971
|
-
declare function
|
|
5931
|
+
declare function sanitizeBanglaText(text: string, preserveWhitespace?: boolean, fallback?: string): string;
|
|
5972
5932
|
/**
|
|
5973
|
-
* Checks if all digits in a string are
|
|
5933
|
+
* Checks if all digits in a string are Bangla digits.
|
|
5974
5934
|
*
|
|
5975
|
-
* Returns true if string contains digits and all digits are
|
|
5935
|
+
* Returns true if string contains digits and all digits are Bangla.
|
|
5976
5936
|
* Returns false if contains English digits or no digits at all.
|
|
5977
5937
|
*
|
|
5978
5938
|
* @param text - String to check
|
|
5979
|
-
* @returns true if all digits are
|
|
5939
|
+
* @returns true if all digits are Bangla, false otherwise
|
|
5980
5940
|
*
|
|
5981
5941
|
* @example
|
|
5982
|
-
* All
|
|
5942
|
+
* All Bangla digits:
|
|
5983
5943
|
* ```typescript
|
|
5984
|
-
*
|
|
5985
|
-
*
|
|
5986
|
-
*
|
|
5944
|
+
* hasOnlyBanglaDigits('১২৩'); // true
|
|
5945
|
+
* hasOnlyBanglaDigits('মূল্য: ১০০'); // true
|
|
5946
|
+
* hasOnlyBanglaDigits('বাংলা'); // false (no digits)
|
|
5987
5947
|
* ```
|
|
5988
5948
|
*
|
|
5989
5949
|
* @example
|
|
5990
5950
|
* Mixed or English digits:
|
|
5991
5951
|
* ```typescript
|
|
5992
|
-
*
|
|
5993
|
-
*
|
|
5994
|
-
*
|
|
5952
|
+
* hasOnlyBanglaDigits('123'); // false (English digits)
|
|
5953
|
+
* hasOnlyBanglaDigits('১২3'); // false (mixed)
|
|
5954
|
+
* hasOnlyBanglaDigits('Price: 100'); // false
|
|
5995
5955
|
* ```
|
|
5996
5956
|
*/
|
|
5997
|
-
declare function
|
|
5957
|
+
declare function hasOnlyBanglaDigits(text: string): boolean;
|
|
5998
5958
|
/**
|
|
5999
|
-
* Normalizes whitespace in
|
|
5959
|
+
* Normalizes whitespace in Bangla text.
|
|
6000
5960
|
*
|
|
6001
5961
|
* Replaces multiple consecutive whitespaces with a single space
|
|
6002
5962
|
* and trims leading/trailing whitespace.
|
|
@@ -6013,60 +5973,60 @@ declare function hasOnlyBengaliDigits(text: string): boolean;
|
|
|
6013
5973
|
*/
|
|
6014
5974
|
declare function normalizeWhitespace(text: string): string;
|
|
6015
5975
|
/**
|
|
6016
|
-
* Splits text into
|
|
5976
|
+
* Splits text into Bangla and non-Bangla parts.
|
|
6017
5977
|
*
|
|
6018
|
-
* Returns an object with separate strings for
|
|
5978
|
+
* Returns an object with separate strings for Bangla and non-Bangla content.
|
|
6019
5979
|
*
|
|
6020
5980
|
* @param text - Text to split
|
|
6021
|
-
* @returns Object with bengali and
|
|
5981
|
+
* @returns Object with bengali and nonBangla strings
|
|
6022
5982
|
*
|
|
6023
5983
|
* @example
|
|
6024
5984
|
* ```typescript
|
|
6025
|
-
*
|
|
6026
|
-
* // { bengali: 'বাংলা',
|
|
5985
|
+
* splitBanglaContent('Hello বাংলা World');
|
|
5986
|
+
* // { bengali: 'বাংলা', nonBangla: 'Hello World' }
|
|
6027
5987
|
*
|
|
6028
|
-
*
|
|
6029
|
-
* // { bengali: '১০০',
|
|
5988
|
+
* splitBanglaContent('Price: ১০০ taka');
|
|
5989
|
+
* // { bengali: '১০০', nonBangla: 'Price: taka' }
|
|
6030
5990
|
* ```
|
|
6031
5991
|
*/
|
|
6032
|
-
declare function
|
|
5992
|
+
declare function splitBanglaContent(text: string): {
|
|
6033
5993
|
bengali: string;
|
|
6034
|
-
|
|
5994
|
+
nonBangla: string;
|
|
6035
5995
|
};
|
|
6036
5996
|
/**
|
|
6037
|
-
* Checks if a string contains any
|
|
5997
|
+
* Checks if a string contains any Bangla consonants.
|
|
6038
5998
|
*
|
|
6039
|
-
*
|
|
5999
|
+
* Bangla consonants: ক খ গ ঘ ঙ চ ছ জ ঝ ঞ ট ঠ ড ঢ ণ ত থ দ ধ ন প ফ ব ভ ম য র ল শ ষ স হ ড় ঢ় য় ৎ
|
|
6040
6000
|
*
|
|
6041
6001
|
* @param text - Text to check
|
|
6042
|
-
* @returns true if contains
|
|
6002
|
+
* @returns true if contains Bangla consonants, false otherwise
|
|
6043
6003
|
*
|
|
6044
6004
|
* @example
|
|
6045
6005
|
* ```typescript
|
|
6046
|
-
*
|
|
6047
|
-
*
|
|
6048
|
-
*
|
|
6049
|
-
*
|
|
6006
|
+
* hasBanglaConsonants('বাংলা'); // true
|
|
6007
|
+
* hasBanglaConsonants('আই'); // false (vowels only)
|
|
6008
|
+
* hasBanglaConsonants('১২৩'); // false (digits only)
|
|
6009
|
+
* hasBanglaConsonants('Hello'); // false
|
|
6050
6010
|
* ```
|
|
6051
6011
|
*/
|
|
6052
|
-
declare function
|
|
6012
|
+
declare function hasBanglaConsonants(text: string): boolean;
|
|
6053
6013
|
/**
|
|
6054
|
-
* Checks if a string contains any
|
|
6014
|
+
* Checks if a string contains any Bangla vowels (independent or diacritics).
|
|
6055
6015
|
*
|
|
6056
|
-
*
|
|
6057
|
-
*
|
|
6016
|
+
* Bangla vowels: অ আ ই ঈ উ ঊ ঋ ৠ ঌ ৡ এ ঐ ও ঔ
|
|
6017
|
+
* Bangla vowel diacritics: া ি ী ু ূ ৃ ৄ ে ৈ ো ৌ
|
|
6058
6018
|
*
|
|
6059
6019
|
* @param text - Text to check
|
|
6060
|
-
* @returns true if contains
|
|
6020
|
+
* @returns true if contains Bangla vowels, false otherwise
|
|
6061
6021
|
*
|
|
6062
6022
|
* @example
|
|
6063
6023
|
* ```typescript
|
|
6064
|
-
*
|
|
6065
|
-
*
|
|
6066
|
-
*
|
|
6067
|
-
*
|
|
6024
|
+
* hasBanglaVowels('আম'); // true
|
|
6025
|
+
* hasBanglaVowels('বাংলা'); // true (has vowel diacritics)
|
|
6026
|
+
* hasBanglaVowels('ক'); // false (consonant only)
|
|
6027
|
+
* hasBanglaVowels('123'); // false
|
|
6068
6028
|
* ```
|
|
6069
6029
|
*/
|
|
6070
|
-
declare function
|
|
6030
|
+
declare function hasBanglaVowels(text: string): boolean;
|
|
6071
6031
|
|
|
6072
|
-
export { BANGLA_DIGITS, BANGLA_MONTHS, BANGLA_SEASONS, BANGLA_WEEKDAYS,
|
|
6032
|
+
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, getOperatorName, 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 };
|