Skip to content

fix: reset timer locales at UTC, Gregorian dates, es-ES AM/PM, and two picker fixes - #782

Merged
sirmalloc merged 9 commits into
sirmalloc:mainfrom
eric-engberg:fix/reset-timer-locale
Nov 5, 2026
Merged

sirmalloc merged 9 commits into
sirmalloc:mainfrom
eric-engberg:fix/reset-timer-locale

Conversation

@eric-engberg

Copy link
Copy Markdown
Contributor

What

Five fixes to the Block and Weekly Reset Timers' date mode and to their locale and timezone pickers:

  • With the timezone left at its default, UTC, the chosen locale now formats the timestamp: So 20:30 UTC for de-DE, 8:30 午後 UTC for ja-JP.
  • ar-SA dates are Gregorian under both Bun and Node, as are hand-typed th-TH and fa-IR.
  • es-ES with the 12-hour clock shows AM/PM instead of A M/P M.
  • In the locale picker, typing uk or ca selects en-GB or en-CA, also when that locale is the system or configured one. "Use uk" / "Use ca" moves to the next row.
  • The timezone picker opens on a configured zone the runtime doesn't list, such as Asia/Kolkata, instead of Africa/Abidjan.

Why (evidence)

  • Locale ignored at UTC. The formatter returned its fixed English UTC format before it looked at the locale, so with the default timezone a de-DE Weekly Reset Timer showed Sun 20:30 UTC while the line editor said locale: de-DE. Etc/UTC, the same zone under another name, gave So 20:30 UTC.
  • ar-SA differs by runtime. The date parts fill a YYYY-MM-DD layout, but no calendar was requested. new Intl.DateTimeFormat('ar-SA').resolvedOptions().calendar is gregory in Node 26 and islamic-umalqura in Bun 1.4.2. With identical settings:
    • npx printed ٢٠٢٦-١٠-١٨ ٢٣:٣٠ غرينتش+٣
    • bunx printed ١٤٤٨-جمادى الأولى-٠٧ ٢٣:٣٠ غرينتش+٣, a Hijri year with its era dropped and a month name inside the numeric layout.
    • th-TH printed year 2569 and fa-IR year 1405 on both runtimes.
  • "A M". ICU writes es-ES's day period as a. m. (bytes 61 2e 20 6d 2e). Dropping only the dots left the inner space: 2026-10-16 10:30 P M CEST.
  • uk / ca in the locale picker. en-GB's search keywords include uk and en-CA's include ca. Both are also valid tags (Ukrainian, Catalan), and a valid tag the list doesn't offer was put first as a "Use " row. Since the picker selects the first row after each keystroke, typing uk and pressing Enter saved Ukrainian, and the timer then showed нд 8:30 ДП GMT+0. When en-GB or en-CA was the system locale (Node takes it from LANG; Bun always reports en-US) or the configured one, its System or Configured row replaced the common row without its keywords, so uk did not list en-GB at all.
  • Timezone picker on the wrong row. A valid zone that Intl.supportedValuesOf('timeZone') doesn't list gets its own "Configured timezone" row. Asia/Kolkata is one: both runtimes list only Asia/Calcutta. A zone picked under Bun and reopened under Node, like Etc/GMT-5, is another. The picker took its starting index from the options as given but shows them sorted, so it opened on Africa/Abidjan, and Enter switched the zone to GMT.

