Skip to content

fix: add automatic date/time format option for locale-native defaults#1323

Open
Kameti77 wants to merge 6 commits into
stoatchat:mainfrom
Kameti77:fix-issue-629
Open

fix: add automatic date/time format option for locale-native defaults#1323
Kameti77 wants to merge 6 commits into
stoatchat:mainfrom
Kameti77:fix-issue-629

Conversation

@Kameti77

@Kameti77 Kameti77 commented Jul 3, 2026

Copy link
Copy Markdown

This PR adds an Automatic option to both the date and time format pickers in Language settings. Previously, the only choices were fixed presets (DD/MM/YYYY, MM/DD/YYYY, YYYY-MM-DD for date and HH:mm, h:mm A for time). Many locales use formats that don't match any of these. For example, German uses DD.MM.YYYY, Spanish uses H:mm, and Indonesian uses HH.mm, so users on those locales had no option that correctly reflected their locale's native format, and there was no way to revert to the locale default once an override had been picked.

The Automatic option uses the locale's native dayjs format tokens (L for date, LT for time), so it always displays the correct format for whatever language is selected. Switching languages updates the Automatic preview immediately. Explicit overrides are preserved across language switches and can be reverted to Automatic at any time.

Changes made:

  • Language.tsx — Added Automatic as the first option in both pickers. The preview is computed via createMemo tracking a new nativeLocaleFormats signal so it updates reactively when the locale changes. Selecting Automatic calls clearDateFormat()/clearTimeFormat() on the store.
  • dayjs.tsx — Added a nativeLocaleFormats signal that captures the locale's original L and LT formats before any user overrides are applied, so the Automatic preview is never affected by a previously picked override.
  • Locale.ts — Added a public getOptions() accessor (the existing get() is protected). Fixed clearDateFormat() and clearTimeFormat() to call loadTimeLocale() directly so the locale reloads even when the language itself hasn't changed.
  • Time.tsx — Changed the date format case to use dayjs's L token (locale-aware) instead of the hardcoded DD/MM/YYYY. Added a separate dateNormal case that keeps the hardcoded DD/MM/YYYY for the Traditional option preview. Added createEffect so the component updates immediately when the locale signal changes rather than waiting for the next setInterval tick.

Fixes #629

How was this PR tested?

  • Switched to German — Date format shows "Automatic" with preview DD.MM.YYYY (dots)
  • Switched to Spanish — Time format shows "Automatic" with preview H:mm (no AM/PM, no leading zero)
  • Switched to Azerbaijani — Time format shows "Automatic" with correct 24-hour format
  • Switched to English (Traditional) — Automatic date preview shows DD/MM/YYYY, time shows h:mm A
  • Switched to English (Simplified) — Automatic date preview shows MM/DD/YYYY
  • Picked an explicit override (DD/MM/YYYY), then switched languages — override was preserved, did not reset
  • Selected Automatic after an explicit override — preview reverted to locale-native format immediately
  • Refreshed the page with an explicit override — override persisted correctly
  • Refreshed the page with Automatic selected — still showed Automatic with correct locale preview
  • Verified Traditional (DD/MM/YYYY), American (MM/DD/YYYY), and ISO Standard previews always show their fixed formats regardless of locale

Screenshots & Screencasts (if appropriate)

Screenshot 2026-07-02 215356 Screenshot 2026-07-02 215431

Checklist:

  • [x ] I have carefully read the contributing guidelines
  • I have performed a self-review of my own code
  • [x ] I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR
  • I have confirmed that any new dependencies are strictly necessary
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code

Please declare, if any, LLM usage involved in creating this PR

I used Claude Code (Anthropic) as a pair programming assistant throughout this PR. It helped me navigate the codebase, understand the Solid.js reactivity model, and reason through the timing issues with async locale loading. All code was reviewed and understood before committing.

@Kameti77 Kameti77 requested review from a team as code owners July 3, 2026 02:05
@Kameti77 Kameti77 changed the title Fix issue 629 fix: add automatic date/time format option for locale-native defaults Jul 3, 2026
Kameti77 added 5 commits July 2, 2026 22:18
Signed-off-by: Kameti <kametidanielk@gmail.com>
…ocale format

Signed-off-by: Kameti <kametidanielk@gmail.com>
…anges

Signed-off-by: Kameti <kametidanielk@gmail.com>
…defaults

Adds an Automatic option to both the date and time format pickers that
reverts to the locale's native format (e.g. DD.MM.YYYY for German,
H:mm for Spanish) instead of locking the user to a hard-coded preset.

A new nativeLocaleFormats signal in dayjs.tsx captures the locale's
original L and LT formats before any user overrides are applied, so
the Automatic preview always shows the true locale default. Selecting
Automatic calls clearDateFormat/clearTimeFormat on the Locale store.
Explicit overrides are preserved across language switches and can be
reverted to Automatic at any time.

Fixes stoatchat#629

Signed-off-by: Kameti <kametidanielk@gmail.com>
…to reload locale

Signed-off-by: Kameti <kametidanielk@gmail.com>
@Kameti77

Kameti77 commented Jul 3, 2026

Copy link
Copy Markdown
Author

Hi @stoatchat/for-web-maintainers, this is my first contribution. I've fixed #629 by adding an Automatic option to the date/time format pickers so locales like German and Spanish correctly show their native formats. Would appreciate a review when you have time! Looking forward to your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Locales that doesn't fit the patterns of date and time have odd results

1 participant