Skip to content

fix(frontend): populate profile timezones via Intl.supportedValuesOf - #306

Open
pphuc25 wants to merge 1 commit into
Calnode:mainfrom
pphuc25:fix/all-iana-timezones
Open

pphuc25 wants to merge 1 commit into
Calnode:mainfrom
pphuc25:fix/all-iana-timezones

Conversation

@pphuc25

@pphuc25 pphuc25 commented Dec 4, 2026

Copy link
Copy Markdown

Summary

The public booking templates (internal/handler/templates/book.html and manage.html) already populate their timezone pickers with Intl.supportedValuesOf('timeZone'). The admin profile page (frontend/src/routes/settings/profile/+page.svelte) still read from a hardcoded 15-item TIMEZONES array in frontend/src/lib/prefs.ts, which left out zones such as Asia/Ho_Chi_Minh and Asia/Bangkok.

This change builds TIMEZONES from Intl.supportedValuesOf('timeZone') merged with FALLBACK_TIMEZONES and sorted. Merging the fallback list is required because V8/ICU omits UTC and Asia/Ho_Chi_Minh from Intl.supportedValuesOf('timeZone') (returning Asia/Saigon instead).

--- a/frontend/src/lib/prefs.ts
+++ b/frontend/src/lib/prefs.ts
-export const TIMEZONES = [
+const FALLBACK_TIMEZONES = [
   'Pacific/Auckland',
   ...
   'Asia/Singapore',
+  'Asia/Ho_Chi_Minh',
+  'Asia/Bangkok',
   ...
   'UTC'
 ];
+
+export const TIMEZONES: string[] = (() => {
+  if (typeof Intl !== 'undefined' && typeof Intl.supportedValuesOf === 'function') {
+    try {
+      return Array.from(new Set([...Intl.supportedValuesOf('timeZone'), ...FALLBACK_TIMEZONES])).sort();
+    } catch {
+      return FALLBACK_TIMEZONES;
+    }
+  }
+  return FALLBACK_TIMEZONES;
+})();

Evidence

  • Before: TIMEZONES in frontend/src/lib/prefs.ts contained 15 hardcoded entries; Asia/Ho_Chi_Minh and Asia/Bangkok were absent from Settings -> Profile -> Timezone.
  • After:
    • Intl.supportedValuesOf('timeZone') returns 418 IANA zones in Node/V8 (UTC: false, Asia/Ho_Chi_Minh: false, Asia/Saigon: true), and merging FALLBACK_TIMEZONES preserves both UTC and Asia/Ho_Chi_Minh.
    • pnpm check (svelte-kit sync && svelte-check --tsconfig ./tsconfig.json): svelte-check found 0 errors and 0 warnings.
    • pnpm build (vite build): completed cleanly (vite build in 12.78s).

Merge Danger

Door: two-way

Reverting frontend/src/lib/prefs.ts restores the previous list with no database or API changes.

Blast Radius: Low

Only affects the TIMEZONES export consumed by the profile timezone Combobox in frontend/src/routes/settings/profile/+page.svelte. Backend validation already uses Go time.LoadLocation on iana_timezone.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No blocking issues — one non-blocking finding below.

Approach: sound — the profile picker should draw from the platform's IANA set instead of a hand-curated 15-entry list, and this matches what the public booking templates already do.

Reviewed changes

  • Timezone source — TIMEZONES is now a module-load union of Intl.supportedValuesOf('timeZone') and the retained FALLBACK_TIMEZONES, deduped and sorted, with the old list kept for engines without supportedValuesOf and for UTC, which CLDR omits.
  • Fallback entries — Asia/Ho_Chi_Minh and Asia/Bangkok were added to the retained list; the first is genuinely absent from CLDR (which returns Asia/Saigon), the second is redundant but harmless.
  • Blast radius — the only consumer is the profile Combobox (settings/profile/+page.svelte:257), and the SPA sets ssr = false, so the module-load IIFE cannot cause hydration drift. Every selectable name is present in Go's embedded tzdata, so the backend time.LoadLocation check in PatchMe accepts the whole list.

Non-blocking

  • CLDR's canonical spellings are the legacy IANA names, so the modern ones stay unsearchable. The list carries Asia/Calcutta, Europe/Kiev, Asia/Rangoon, America/Godthab and Africa/Asmera while lacking Asia/Kolkata, Europe/Kyiv, Asia/Yangon, America/Nuuk and Asia/Asmara, so a user searching the picker for the name they know gets "no results" — the fallback merge only patches one such case (Asia/Ho_Chi_Minh), and leaves both it and Asia/Saigon selectable. The same gap means a stored value outside the list (set via the API or a seed) renders as an empty picker, since Combobox resolves its display label only against items (prefs.ts L95); adding the current spellings to the merge, or appending the stored value in the profile page, closes both.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash | 𝕏

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.

1 participant