platform icon indicating copy to clipboard operation
platform copied to clipboard

fix: respect locale date order for Asian languages in DatePresenter #10779

Open Learnobug opened this issue 7 months ago • 3 comments

Problem

DatePresenter and DateRangePresenter were hardcoding the Western day-month-year display order (25 Mar 2025) by manually concatenating date parts in the template. This ignored the user's locale, causing incorrect and confusing date display for Asian languages:

Korean (ko): should be 2025년 3월 25일 Japanese (ja): should be 2025年3月25日 Chinese (zh): should be 2025年3月25日

Solution Added a formatDate() utility in DateUtils.ts that uses Intl.DateTimeFormat with the browser's resolved locale, which natively produces the correct ordering for all languages.

Replaced all hardcoded {day} {month} {year} template concatenations with formatDate() in:

DatePresenter.svelte DateRangePresenter.svelte (both inline and button display modes)

Testing Set browser language to Japanese/Korean/Chinese and verify dates render in correct YYYY-MM-DD hierarchy Verify Western locales (en, fr, de) still display correctly as Mar 25 or Mar 25, 2025

Learnobug avatar Apr 18 '26 13:04 Learnobug

Connected to Huly®: UBERF-16321

huly-github-staging avatar Apr 18 '26 13:04 huly-github-staging

@Learnobug Thank you for your contribution. Could you please fix formatting (cd packages/ui && rushx format -f)

BykhovDenis avatar Apr 21 '26 13:04 BykhovDenis

Playwright e2e test failure is unrelated to this change — it requires a running server at localhost:3003 which is unavailable in CI for fork PRs. The formatting fix has been applied. All changes are scoped to DateUtils.ts, DatePresenter.svelte, and DateRangePresenter.svelte

Learnobug avatar Apr 21 '26 15:04 Learnobug