How

  • formatUsageResetAt: with a locale set and the zone UTC, format through Intl in that locale, as every other zone already does. The full form ends in a fixed "UTC", as it does without a locale, instead of the zone name Intl gives: a few locales name UTC otherwise, such as el-GR's Συντονισμένη Παγκόσμια Ώρα (6 languages, the same under both runtimes: blo, el, ku, sc, sd and so). Compact mode keeps its Z. Without a locale, the fixed format is unchanged, and en-US gives the same output as no locale. A side effect: a locale with its own digits (ar-SA) now uses them at UTC too (٢٠٢٦-١٠-١٦ ٢٠:٣٠ UTC, was 2026-10-16 20:30 UTC), as it already did in every other zone.
  • formatResetAtInTimezone: request calendar: 'gregory', so the parts always fit the layout. This also overrides a typed -u-ca-…. The locale keeps its own digits, matching its zone name and time; Latin digits remain available by typing ar-SA-u-nu-latn.
  • normalizeDayPeriod: drop each dot together with the space after it. a. m. becomes AM, while day periods without dots keep their spaces (checked across 153 locales on both runtimes).
  • filterLocaleOptions: a locale whose keywords include the search goes ahead of the custom row, which follows directly after it. A tag that matches no keyword, such as en-au, still comes first. A Ukrainian or Catalan user typing the bare code now presses Down once, or types uk-UA / ca-ES, which still come first.
  • getLocaleOptions: the System and Configured rows replace the common row for their locale, so they now carry that row's keywords and match and rank the same way.
  • SearchableOptionEditor: find the starting row in the list the empty search shows. This fixes the locale and timezone pickers alike.

Demo

Locale at UTC. ja-JP 12-hour Block Reset and de-DE weekday Weekly Reset, timezone left at UTC. Before: 8:30 PM UTC / Sun 20:30 UTC. After: 8:30 午後 UTC / So 20:30 UTC.

Powerline

Before:

Locale at UTC before the fix, Powerline

After:

Locale at UTC after the fix, Powerline

Plain

Before:

Locale at UTC before the fix, Plain

After:

Locale at UTC after the fix, Plain

es-ES 12-hour, Europe/Madrid. 10:30 P M CEST becomes 10:30 PM CEST, and dom 10:30 P M becomes dom 10:30 PM.

Powerline

Before:

es-ES day period before the fix, Powerline

After:

es-ES day period after the fix, Powerline

Plain

Before:

es-ES day period before the fix, Plain

After:

es-ES day period after the fix, Plain

ar-SA, Asia/Riyadh, built CLI under Bun and Node. Before: Bun shows a Hijri date, Node a Gregorian one. After: both show the same Gregorian date. (The terminal draws the Arabic letters unjoined.)

Powerline

Before:

ar-SA calendar before the fix, Powerline

After:

ar-SA calendar after the fix, Powerline

Plain

Before:

ar-SA calendar before the fix, Plain

After:

ar-SA calendar after the fix, Plain

Locale picker: type uk, then Enter. Before: "Use uk" is selected and the preview turns Cyrillic (locale: uk). After: en-GB is selected and saved.

Powerline

Before:

Locale picker before the fix, Powerline

After:

Locale picker after the fix, Powerline

Plain

Before:

Locale picker before the fix, Plain

After:

Locale picker after the fix, Plain

Timezone picker with Asia/Kolkata configured: press z, then Enter. Before: it opens on Africa/Abidjan and saves it (08:30 GMT). After: it opens on Asia/Kolkata and keeps it (14:00 GMT+5:30).

Powerline

Before:

Timezone picker before the fix, Powerline

After:

Timezone picker after the fix, Powerline

Plain

Before:

Timezone picker before the fix, Plain

After:

Timezone picker after the fix, Plain

