From 97cfb2829df7c6efa2b98647226fe29e81edf317 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 5 Jun 2026 12:28:58 +0200 Subject: [PATCH] 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. --- .../core/date-time-format/date-time-format.service.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/core/date-time-format/date-time-format.service.ts b/src/app/core/date-time-format/date-time-format.service.ts index 5b6afb87f2..5a0b73297b 100644 --- a/src/app/core/date-time-format/date-time-format.service.ts +++ b/src/app/core/date-time-format/date-time-format.service.ts @@ -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); } }); }