Repository navigation
feat(settings): region, clock and units follow the browser's region - #443
Merged
Merged
Conversation
Times were a mix of AM/PM and 24-hour: English was formatted as en-US, and several components called toLocaleTimeString themselves. Every date and time now goes through utils/format.ts, which writes dates in the interface language in the region's order and times on one chosen clock. The region is detected from the browser's time zone first (an en-US browser in the Netherlands is common, its time zone is not), then from its languages. Settings > Region and units gets Region, Clock and an "Automatic" choice for every unit, each naming what it stands for. Installs keep the units they stored; numbers stay in the interface language. Also: the gateway's charging and battery-heating schedule times follow the clock, the climate schedule time picker gains AM/PM on a 12-hour clock, and the maintenance log's default date is the local day instead of the UTC one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
Times across the app were a mix of AM/PM and 24-hour. English was formatted as
en-US(12-hour clock, month-first dates) while Dutch gotnl-NL. Several components also calledtoLocaleTimeStringthemselves, and the gateway's schedule times were shown exactly as sent. Now every date and time goes through one formatter, and the region, the clock and each unit follow the region the browser is in, with a manual override for each.utils/region.ts): the browser's time zone decides the region first, so an English browser in the Netherlands gets 24-hour times, km and bar. A region named in the browser languages comes next, then the region the first language is most spoken in.utils/timeZoneRegions.tsis generated byfrontend/scripts/gen-time-zone-regions.mjsfrom the CLDR data in Node's ICU. It includes the current IANA names Firefox reports (Asia/Kolkata) next to the CLDR ones Chromium and Safari report (Asia/Calcutta).utils/format.ts):formatDate,formatTime,formatDateTime,formatHourandformatTimeOfDay(for a storedHH:mm).en-NLwrites09/10/2026).12.3wherever the browser is.HH:mmon the 24-hour clock.regionUnits): miles in the US, the UK and their territories; Fahrenheit per CLDR's weather list; psi in the US, UK, Australia, Canada, India and New Zealand; kPa in Japan; metric with bar everywhere else.Behaviour notes
HH:mm, since the Worker does not know a device's clock.Tests
test-setup.tspinsdetectRegionto NL, since CI runs in UTC with jsdom'sen-US.region.spec.tstests the real detection throughvi.importActual.region.spec.ts,RegionalSettings.spec.ts, region unit tables inunits.spec.ts, 12-hour cases forTimeOfDaySelect, the store and the formatters. Specs that pinned02:05 PMfor English now pin the 24-hour default.en-USbrowser in Amsterdam (only 24-hour times, km, bar) and in New York (only 12-hour times, mi, psi, AM/PM picker). The settings section has no overflow at 1440 and 390 px.The zone table adds about 3.8 KB gzip to the entry bundle. Detection has to run before the first render, so it is not lazy.
Type of Change
Related Issues
None.
Checklist
pnpm lint/dotnet build)unraid/garagestack.xmlchanged: copied tojoszz/unraid-community-appsafter merge (not changed)🤖 Generated with Claude Code