Testing

  • On main as of fix: use env override and settings for usable context ratio calculation #407 (71e8b42): merges cleanly, bun run lint is clean, and bun test gives 3954 pass, 0 fail. The built CLI under Bun 1.4.4 and Node 26.13.0 matches main in plain and Powerline mode with the baseline configs, and the TUI opens and exits cleanly. It adds no JavaScript or Node API newer than Node 14, the build's target.
  • bun run lint: clean.
  • bun test: 3184 pass, 0 fail, across 178 files (main: 3168).
  • Sixteen new tests:
    • usage.test.ts (6): es-ES day period; Gregorian calendar for ar-SA, th-TH and fa-IR; locale at UTC; the fixed UTC label for el-GR at UTC; en-US at UTC unchanged; the fixed UTC format when Intl rejects the locale (de_DE).
    • locales.test.ts (5): keyword vs custom-row ranking, and the same for en-GB/uk and en-CA/ca as the System row and as the Configured row.
    • locale-editor.test.tsx (3): Ink, type uk, Enter saves en-GB, with en-GB as a common, system or configured locale.
    • searchable-option-editor.test.tsx (2): Ink, opens on an unlisted configured value and Enter keeps it, for the locale and timezone editors.
  • Against main's code, 13 of the 16 fail under both Bun and Node; the other 3 are guards.
  • Node v26.10.0 vitest on the four changed test files: 71/71 pass with LANG set to en_US, en_GB and en_CA (main: 55/55). The locale tests pin the runtime's locale, so they no longer depend on the host's LANG.
  • Built CLI under Bun 1.4.2 and Node v26.10.0, with ar-SA (UTC and Asia/Riyadh) and de-DE (UTC): both runtimes now print identical lines in plain and Powerline modes; on main they disagree. With el-GR at UTC, both runtimes print 2026-10-16 20:30 UTC and Κυρ 20:30 UTC (main: Sun 20:30 UTC). The baseline piped render is unchanged, and the TUI opens and exits cleanly under both runtimes.

With the 12-hour clock in date mode, the Block and Weekly Reset Timers
turn the locale's day period into AM/PM by dropping its dots and
uppercasing it. That works for "am", "pm", "a.m." and "p.m.", but ICU
writes es-ES's as "a. m." and "p. m.", with a space after the first dot,
so the timers showed "10:30 A M CEST" in the status line and the preview.
Locales typed in by hand such as ca, bs and es-AR write it the same way.

Drop each dot together with the space after it, so "a. m." becomes "AM"
like the other forms, while a day period without dots keeps its spaces.
In date mode, the Block and Weekly Reset Timers ask Intl for the year,
month and day in the chosen locale and fill them into a YYYY-MM-DD
layout, without saying which calendar to use. ar-SA, which the locale
picker offers, defaults to Gregorian in Node's ICU data but to the
Islamic (Umm al-Qura) calendar in Bun's, where the month comes back as a
name even though two digits were asked for. The same settings then
showed "٢٠٢٦-١٠-١٣ ١٦:٠٥" under npx and "١٤٤٨-جمادى الأولى-٠٢ ١٦:٠٥"
under bunx: a Hijri year with its era dropped and a month name inside
the numeric layout. th-TH (Buddhist year 2569) and fa-IR (Persian year
1405) typed in by hand gave non-Gregorian dates under both runtimes.

Ask for the Gregorian calendar, so the parts always fit the layout and
both runtimes print the same date. The locale keeps its own digits, as
it already does in its zone name and time.
The Block and Weekly Reset Timers offer a locale in date mode whatever
the timezone, and the line editor shows it ("locale: de-DE"). But with
the timezone at its default, UTC, the formatter returned its fixed
English format before it looked at the locale, so the weekday names and
day period stayed English: "Sun 08:30 UTC" for de-DE and "8:30 AM UTC"
for ja-JP, while Etc/UTC, the same zone under another name, gave
"So 08:30 UTC" and "8:30 午前 UTC".

When a locale is set, format UTC through Intl in that locale, as every
other zone already is. The output keeps the UTC format's shape: every
locale names the zone "UTC", and compact mode still ends in "Z". Without
a locale the fixed format is unchanged, and en-US gives the same output
as no locale.
The reset timers' locale picker searches each listed locale by a few
keywords, and en-GB's include 'uk' and en-CA's 'ca'. It also offers a
search that is a valid locale tag not in the list as a "Use <tag>"
custom row, placed first. 'uk' and 'ca' are valid tags too, for
Ukrainian and Catalan, so typing either put "Use uk" or "Use ca" above
en-GB or en-CA, and since the picker selects the first row after each
keystroke, Enter saved Ukrainian or Catalan formatting.

Put a locale whose keywords include the search ahead of the custom row.
The custom row still comes next, so a Ukrainian or Catalan tag is one
Down away, and any other tag the list doesn't offer, such as en-AU,
still comes first.
…oesn't list

A reset timer's timezone picker should open on the configured zone, so
Enter keeps it. A valid zone that Intl doesn't list, such as Asia/Kolkata
(both Node and Bun list it as Asia/Calcutta) or Etc/GMT-5 picked under
Bun and reopened under Node, gets its own "Configured timezone" row
right after Local. The picker found the starting row's index in the
options as given, but shows them sorted, and the sort puts that row
after Africa/Abidjan. So the picker opened on Africa/Abidjan, and Enter
without moving saved it, switching the reset time to GMT.

Find the starting row in the list as the empty search shows it.
…stem or configured locale

The locale picker lists the system locale and the configured locale in
their own rows above the common ones, and drops the common row for the
same locale. Those rows carried only "system ..." or "configured ..."
search words, so when en-GB or en-CA was the system or configured
locale, the 'uk' and 'ca' keywords went with the dropped row. Typing
either put "Use uk" or "Use ca" first again and Enter saved Ukrainian or
Catalan; for 'uk', en-GB was not even listed. That is the case for a UK
or Canadian user under Node, which takes its default locale from LANG,
and for anyone reopening the picker after choosing en-GB or en-CA.

Give the System and Configured rows the keywords of the common locale
they replace, so they match and rank the same way it would.

The keyword tests now pin the runtime's locale: they passed under Bun,
which reports en-US whatever LANG says, and failed under Node with
LANG=en_GB.UTF-8 or en_CA.UTF-8.
With a locale set and the timezone left at its default, UTC, the full
date-mode stamp now goes through Intl in that locale and takes the zone
name Intl gives. For most locales that is "UTC", but a few spell it
differently: el-GR writes "2026-03-15 08:30 Συντονισμένη Παγκόσμια Ώρα",
and sd, ku, sc and so give "م ع و", "SGH", "TCU" and "Waqtiga UTC", the
same under Bun and Node. Without a locale these stamps end in "UTC".

At UTC, the full form now ends in the fixed "UTC" label, as compact mode
already ends in a fixed "Z". The weekday, day period and digits still
follow the locale. An explicitly chosen IANA zone such as Etc/UTC keeps
Intl's zone name, as any other zone does.
With a locale set and the timezone at UTC, a reset timestamp goes
through Intl in that locale, and keeps the fixed format when Intl can't
use the locale. Only the localized outcome had tests.

A POSIX-style tag such as "de_DE" is not a valid language tag, and Intl
throws on it under both Bun and Node. The stamp then reads
"Sun 08:30 UTC" in the full form and "Sun 08:30Z" in compact mode,
where de-DE gives "So 08:30 UTC" and "So 08:30Z".
formatUsageResetAt parsed the timestamp, split its overloaded
locale-or-hour12 argument, and then held both zone paths inline: the
UTC one, which tries the chosen locale, adds the compact "Z" and falls
back to the fixed format, and the IANA or local one with its en-US
fallback.

The UTC path moves into formatResetAtUtcInLocale, next to
formatResetAtUtc and formatResetAtInTimezone, the two formatters it
chooses between. formatUsageResetAt now reads as parse, normalize, then
format for the zone, and its UTC branch is a single call. The output is
the same for every timezone, locale and option.
@axisrow

axisrow commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Reproduced on current main (66e9a08):

Red: 13 failing / 71 total — matching the "13 of the 16 fail, 3 are guards" claim. Clearest symptom: at UTC a de-DE timer renders Expected: "So 08:30 UTC" / Received: "Sun 08:30 UTC". Also reproduced: es-ES 12h day period, Gregorian calendar not forced for ar-SA/th-TH/fa-IR, typing uk/ca in the locale picker saving the wrong locale, and the timezone picker landing on Africa/Abidjan for an unlisted configured zone.

Green: with the full PR head checked out, 71 passing / 0 failing.

Note: verified with bun test on macOS (bun's built-in ICU) — the Bun-vs-Node Hijri/Gregorian divergence was not cross-checked under Node.

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.

3 participants