The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(dashboard): name Etc/GMT world clocks by their real offset
Maurice07eeae848674
diff --git a/client/src/components/Dashboard/useDashboardTimezones.test.ts b/client/src/components/Dashboard/useDashboardTimezones.test.tsindex b5580930f..28a75eb7d 100644--- a/client/src/components/Dashboard/useDashboardTimezones.test.ts+++ b/client/src/components/Dashboard/useDashboardTimezones.test.ts@@ -2,7 +2,7 @@import { act, renderHook, waitFor } from '@testing-library/react';import { useSettingsStore } from '../../store/settingsStore';-import { shortZone, useDashboardTimezones } from './useDashboardTimezones';+import { shortZone, useDashboardTimezones, zoneOptionLabel } from './useDashboardTimezones';const updateSetting = vi.fn<(key: string, value: unknown) => Promise<void>>();const home = Intl.DateTimeFormat().resolvedOptions().timeZone;@@ -32,6 +32,22 @@ describe('shortZone', () => {});});+describe('Etc/GMT zones (#3175)', () => {+ it('FE-COMP-TZHOOK-010: names an Etc/GMT zone by its real offset, which is the opposite of the sign in its id', () => {+ expect(shortZone('Etc/GMT-4')).toBe('GMT+4');+ expect(shortZone('Etc/GMT+4')).toBe('GMT-4');+ expect(shortZone('Etc/GMT-14')).toBe('GMT+14');+ expect(shortZone('Etc/GMT+0')).toBe('GMT');+ expect(shortZone('Etc/UTC')).toBe('UTC');+ });++ it('FE-COMP-TZHOOK-011: the picker lists an Etc/GMT zone under its real offset and every other zone by its id', () => {+ expect(zoneOptionLabel('Etc/GMT-4')).toBe('GMT+4');+ expect(zoneOptionLabel('Etc/GMT+4')).toBe('GMT-4');+ expect(zoneOptionLabel('America/New_York')).toBe('America/New York');+ });+});+describe('useDashboardTimezones', () => {it('FE-COMP-TZHOOK-002: an unset list falls back to home plus the defaults, a stored one is honoured', () => {const fallback = renderHook(() => useDashboardTimezones('en'));diff --git a/client/src/components/Dashboard/useDashboardTimezones.ts b/client/src/components/Dashboard/useDashboardTimezones.tsindex a2da83bb0..a576e7b90 100644--- a/client/src/components/Dashboard/useDashboardTimezones.ts+++ b/client/src/components/Dashboard/useDashboardTimezones.ts@@ -28,12 +28,30 @@ const FALLBACK_ZONES = ['UTC',];+// Etc/GMT±N counts westward as positive (POSIX), so Etc/GMT-4 is four hours ahead of UTC.+const ETC_GMT = /^Etc\/GMT([+-])(\d{1,2})$/;++/** The real offset of an Etc/GMT zone (Etc/GMT-4 reads GMT+4), or null for any other zone. */+function etcGmtLabel(tz: string): string | null {+ const match = ETC_GMT.exec(tz);+ if (!match) return null;+ if (Number(match[2]) === 0) return 'GMT';+ return `GMT${match[1] === '+' ? '-' : '+'}${match[2]}`;+}+/** The city part of a zone id, so America/New_York reads New York. */export function shortZone(tz: string): string {+ const etc = etcGmtLabel(tz);+ if (etc) return etc;const city = tz.split('/').pop() || tz;return city.replace(/_/g, ' ');}+/** How the zone picker lists a zone: its id, with Etc/GMT zones under their real offset. */+export function zoneOptionLabel(tz: string): string {+ return etcGmtLabel(tz) ?? tz.replace(/_/g, ' ');+}+/*** The dashboard's world clocks: the zone list lives in the user's settings, the* clocks tick every 30 seconds, `adding` toggles the zone picker.diff --git a/client/src/mobile/screens/dashboard/MDashWidgets.tsx b/client/src/mobile/screens/dashboard/MDashWidgets.tsxindex 0521170b7..f9eb12470 100644--- a/client/src/mobile/screens/dashboard/MDashWidgets.tsx+++ b/client/src/mobile/screens/dashboard/MDashWidgets.tsx@@ -10,7 +10,7 @@ import { useAddonStore } from '../../../store/addonStore'import { entityGradient } from '../../../utils/gradients'import { useCurrencyConverter } from '../../../components/Dashboard/useCurrencyConverter'import { useCollectionLists } from '../../../components/Dashboard/useCollectionLists'-import { shortZone, useDashboardTimezones } from '../../../components/Dashboard/useDashboardTimezones'+import { shortZone, useDashboardTimezones, zoneOptionLabel } from '../../../components/Dashboard/useDashboardTimezones'import { formatTime, splitReservationDateTime } from '../../../utils/formatters'import { normalizeAppearance, MOBILE_DASH_TOKENS, type MobileDashToken } from '@trek/shared'import { MOMENT_LABEL, upcomingKey, type UpcomingReservation } from '../../../pages/dashboard/dashboardModel'@@ -231,7 +231,7 @@ function MTimezonesWidget(): React.ReactElement {><option value="" disabled>{t('dashboard.tz.searchPlaceholder')}</option>{allZones.filter(z => !zones.includes(z)).map(z => (- <option key={z} value={z}>{z.replace(/_/g, ' ')}</option>+ <option key={z} value={z}>{zoneOptionLabel(z)}</option>))}</select>)}diff --git a/client/src/pages/DashboardPage.tsx b/client/src/pages/DashboardPage.tsxindex 245fed2d2..fa0c5ed74 100644--- a/client/src/pages/DashboardPage.tsx+++ b/client/src/pages/DashboardPage.tsx@@ -25,7 +25,7 @@ import { IcsSubscribeModal } from '../components/Planner/IcsSubscribeModal'import CollectionsWidget from '../components/Dashboard/CollectionsWidget'import { useCurrencyConverter } from '../components/Dashboard/useCurrencyConverter'import { useDashboardPlugins } from '../components/Dashboard/useDashboardPlugins'-import { shortZone, useDashboardTimezones } from '../components/Dashboard/useDashboardTimezones'+import { shortZone, useDashboardTimezones, zoneOptionLabel } from '../components/Dashboard/useDashboardTimezones'import PluginWidgets from '../components/Plugins/PluginWidgets'import PluginFrame from '../components/Plugins/PluginFrame'import { TripCardBadges } from '../components/Plugins/TripCardBadges'@@ -701,7 +701,7 @@ function TimezoneTool({ locale }: { locale: string }): React.ReactElement {const tzOptions = allZones.filter(z => !zones.includes(z))- .map(z => ({ value: z, label: z.replace(/_/g, ' '), searchLabel: z }))+ .map(z => ({ value: z, label: zoneOptionLabel(z), searchLabel: `${z} ${zoneOptionLabel(z)}` }))return (<div className="tool">