mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-28 18:20:42 +00:00
fix(date-time): use browser regional locale for default date format (#8023)
When no explicit dateTimeLocale override is set, the date adapter locale
followed the UI translation language (currentLang), which is region-agnostic
('en' resolves to US MM/DD/YYYY). This mis-formatted dates for en-GB/en-AU
users who never picked a date locale, and turned master red: 5 recurring
start-date E2E tests fail because the suite pins navigator.language=en-GB
and types DD/MM/YYYY.
Fall back to the browser regional locale (getBrowserCultureLang, e.g.
'en-GB') instead, with currentLang/defaultLang/DEFAULT_LOCALE as further
fallbacks. Regression introduced in #8000.
This commit is contained in:
parent
315c900391
commit
97cfb2829d
1 changed files with 8 additions and 2 deletions
|
|
@ -61,11 +61,17 @@ export class DateTimeFormatService {
|
|||
if (cfgValue) {
|
||||
this.setDateAdapterLocale(cfgValue);
|
||||
} else {
|
||||
const uiLang =
|
||||
// No explicit date/time override: follow the browser's regional locale
|
||||
// (e.g. 'en-GB' → DD/MM/YYYY) rather than the UI translation language.
|
||||
// The UI language is region-agnostic — 'en' resolves to US MM/DD/YYYY,
|
||||
// which would mis-format dates for en-GB/en-AU/etc. users who never
|
||||
// picked a date locale. Fall back to UI language, then the default.
|
||||
const fallbackLocale =
|
||||
this._translateService.getBrowserCultureLang?.()?.toLowerCase() ||
|
||||
this._translateService.currentLang ||
|
||||
this._translateService.defaultLang ||
|
||||
DEFAULT_LOCALE;
|
||||
this.setDateAdapterLocale(uiLang as DateTimeLocale);
|
||||
this.setDateAdapterLocale(fallbackLocale as DateTimeLocale);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue