ngx-ode-ui 4.11.0-develop-b2school.1 → 4.11.0-develop-b2school.2

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.
@@ -7,7 +7,7 @@ import { NG_VALUE_ACCESSOR, NgModel, FormsModule } from '@angular/forms';
7
7
  import Flatpickr from 'flatpickr';
8
8
  import French from 'flatpickr/dist/l10n/fr.js';
9
9
  import * as i1 from '@angular/common';
10
- import { CommonModule, DatePipe } from '@angular/common';
10
+ import { CommonModule, getLocaleId, DatePipe } from '@angular/common';
11
11
  import * as i2$1 from 'ngx-ode-sijil';
12
12
  import { NgxOdeSijilModule } from 'ngx-ode-sijil';
13
13
  import * as i2$2 from 'ngx-infinite-scroll';
@@ -2645,8 +2645,21 @@ class LocalizedDatePipe {
2645
2645
  constructor(bundlesService) {
2646
2646
  this.bundlesService = bundlesService;
2647
2647
  }
2648
- transform(value, pattern = 'mediumDate') {
2649
- const datePipe = new DatePipe(this.bundlesService.currentLanguage);
2648
+ transform(value, pattern = "mediumDate") {
2649
+ let targetLanguage = this.bundlesService.currentLanguage || "en";
2650
+ try {
2651
+ // If targetLanguage and angular current locale are different, fall back angular locale to "en"
2652
+ if (getLocaleId(targetLanguage) !== targetLanguage) {
2653
+ targetLanguage = "en";
2654
+ }
2655
+ }
2656
+ catch (e) {
2657
+ // getLocaleId(targetLanguage) can throw an error when locale is not recognized
2658
+ // In such a case, fall back to "en"
2659
+ targetLanguage = "en";
2660
+ }
2661
+ // Use angular locale formatting for localized dates
2662
+ const datePipe = new DatePipe(targetLanguage);
2650
2663
  return datePipe.transform(value, pattern);
2651
2664
  }
2652
2665
  }