diff --git a/client/src/components/Admin/paddle/PaddleAutoLoadParts.tsx b/client/src/components/Admin/paddle/PaddleAutoLoadParts.tsx
index 729bc318f..dc434a5a2 100644
--- a/client/src/components/Admin/paddle/PaddleAutoLoadParts.tsx
+++ b/client/src/components/Admin/paddle/PaddleAutoLoadParts.tsx
@@ -1,6 +1,8 @@
import type { PaddleRegionAutoMode, PaddleRegionPending } from '@trek/shared';
import { Ban, CloudDownload, Hand, Loader2, Power, Sparkles } from 'lucide-react';
+import { useDateFormat } from '../../../hooks/useDateFormat';
import { useTranslation } from '../../../i18n';
+import { formatDisplayDate } from '../../../utils/dateFormat';
import { ChoiceChips, SettingRows, SETTINGS_BUTTON, SettingsHint, StatusPill } from '../../Settings/settingsKit';
import { LABEL, Segmented } from '../../shared/dialogParts';
import { fs } from '../../shared/DialogShell';
@@ -71,8 +73,9 @@ export function AutoLoadSettings({ admin }: { admin: Admin }) {
function RequestRow({ request, admin }: { request: PaddleRegionPending; admin: Admin }) {
const { t, language } = useTranslation();
const megabytes = useMegabytes();
+ const dateFormat = useDateFormat();
const busy = admin.busyId === request.id;
- const date = new Date(request.requested_at).toLocaleDateString(language, { dateStyle: 'medium' });
+ const date = formatDisplayDate(new Date(request.requested_at), language, { dateStyle: 'medium' }, dateFormat);
return (
diff --git a/client/src/components/Roadtrip/RoadtripSidebarHeaders.test.tsx b/client/src/components/Roadtrip/RoadtripSidebarHeaders.test.tsx
index f925c4d4a..dcfc2d35a 100644
--- a/client/src/components/Roadtrip/RoadtripSidebarHeaders.test.tsx
+++ b/client/src/components/Roadtrip/RoadtripSidebarHeaders.test.tsx
@@ -104,6 +104,24 @@ describe('DayHeader', () => {
expect(container.querySelector('time')).toHaveTextContent('6/2')
})
+ it('FE-ROADTRIP-HEADERS-003c: a chosen date format sets the order and separator on the tile, whatever the clock', () => {
+ const tileDate = (time_format: string, date_format: string): string | null => {
+ useSettingsStore.setState({ settings: { distance_unit: 'metric', time_format, date_format } as never })
+ const { container, unmount } = wrap()
+ const text = container.querySelector('time')!.textContent
+ unmount()
+ return text
+ }
+ // 5 October: a 12-hour reader who writes the day first no longer sees "10/5".
+ expect(tileDate('12h', 'DD/MM/YYYY')).toBe('5/10')
+ expect(tileDate('24h', 'YYYY-MM-DD')).toBe('10-5')
+ expect(tileDate('12h', 'DD.MM.YYYY')).toBe('5.10.')
+ expect(tileDate('24h', 'MM/DD/YYYY')).toBe('10/5')
+ // On auto the clock still decides, as before the format existed.
+ expect(tileDate('12h', 'auto')).toBe('10/5')
+ expect(tileDate('24h', 'auto')).toBe('5.10.')
+ })
+
it('FE-ROADTRIP-HEADERS-004: the pills never wrap but give way in steps as the row narrows, and a day of only its night has no drive and no count', () => {
// Room for everything: the drive with its time, the count with its word. The old
// narrow flag no longer decides it; the row measures its own room.
diff --git a/client/src/components/Roadtrip/RoadtripSidebarHeaders.tsx b/client/src/components/Roadtrip/RoadtripSidebarHeaders.tsx
index 0a1432438..3db7565b9 100644
--- a/client/src/components/Roadtrip/RoadtripSidebarHeaders.tsx
+++ b/client/src/components/Roadtrip/RoadtripSidebarHeaders.tsx
@@ -6,6 +6,8 @@ import { useTranslation } from '../../i18n/TranslationContext'
import { Tooltip } from '../shared/Tooltip'
import { NEUTRAL_TINT, fs } from '../shared/DialogShell'
import { useSettingsStore } from '../../store/settingsStore'
+import { useDateFormat } from '../../hooks/useDateFormat'
+import { dateLayout } from '../../utils/dateFormat'
import { formatDistance } from '../../utils/units'
import { formatDate } from '../../utils/formatters'
import { formatDurationShort } from './roadtripModel'
@@ -89,13 +91,22 @@ export function TripSummary({ routes, narrow }: { routes: RoadtripRoutes; narrow
}
/**
- * A date short enough for the day tile, in the order the reader's clock setting implies:
- * month first with the 12-hour clock ("10/5"), day first with the 24-hour one ("5.10.").
+ * A date short enough for the day tile: day and month, unpadded, in the order and with
+ * the separator of the reader's date format ("5/10", "10-5", "5.10."). With the format
+ * on 'auto' the clock setting still decides, as it did before the format existed: month
+ * first with the 12-hour clock ("10/5"), day first with the 24-hour one ("5.10.").
*/
-function shortDate(iso: string, is12h: boolean): string {
+function shortDate(iso: string, is12h: boolean, format?: string | null): string {
const [, m, d] = iso.split("-").map(Number)
if (!m || !d) return iso
- return is12h ? `${m}/${d}` : `${d}.${m}.`
+ const layout = dateLayout(format)
+ if (!layout) return is12h ? `${m}/${d}` : `${d}.${m}.`
+ const text = layout.order
+ .filter(field => field !== 'year')
+ .map(field => (field === 'day' ? d : m))
+ .join(layout.separator)
+ // The dotted layout closes on a dot the way it is written in full ("5.10.2026").
+ return layout.separator === '.' ? `${text}.` : text
}
@@ -139,6 +150,7 @@ function flagTexts(day: RoadtripDay, followable: boolean, t: ReturnType s.settings.time_format) === "12h"
+ const dateFormat = useDateFormat()
return (
>
) : null}
diff --git a/client/src/components/Tours/paddle/ObstacleDecisionPanel.tsx b/client/src/components/Tours/paddle/ObstacleDecisionPanel.tsx
index 96195e51a..a62995592 100644
--- a/client/src/components/Tours/paddle/ObstacleDecisionPanel.tsx
+++ b/client/src/components/Tours/paddle/ObstacleDecisionPanel.tsx
@@ -19,6 +19,7 @@ import {
X,
} from 'lucide-react';
import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react';
+import { useDateFormat } from '../../../hooks/useDateFormat';
import { useTranslation } from '../../../i18n';
import { fs } from '../../shared/DialogShell';
import { Tooltip } from '../../shared/Tooltip';
@@ -306,9 +307,10 @@ function decidedLine(
decision: ObstacleDecisionRecord,
memberName: (id: number | null) => string | null,
t: Translate,
- locale: string
+ locale: string,
+ dateFormat: string
): string {
- const date = formatCheckDate(decision.decided_at, locale);
+ const date = formatCheckDate(decision.decided_at, locale, dateFormat);
const name = memberName(decision.decided_by);
return name ? t('tours.paddle.check.decidedBy', { date, name }) : t('tours.paddle.check.decidedAt', { date });
}
@@ -330,10 +332,11 @@ function MetaLine({
onNext: (() => void) | null;
}) {
const { t, locale } = useTranslation();
+ const dateFormat = useDateFormat();
if (!decision && !onNext) return null;
return (
diff --git a/client/src/components/Tours/paddle/PaddleCheckCard.tsx b/client/src/components/Tours/paddle/PaddleCheckCard.tsx
index d3394f6f2..502e4a3c7 100644
--- a/client/src/components/Tours/paddle/PaddleCheckCard.tsx
+++ b/client/src/components/Tours/paddle/PaddleCheckCard.tsx
@@ -8,6 +8,7 @@ import type {
} from '@trek/shared';
import { AlertTriangle, CloudOff, LifeBuoy, ListChecks, Loader2, PencilLine, Save, WifiOff } from 'lucide-react';
import { useEffect, useId, useMemo, useRef, useState, type ReactNode } from 'react';
+import { useDateFormat } from '../../../hooks/useDateFormat';
import { useTranslation } from '../../../i18n';
import { useSettingsStore } from '../../../store/settingsStore';
import { formatDistance } from '../../../utils/units';
@@ -81,8 +82,9 @@ function rowKey(row: ChecklistRow, index: number): string {
/** The sentence the checklist's state calls for. */
function CheckNoticeLine({ notice, evaluatedAt }: { notice: CheckNotice; evaluatedAt: string | null }) {
const { t, locale } = useTranslation();
+ const dateFormat = useDateFormat();
const { textKey, icon, role } = NOTICES[notice];
- const time = evaluatedAt ? formatCheckDate(evaluatedAt, locale) : '';
+ const time = evaluatedAt ? formatCheckDate(evaluatedAt, locale, dateFormat) : '';
return (
{t(textKey, { time })}
@@ -311,11 +313,12 @@ function EarlierDecisions({
/** A route without rows: nothing known where the data covers it, no data where there is none; else the data line speaks. */
function EmptyLine({ summary }: { summary: PaddleCheck | null }) {
const { t, locale } = useTranslation();
+ const dateFormat = useDateFormat();
let text: string | null = null;
if (summary?.data === 'none') text = t('tours.paddle.obstacles.none');
else if (summary?.data === 'covered') {
const date = summary.data_as_of
- ? formatCheckDate(summary.data_as_of, locale)
+ ? formatCheckDate(summary.data_as_of, locale, dateFormat)
: t('tours.paddle.obstacles.dateUnknown');
text = t('tours.paddle.obstacles.coveredEmpty', { date });
}
diff --git a/client/src/components/Tours/paddle/PaddleObstacleCard.tsx b/client/src/components/Tours/paddle/PaddleObstacleCard.tsx
index 569797808..4a4264bda 100644
--- a/client/src/components/Tours/paddle/PaddleObstacleCard.tsx
+++ b/client/src/components/Tours/paddle/PaddleObstacleCard.tsx
@@ -1,8 +1,10 @@
import { ExternalLink, X } from 'lucide-react';
import type { ReactNode } from 'react';
+import { useDateFormat } from '../../../hooks/useDateFormat';
import { useTranslation } from '../../../i18n';
import { useSettingsStore } from '../../../store/settingsStore';
import type { DistanceUnit } from '../../../types';
+import { formatDisplayDate } from '../../../utils/dateFormat';
import { formatDistance } from '../../../utils/units';
import { MAP_CARD_GLASS } from '../../Map/mapControlShadow';
import { SoftPill } from '../../Planner/planParts';
@@ -86,7 +88,10 @@ function AccessAndFacts({ detail, unit }: { detail: PaddleObstacleDetail; unit:
/** The way to the source and how current it is; a record in the data is no check on site. */
function SourceLines({ detail }: { detail: PaddleObstacleDetail }) {
const { t, language } = useTranslation();
- const date = detail.dataAsOf ? new Date(detail.dataAsOf).toLocaleDateString(language, { dateStyle: 'medium' }) : null;
+ const dateFormat = useDateFormat();
+ const date = detail.dataAsOf
+ ? formatDisplayDate(new Date(detail.dataAsOf), language, { dateStyle: 'medium' }, dateFormat)
+ : null;
return (
<>
region.source_timestamp)
.filter((time): time is string => !!time)
.sort(compareCodeUnits);
- return times[0] ? new Date(times[0]).toLocaleDateString(language, { dateStyle: 'medium' }) : null;
+ return times[0] ? formatDisplayDate(new Date(times[0]), language, { dateStyle: 'medium' }, dateFormat) : null;
}
/**
@@ -23,6 +29,7 @@ function dataDate(regions: readonly { source_timestamp?: string | null }[], lang
*/
export function PaddleObstacleNotice() {
const { t, language } = useTranslation();
+ const dateFormat = useDateFormat();
const { status, coverage, related, regions, truncated } = usePaddleObstacleStore(
useShallow((state) => ({
status: state.status,
@@ -43,7 +50,7 @@ export function PaddleObstacleNotice() {
if (status === 'offline')
return }>{t('tours.paddle.obstacles.offline')};
if (status === 'error') return {t('tours.paddle.obstacles.error')};
- const date = dataDate(regions, language) ?? t('tours.paddle.obstacles.dateUnknown');
+ const date = dataDate(regions, language, dateFormat) ?? t('tours.paddle.obstacles.dateUnknown');
if (coverage === 'none') return {t('tours.paddle.obstacles.none')};
if (coverage === 'partial')
return {t('tours.paddle.obstacles.partial', { date })};
diff --git a/client/src/components/Tours/paddle/paddleCheckModel.test.ts b/client/src/components/Tours/paddle/paddleCheckModel.test.ts
index 3065b218d..3f45a32df 100644
--- a/client/src/components/Tours/paddle/paddleCheckModel.test.ts
+++ b/client/src/components/Tours/paddle/paddleCheckModel.test.ts
@@ -1,4 +1,4 @@
-// PCM-001 to PCM-019: the check bench of a paddle tour in one pill, how the dates of the checklist read, where the
+// PCM-001 to PCM-020: the check bench of a paddle tour in one pill, how the dates of the checklist read, where the
// camera goes for an entry and the order the checklist lists its rows in (PAD-06, PAD-09).
import { Ban, CircleDashed, ListChecks } from 'lucide-react';
import { describe, expect, it } from 'vitest';
@@ -146,6 +146,13 @@ describe('formatCheckDate', () => {
expect(formatCheckDate('', 'en')).toBe('');
expect(formatCheckDate('2026-05', 'not a language')).toBe('2026-05');
});
+
+ it('PCM-020: a day takes the chosen date format where the language writes it in numbers, a month stays named', () => {
+ expect(formatCheckDate('2026-10-01', 'de', 'YYYY-MM-DD')).toBe('2026-10-01');
+ expect(formatCheckDate('2026-10-01', 'de', 'auto')).toBe(formatCheckDate('2026-10-01', 'de'));
+ expect(formatCheckDate('2026-10-01', 'en', 'YYYY-MM-DD')).toMatch(/Oct.*1.*2026/);
+ expect(formatCheckDate('2026-05', 'de', 'YYYY-MM-DD')).toBe(formatCheckDate('2026-05', 'de'));
+ });
});
describe('focusPointsOf', () => {
diff --git a/client/src/components/Tours/paddle/paddleCheckModel.ts b/client/src/components/Tours/paddle/paddleCheckModel.ts
index 1c45b27ce..e1f48bfef 100644
--- a/client/src/components/Tours/paddle/paddleCheckModel.ts
+++ b/client/src/components/Tours/paddle/paddleCheckModel.ts
@@ -7,6 +7,7 @@ import {
type TourOwnEntry,
} from '@trek/shared';
import { Ban, CircleDashed, ListChecks, type LucideIcon } from 'lucide-react';
+import { formatDisplayDate } from '../../../utils/dateFormat';
type Translate = (key: string, params?: Record) => string;
@@ -52,8 +53,11 @@ export function paddleCheckFact(check: PaddleCheck, t: Translate): { icon: Lucid
const MONTH = /^(\d{4})-(\d{2})$/;
-/** A date of the checklist in the user's locale: a bare `YYYY-MM` (an OSM check date) reads as month and year. */
-export function formatCheckDate(value: string, locale: string): string {
+/**
+ * A date of the checklist in the user's locale: a bare `YYYY-MM` (an OSM check date) reads as month and year.
+ * `format` is the user's date format, which the day takes where the language writes it in numbers.
+ */
+export function formatCheckDate(value: string, locale: string, format?: string | null): string {
const month = MONTH.exec(value);
try {
if (month) {
@@ -64,7 +68,7 @@ export function formatCheckDate(value: string, locale: string): string {
if (Number.isNaN(date.getTime())) return value;
// A bare day is a calendar day, not an instant in the user's zone.
const timeZone = /^\d{4}-\d{2}-\d{2}$/.test(value) ? 'UTC' : undefined;
- return new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeZone }).format(date);
+ return formatDisplayDate(date, locale, { dateStyle: 'medium', timeZone }, format);
} catch {
return value;
}
diff --git a/client/src/mobile/screens/admin/MAdminPaddleRegionsPanel.tsx b/client/src/mobile/screens/admin/MAdminPaddleRegionsPanel.tsx
index d42a5ed87..af0a35e1c 100644
--- a/client/src/mobile/screens/admin/MAdminPaddleRegionsPanel.tsx
+++ b/client/src/mobile/screens/admin/MAdminPaddleRegionsPanel.tsx
@@ -23,7 +23,9 @@ import {
regionStatusTone,
} from '../../../components/Admin/paddle/paddleRegionsModel';
import { usePaddleRegionsAdmin } from '../../../components/Admin/paddle/usePaddleRegionsAdmin';
+import { useDateFormat } from '../../../hooks/useDateFormat';
import { useTranslation } from '../../../i18n';
+import { formatDisplayDate } from '../../../utils/dateFormat';
import MBadge from '../../components/MBadge';
import MChip from '../../components/MChip';
import MConfirmSheet from '../settings/MConfirmSheet';
@@ -111,6 +113,7 @@ function AutoLoad({ admin }: { admin: Admin }) {
function RequestRow({ request, admin }: { request: PaddleRegionPending; admin: Admin }) {
const { t, language } = useTranslation();
+ const dateFormat = useDateFormat();
const busy = admin.busyId === request.id;
return (