Skip to content

Commit 444d426

Browse files
mhaertwiggithub-actions
authored andcommitted
fix(angular/datepicker): allow weekday abbreviations with a period (#2798)
According to https://cldr.unicode.org/, German weekday abbreviations use a period, whereas Swiss weekday abbreviations do not. This caused the datepicker to stop working when `de` was selected as `LOCALE_ID` instead of `de-CH`. This PR makes the date string parsing more robust.
1 parent 97e3ce9 commit 444d426

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/angular/core/datetime/lean-date-adapter.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ describe('LeanDateAdapter', () => {
1414
{ input: '1.1.1', expectedYear: 2001, expectedMonth: 1, expectedDay: 1 },
1515
{ input: '121220', expectedYear: 2020, expectedMonth: 12, expectedDay: 12 },
1616
{ input: '12122020', expectedYear: 2020, expectedMonth: 12, expectedDay: 12 },
17+
{ input: 'So, 12.01.2025', expectedYear: 2025, expectedMonth: 1, expectedDay: 12 },
18+
{ input: 'So., 12.01.2025', expectedYear: 2025, expectedMonth: 1, expectedDay: 12 },
1719
{ input: 'Sa, 01012020', expectedYear: 2020, expectedMonth: 1, expectedDay: 1 },
1820
{ input: 'Sa,01012020', expectedYear: 2020, expectedMonth: 1, expectedDay: 1 },
1921
{ input: '01012020', expectedYear: 2020, expectedMonth: 1, expectedDay: 1 },

src/angular/core/datetime/native-date-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export class SbbNativeDateAdapter extends SbbDateAdapter<Date> {
224224
}
225225

226226
protected _splitStringDate(value: string): [number, number, number] | null {
227-
const match = /^(\w+,[ ]?)?(\d+)\.(\d+)\.(\d+)$/.exec(value);
227+
const match = /^(\w+\.?,[ ]?)?(\d+)\.(\d+)\.(\d+)$/.exec(value);
228228
if (!match) {
229229
return null;
230230
}

0 commit comments

Comments
 (0)