Skip to content

Commit

Permalink
Fix formatting when day period goes first in the time format #1189
Browse files Browse the repository at this point in the history
  • Loading branch information
andriivarhanov committed Apr 19, 2023
1 parent c4d5d62 commit 415897a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/ids-locale/ids-locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ class IdsLocale {
if (showDayPeriods && calendar) {
result = result.replace(' a', ` ${hours >= 12 ? calendar.dayPeriods[1] : calendar.dayPeriods[0]}`);
if (pattern.indexOf('a') === 0) {
result = result.replace(' a', ` ${hours >= 12 ? calendar.dayPeriods[1] : calendar.dayPeriods[0]}`);
result = result.replace('a', ` ${hours >= 12 ? calendar.dayPeriods[1] : calendar.dayPeriods[0]}`);
}
}

Expand Down Expand Up @@ -760,7 +760,7 @@ class IdsLocale {
dateString = dateString.replace(' de ', ' ');

// Fix ah
dateFormat = dateFormat.replace('/ah/', '/a/h/');
dateFormat = dateFormat.replace('ah', 'a/h');
dateString = dateString.replace('午', '午/');

// Remove commas
Expand Down
4 changes: 2 additions & 2 deletions src/components/ids-time-picker/ids-time-picker-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ class IdsTimePickerPopup extends Base {
}

/**
* @returns {boolean} returns true if the timepicker format includes the am/pm period (" a")
* @returns {boolean} returns true if the timepicker format includes a day period ("a")
*/
#hasPeriod(): boolean {
return this.#is12Hours() && this.format.toLowerCase().includes(' a');
return this.#is12Hours() && (this.format.toLowerCase().indexOf(' a') > -1 || this.format.toLowerCase().indexOf('a') === 0);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/ids-time-picker/ids-time-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@ export default class IdsTimePicker extends Base {
}

/**
* @returns {boolean} returns true if the timepicker format includes the am/pm period (" a")
* @returns {boolean} returns true if the timepicker format includes a day period ("a")
*/
#hasPeriod(): boolean {
return this.#is12Hours() && this.format.toLowerCase().includes(' a');
return this.#is12Hours() && (this.format.toLowerCase().indexOf(' a') > -1 || this.format.toLowerCase().indexOf('a') === 0);
}

/**
Expand Down

0 comments on commit 415897a

Please sign in to comment.