Skip to content

Fix locale-specific date separators in DateTimeFormat#2319

Merged
lahma merged 1 commit into
sebastienros:mainfrom
lahma:fix/intl-locale-date-separator
Mar 6, 2026
Merged

Fix locale-specific date separators in DateTimeFormat#2319
lahma merged 1 commit into
sebastienros:mainfrom
lahma:fix/intl-locale-date-separator

Conversation

@lahma

@lahma lahma commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #557 (comment: #557 (comment))

  • Locale-aware date separators: toLocaleDateString was using hardcoded "/" separator for all numeric date formats. Now derives both the date component order and separator from the locale's ShortDatePattern via DateTimeFormatInfo. This fixes output for locales like nl-NL (uses -), de-DE (.), sv-SE (-), ko-KR (. ), etc.
  • Locale-aware date order: Previously used a hardcoded list of languages for MDY/DMY/YMD ordering, missing locales like sv-SE (YMD). Now parses the order from ShortDatePattern.
  • Consistent CultureInfo: Uses useUserOverride: false when creating CultureInfo to ensure consistent behavior regardless of the host's Windows regional settings.

Before / After

Locale Browser (expected) Before After
nl-NL 6-3-2026 6/3/2026 6-3-2026
de-DE 5.3.2026 5/3/2026 5.3.2026
sv-SE 2026-03-05 5/3/2026 2026-03-05
ko-KR 2026. 3. 5. 2026/3/5 2026. 3. 5.

Test plan

  • intl402 test suite: 0 failures, 3298 passed (no regressions)
  • Main test suite: 0 failures, 5465 passed (no regressions)
  • Verified ParseDateOrder logic produces correct order for 12+ locales

🤖 Generated with Claude Code

toLocaleDateString was using hardcoded "/" separator for all numeric
date formats. Now derives both date component order and separator from
the locale's ShortDatePattern via DateTimeFormatInfo, fixing output for
locales like nl-NL (should use "-"), de-DE ("."), sv-SE ("-"), etc.

Also uses useUserOverride: false when creating CultureInfo to ensure
consistent behavior regardless of Windows regional settings.

Fixes sebastienros#557

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lahma
lahma enabled auto-merge (squash) March 6, 2026 16:55
@lahma
lahma merged commit 9c5f623 into sebastienros:main Mar 6, 2026
4 checks passed
@lahma
lahma deleted the fix/intl-locale-date-separator branch March 6, 2026 17:24
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.

toLocaleDateString format and timezone

1 participant