Skip to content

fix(opencode): respect system locale for time formatting#28805

Open
jeaEmri wants to merge 1 commit into
anomalyco:devfrom
jeaEmri:jea/fix-locale-time-format
Open

fix(opencode): respect system locale for time formatting#28805
jeaEmri wants to merge 1 commit into
anomalyco:devfrom
jeaEmri:jea/fix-locale-time-format

Conversation

@jeaEmri
Copy link
Copy Markdown

@jeaEmri jeaEmri commented May 22, 2026

Issue for this PR

Closes #28804

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Bun ignores LC_TIME/LANG env vars when undefined is passed to toLocaleTimeString(), defaulting to en-US (12h AM/PM) regardless of system locale. This is a known Bun bug (oven-sh/bun#7386, open since Dec 2023).

The fix adds a small helper that reads POSIX locale env vars (LC_ALL > LC_TIME > LANG), converts the value to BCP-47 format (e.g. da_DK.UTF-8 -> da-DK), and passes it explicitly to toLocaleTimeString() and toLocaleDateString(). Falls back to undefined (current behavior) when no env vars are set.

How did you verify your code works?

  • bun test test/util/locale.test.ts -- 3 tests pass (24h locale, 12h locale, no-env fallback)
  • Manual verification: LC_TIME=da_DK.UTF-8 bun -e "..." confirms 08.xx output vs 8:xx AM without the fix

Screenshots / recordings

Not a UI change -- only affects time string formatting logic.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

Timestamps always show AM/PM on Linux (Bun ignores system locale)

1 participant