Browse Source

Show dates in the workshop's date format on meters, schedules, status reports, the portal and Reports (#685)

* Show dates in the workshop's date format on meters, schedules, status reports, the portal and Reports

* Name months in the customer's language and keep the workshop's clock through the viewer's DST gap
Bernt Christian Egeland 3 ngày trước cách đây
mục cha
commit
93bb6eadbd
52 tập tin đã thay đổi với 936 bổ sung và 454 xóa
  1. 32 18
      src/__tests__/app/vehicles/vehicle-job-warnings-feed.test.tsx
  2. 298 0
      src/__tests__/features/dates/workshop-date-format.test.tsx
  3. 28 6
      src/__tests__/features/inspection-reminders/booking-actions.test.ts
  4. 2 2
      src/__tests__/features/portal/chat-panel.test.tsx
  5. 1 0
      src/__tests__/features/portal/helpers/fixtures.ts
  6. 12 10
      src/__tests__/features/portal/home-colour.test.tsx
  7. 9 9
      src/__tests__/features/portal/home-daylight.test.tsx
  8. 10 10
      src/__tests__/features/portal/home-garage.test.tsx
  9. 7 7
      src/__tests__/features/portal/home-print.test.tsx
  10. 18 9
      src/__tests__/features/portal/portal-format.test.ts
  11. 10 9
      src/__tests__/features/portal/portal-lists.test.tsx
  12. 2 1
      src/__tests__/features/portal/portal-quote-page.test.tsx
  13. 9 4
      src/__tests__/features/reports/report-range-workshop-today.test.tsx
  14. 13 11
      src/__tests__/features/status-reports/report-day.test.tsx
  15. 1 1
      src/app/(authenticated)/(dashboard)/dashboard-client.tsx
  16. 25 7
      src/app/(authenticated)/reports/reports-client.tsx
  17. 4 12
      src/app/(authenticated)/settings/report-schedule/report-schedule-settings.tsx
  18. 3 1
      src/app/(authenticated)/settings/team/team-settings.tsx
  19. 5 14
      src/app/(authenticated)/vehicles/[id]/job-warning.tsx
  20. 5 3
      src/app/(authenticated)/vehicles/[id]/vehicle-activity-feed.tsx
  21. 4 5
      src/app/(public)/b/[token]/booking-client.tsx
  22. 5 4
      src/app/(public)/share/status-report/[orgId]/[token]/page.tsx
  23. 5 7
      src/app/api/v1/tech/jobs/[id]/notes/route.ts
  24. 4 3
      src/components/sent-copy-note.tsx
  25. 17 8
      src/components/ui/datetime-picker.tsx
  26. 23 11
      src/features/inspection-reminders/Actions/bookingActions.ts
  27. 8 2
      src/features/inspection-reminders/Lib/campaign.ts
  28. 8 0
      src/features/inspection-reminders/Lib/settings.ts
  29. 18 12
      src/features/integrations/Actions/videoCallActions.ts
  30. 17 6
      src/features/messaging/Components/EmailConversation.tsx
  31. 4 9
      src/features/messaging/Components/PortalConversation.tsx
  32. 4 5
      src/features/meters/Components/VehicleMeters.tsx
  33. 10 4
      src/features/portal/Components/Chat/PortalChatPanel.tsx
  34. 11 4
      src/features/portal/Components/Chat/chatThread.ts
  35. 1 1
      src/features/portal/Lib/homeTypes.ts
  36. 18 16
      src/features/portal/Lib/portalFormat.ts
  37. 9 14
      src/features/portal/Lib/workshop.server.ts
  38. 4 2
      src/features/settings/Components/license-settings.tsx
  39. 7 28
      src/features/status-reports/Components/StatusReportList.tsx
  40. 14 9
      src/features/status-reports/Lib/reportDay.ts
  41. 6 3
      src/features/telegram/Components/TelegramMessagesClient.tsx
  42. 4 1
      src/features/vehicles/Components/PlateLookupCommand.tsx
  43. 3 2
      src/features/vehicles/Components/ReminderFormDialog.tsx
  44. 5 8
      src/features/vehicles/Components/VehicleForm.tsx
  45. 18 38
      src/features/vehicles/Components/service-edit/ScheduleTimesSection.tsx
  46. 3 2
      src/features/vehicles/Components/service-page/ServicePageClient.tsx
  47. 0 2
      src/features/workboard/Components/JobDetailPopover.tsx
  48. 11 4
      src/features/workboard/Components/JobTooltip.tsx
  49. 14 10
      src/lib/cron/report-schedules.ts
  50. 135 100
      src/lib/format.ts
  51. 13 0
      src/lib/use-format-date.ts
  52. 39 0
      src/lib/workshop-timezone.ts

+ 32 - 18
src/__tests__/app/vehicles/vehicle-job-warnings-feed.test.tsx

@@ -4,8 +4,14 @@
  * work order's words. The row itself is the way into the job to fix it.
  */
 
-import { describe, expect, it } from 'vitest'
+import { describe, expect, it, vi } from 'vitest'
 import { render, screen, within } from '@testing-library/react'
+
+vi.mock('@/features/settings/Actions/timezoneActions', () => ({
+  adoptDetectedTimezone: vi.fn(async () => undefined),
+}))
+
+import { DateSettingsProvider } from '@/components/date-settings-context'
 import { TooltipProvider } from '@/components/ui/tooltip'
 import {
   type FeedWorkOrder,
@@ -70,22 +76,24 @@ function renderFeed(
   owed: Record<string, 'unpaid' | 'partial'> = {}
 ) {
   return render(
-    <TooltipProvider>
-      <VehicleActivityFeed
-        vehicleId="veh-1"
-        filter="all"
-        search=""
-        workOrders={workOrders}
-        quotes={[]}
-        inspections={[]}
-        distUnit="km"
-        readingLabel="Mileage"
-        currencyCode="NOK"
-        vehicleMileage={0}
-        jobWarnings={jobWarnings}
-        owed={owed}
-      />
-    </TooltipProvider>
+    <DateSettingsProvider dateFormat="dd/MM/yyyy" timeFormat="24h">
+      <TooltipProvider>
+        <VehicleActivityFeed
+          vehicleId="veh-1"
+          filter="all"
+          search=""
+          workOrders={workOrders}
+          quotes={[]}
+          inspections={[]}
+          distUnit="km"
+          readingLabel="Mileage"
+          currencyCode="NOK"
+          vehicleMileage={0}
+          jobWarnings={jobWarnings}
+          owed={owed}
+        />
+      </TooltipProvider>
+    </DateSettingsProvider>
   )
 }
 
@@ -94,6 +102,12 @@ const rowOf = (title: string) =>
   screen.getByRole('link', { name: title }).closest('li') as HTMLElement
 
 describe('the jobs table on the vehicle page', () => {
+  it("dates each job in the workshop's date format", () => {
+    renderFeed([])
+    expect(within(rowOf('Brake service')).getByText('16/11/2026')).toBeInTheDocument()
+    expect(within(rowOf('Oil change')).getByText('02/11/2026')).toBeInTheDocument()
+  })
+
   it('says what is wrong on the row of the job in the workshop', () => {
     renderFeed([
       warning({
@@ -112,7 +126,7 @@ describe('the jobs table on the vehicle page', () => {
 
     const row = rowOf('Brake service')
     expect(
-      within(row).getByText('Ola Nordmann: Away (On leave) · Nov 16 – Nov 17')
+      within(row).getByText('Ola Nordmann: Away (On leave) · 16/11/2026 – 17/11/2026')
     ).toBeInTheDocument()
     expect(within(row).getByText(/This booking needs attention/)).toBeInTheDocument()
     expect(within(row).getByRole('link', { name: 'Brake service' })).toHaveAttribute(

+ 298 - 0
src/__tests__/features/dates/workshop-date-format.test.tsx

@@ -0,0 +1,298 @@
+/**
+ * Dates read the way the workshop writes them (Settings, Localization), on
+ * the workshop's clock: a meter's last reading, a status report's day, the
+ * booked time in the schedule picker. They used to come out in the
+ * language's own form ("Nov 24, 2026", "November 25th, 2026 07:00") beside
+ * a "24/11/2026" on the same page.
+ *
+ * The browser here is far west of UTC and the workshop far east of it, so a
+ * date read on the wrong clock lands on the wrong day.
+ */
+import { render, screen } from '@testing-library/react'
+import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
+
+vi.mock('@/features/settings/Actions/timezoneActions', () => ({
+  adoptDetectedTimezone: vi.fn(async () => undefined),
+}))
+vi.mock('@/features/meters/Actions/vehicleMeterActions', () => ({
+  addMeterReading: vi.fn(),
+  addVehicleMeter: vi.fn(),
+  markMeterReadingWrong: vi.fn(),
+  removeVehicleMeter: vi.fn(),
+  replaceVehicleMeter: vi.fn(),
+}))
+vi.mock('@/features/equipment/Actions/equipmentItemActions', () => ({
+  addEquipmentMeter: vi.fn(),
+}))
+vi.mock('@/features/status-reports/Actions/deleteStatusReport', () => ({
+  deleteStatusReport: vi.fn(),
+}))
+vi.mock('@/features/status-reports/Components/CreateStatusReportDialog', () => ({
+  CreateStatusReportDialog: () => null,
+}))
+vi.mock('@/features/status-reports/Components/SendStatusReportDialog', () => ({
+  SendStatusReportDialog: () => null,
+}))
+vi.mock('next/navigation', () => ({ useRouter: () => ({ refresh: vi.fn(), push: vi.fn() }) }))
+vi.mock('sonner', () => ({ toast: { error: vi.fn(), success: vi.fn() } }))
+
+import { ConfirmProvider } from '@/components/confirm-dialog'
+import { DateSettingsProvider } from '@/components/date-settings-context'
+import { DateTimePicker } from '@/components/ui/datetime-picker'
+import { VehicleMeters } from '@/features/meters/Components/VehicleMeters'
+import { StatusReportList } from '@/features/status-reports/Components/StatusReportList'
+import { templateValues } from '@/features/inspection-reminders/Lib/campaign'
+import { buildPortalFormat } from '@/features/portal/Lib/portalFormat'
+import { formatReportDay } from '@/features/status-reports/Lib/reportDay'
+import { formatDate, formatDateTime, formatDayKey, formatTime } from '@/lib/format'
+
+const originalTz = process.env.TZ
+beforeAll(() => {
+  process.env.TZ = 'America/Los_Angeles'
+})
+afterAll(() => {
+  process.env.TZ = originalTz
+})
+
+// 08:30 on 25 November in Auckland; still 24 November in UTC and in Los Angeles.
+const MORNING_IN_AUCKLAND = '2026-11-24T19:30:00.000Z'
+
+function inWorkshop(dateFormat: string, children: React.ReactNode) {
+  return render(
+    <DateSettingsProvider dateFormat={dateFormat} timeFormat="24h" timezone="Pacific/Auckland">
+      <ConfirmProvider>{children}</ConfirmProvider>
+    </DateSettingsProvider>
+  )
+}
+
+const meters = () => (
+  <VehicleMeters
+    vehicleId="veh-1"
+    types={[{ id: 'mt-1', name: 'Engine hours', unit: 'hrs' }]}
+    meters={[
+      {
+        id: 'm-1',
+        meterTypeId: 'mt-1',
+        name: 'Engine hours',
+        unit: 'hrs',
+        current: 1250,
+        currentAt: MORNING_IN_AUCKLAND,
+        total: 1250,
+        replaced: false,
+        readings: [],
+      },
+    ]}
+  />
+)
+
+describe("a meter's last reading", () => {
+  it("is dated on the workshop's day in its date format", () => {
+    inWorkshop('dd/MM/yyyy', meters())
+    expect(screen.getByText(/Read 25\/11\/2026/)).toBeInTheDocument()
+    expect(screen.queryByText(/Nov/)).not.toBeInTheDocument()
+  })
+
+  it('follows another format the workshop chose', () => {
+    inWorkshop('MM/dd/yyyy', meters())
+    expect(screen.getByText(/Read 11\/25\/2026/)).toBeInTheDocument()
+  })
+})
+
+const reports = () => (
+  <StatusReportList
+    serviceRecordId="sr-1"
+    organizationId="org-1"
+    vehicleName="Volvo V60"
+    customer={null}
+    smsEnabled={false}
+    emailEnabled={false}
+    telegramEnabled={false}
+    initialReports={[
+      {
+        id: 'r-1',
+        title: 'Brake pads',
+        message: null,
+        status: 'sent',
+        videoUrl: null,
+        createdAt: MORNING_IN_AUCKLAND,
+        expiresAt: null,
+        publicToken: 'tok',
+        customerFeedback: null,
+        feedbackAt: null,
+        sentVia: 'sms',
+        sentAt: MORNING_IN_AUCKLAND,
+      },
+    ]}
+  />
+)
+
+describe("a work order's status reports", () => {
+  it("are listed with the workshop's day and clock", () => {
+    inWorkshop('dd/MM/yyyy', reports())
+    expect(screen.getAllByText('25/11/2026 08:30').length).toBeGreaterThan(0)
+  })
+
+  it('follow another format the workshop chose', () => {
+    inWorkshop('yyyy-MM-dd', reports())
+    expect(screen.getAllByText('2026-11-25 08:30').length).toBeGreaterThan(0)
+  })
+})
+
+describe('the date and time picker', () => {
+  const picker = () => (
+    <DateTimePicker
+      value={new Date(MORNING_IN_AUCKLAND)}
+      timeZone="Pacific/Auckland"
+      granularity="minute"
+      hourCycle={24}
+    />
+  )
+
+  it("shows the booked time in the workshop's date format on its clock", () => {
+    inWorkshop('dd/MM/yyyy', picker())
+    expect(screen.getByRole('button', { name: '25/11/2026 08:30' })).toBeInTheDocument()
+  })
+
+  it('follows another format the workshop chose', () => {
+    inWorkshop('MM/dd/yyyy', picker())
+    expect(screen.getByRole('button', { name: '11/25/2026 08:30' })).toBeInTheDocument()
+  })
+})
+
+describe('the due date in an inspection reminder the customer receives', () => {
+  const values = (dateFormat: string) =>
+    templateValues({
+      candidate: {
+        vehicleId: 'v-1',
+        customerId: 'c-1',
+        customerName: 'Kari',
+        vehicle: 'Volvo V60',
+        licensePlate: 'EV11223',
+        // Midnight on 1 December in Auckland, still 30 November in UTC.
+        dueAt: '2026-11-30T11:00:00.000Z',
+        recipient: '+64 21 000 000',
+        overdue: false,
+        excluded: null,
+        lastRemindedAt: null,
+      },
+      settings: {
+        durationMinutes: 60,
+        leadDays: 1,
+        horizonWeeks: 4,
+        walkInReserve: 0,
+        linkValidDays: 7,
+        bookingMode: 'direct',
+        phone: null,
+        workshopName: 'Harbour Motors',
+        templateSms: null,
+        templateEmailSubject: null,
+        templateEmailBody: null,
+        workingHours: {
+          start: '08:00',
+          end: '16:00',
+          includeWeekends: false,
+          timeZone: 'Pacific/Auckland',
+        },
+        timeZone: 'Pacific/Auckland',
+        timeZoneDetected: false,
+        dateFormat,
+      },
+      link: 'https://example.test/b/tok',
+      locale: 'en',
+    }).dueDate
+
+  it("is the workshop's day in its date format", () => {
+    expect(values('dd/MM/yyyy')).toBe('01/12/2026')
+    expect(values('MM/dd/yyyy')).toBe('12/01/2026')
+  })
+})
+
+describe('a workshop format that spells the month', () => {
+  // 22:30 UTC on 30 November: already 1 December in Auckland.
+  const MADE = new Date('2026-11-30T22:30:00Z')
+
+  it("names the month in the customer's language, not in English", () => {
+    expect(formatDate(MADE, 'd MMMM yyyy', 'Europe/Oslo', 'nb')).toBe('30 november 2026')
+    expect(formatDate(MADE, 'd MMMM yyyy', 'Pacific/Auckland', 'nb')).toBe('1 desember 2026')
+    expect(formatDate(MADE, 'd MMMM yyyy', 'Pacific/Auckland', 'de')).toBe('1 Dezember 2026')
+    expect(formatDayKey('2026-05-17', 'd MMMM yyyy', 'nb')).toBe('17 mai 2026')
+  })
+
+  it('keeps the English names the app has always used when no language is given', () => {
+    expect(formatDate(MADE, 'MMM d, yyyy', 'Pacific/Auckland')).toBe('Dec 1, 2026')
+    expect(formatDate(MADE, 'd MMMM yyyy', 'Pacific/Auckland')).toBe('1 December 2026')
+  })
+
+  it('reaches the status report share page and the portal in that language', () => {
+    expect(formatReportDay(MADE, 'd MMMM yyyy', 'Pacific/Auckland', 'nb')).toBe('1 desember 2026')
+    const portal = buildPortalFormat({
+      locale: 'nb',
+      timeZone: 'Pacific/Auckland',
+      timeFormat: '24h',
+      dateFormat: 'd MMMM yyyy',
+      money: (amount) => `${amount} kr`,
+      today: 'i dag',
+      tomorrow: 'i morgen',
+      now: new Date('2026-11-01T00:00:00Z'),
+    })
+    expect(portal.day(MADE.toISOString())).toBe('1 desember 2026')
+  })
+})
+
+describe("a time that falls in the viewer's own DST gap", () => {
+  // 02:30 on 8 March in Auckland. Los Angeles, where this browser is, springs
+  // forward at 02:00 that same morning, so 02:30 does not exist there.
+  const IN_THE_GAP = '2026-03-07T13:30:00.000Z'
+
+  it("is still the workshop's 02:30", () => {
+    expect(formatDateTime(IN_THE_GAP, 'dd/MM/yyyy', '24h', 'Pacific/Auckland')).toBe(
+      '08/03/2026 02:30'
+    )
+    expect(formatTime(IN_THE_GAP, '24h', 'Pacific/Auckland')).toBe('02:30')
+    expect(formatTime(IN_THE_GAP, '12h', 'Pacific/Auckland')).toBe('02:30 AM')
+  })
+
+  it('reads 02:30 in the list of status reports', () => {
+    inWorkshop(
+      'dd/MM/yyyy',
+      <StatusReportList
+        serviceRecordId="sr-1"
+        organizationId="org-1"
+        vehicleName="Volvo V60"
+        customer={null}
+        smsEnabled={false}
+        emailEnabled={false}
+        telegramEnabled={false}
+        initialReports={[
+          {
+            id: 'r-2',
+            title: 'Night check',
+            message: null,
+            status: 'sent',
+            videoUrl: null,
+            createdAt: IN_THE_GAP,
+            expiresAt: null,
+            publicToken: 'tok2',
+            customerFeedback: null,
+            feedbackAt: null,
+            sentVia: 'sms',
+            sentAt: IN_THE_GAP,
+          },
+        ]}
+      />
+    )
+    expect(screen.getAllByText('08/03/2026 02:30').length).toBeGreaterThan(0)
+  })
+})
+
+describe('a calendar day key', () => {
+  it('is the same day in any format, on any clock', () => {
+    expect(formatDayKey('2026-11-25', 'dd/MM/yyyy')).toBe('25/11/2026')
+    expect(formatDayKey('2026-11-25', 'MM/dd/yyyy')).toBe('11/25/2026')
+    expect(formatDayKey('2026-01-01', 'd. MMM yyyy')).toBe('1. Jan 2026')
+  })
+
+  it('leaves anything that is not a day key as it is', () => {
+    expect(formatDayKey('soon', 'dd/MM/yyyy')).toBe('soon')
+  })
+})

+ 28 - 6
src/__tests__/features/inspection-reminders/booking-actions.test.ts

@@ -1,4 +1,5 @@
 import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { formatDateTime } from '@/lib/format'
 
 const inspectionReminderSend = { findUnique: vi.fn(), update: vi.fn() }
 const serviceRecord = {
@@ -42,6 +43,7 @@ vi.mock('@/lib/notify', () => ({ notify }))
 vi.mock('next-intl/server', () => ({
   getTranslations: async () => (key: string, values?: Record<string, unknown>) =>
     `${key}${values ? ` ${JSON.stringify(values)}` : ''}`,
+  getLocale: async () => 'en',
 }))
 const claimableResource = vi.fn()
 vi.mock('@/features/inspection-reminders/Lib/booking', () => ({
@@ -67,6 +69,8 @@ const settings = {
   workingHours: { start: '08:00', end: '16:00', includeWeekends: false, timeZone: 'Europe/Oslo' },
   timeZone: 'Europe/Oslo',
   timeZoneDetected: false,
+  dateFormat: 'dd/MM/yyyy',
+  timeFormat: '24h' as '12h' | '24h',
 }
 vi.mock('@/features/inspection-reminders/Lib/settings', () => ({
   loadInspectionReminderSettings: vi.fn(async () => settings),
@@ -113,6 +117,8 @@ beforeEach(() => {
   vi.clearAllMocks()
   settings.bookingMode = 'direct'
   settings.timeZone = 'Europe/Oslo'
+  settings.dateFormat = 'dd/MM/yyyy'
+  settings.timeFormat = '24h'
   appSetting.findUnique.mockResolvedValue(null)
   serviceRecord.create.mockResolvedValue({ id: 'rec-1', vehicleId: 'v-1' })
   serviceRequest.create.mockResolvedValue({ id: 'req-1' })
@@ -165,12 +171,7 @@ describe('booking link', () => {
 
   it('tells the desk and the customer the booked time on the workshop clock, not the server clock', async () => {
     const slot = new Date('2026-12-02T07:00:00Z')
-    const format = (timeZone?: string) =>
-      new Intl.DateTimeFormat(undefined, {
-        dateStyle: 'medium',
-        timeStyle: 'short',
-        timeZone,
-      }).format(slot)
+    const format = (timeZone?: string) => formatDateTime(slot, 'dd/MM/yyyy', '24h', timeZone)
     // A workshop whose clock reads differently from the machine running the
     // tests, wherever that is: no two of these agree at this hour, so at
     // least one is not the host's, and the test never passes by coincidence.
@@ -194,6 +195,27 @@ describe('booking link', () => {
     expect(scheduledMessage.create.mock.calls[0][0].data.body).toContain(onWorkshopClock)
   })
 
+  it("writes the booked time in the workshop's date format and clock", async () => {
+    // 07:00 UTC on 2 December is 20:00 that evening in Auckland.
+    const slot = new Date('2026-12-02T07:00:00Z')
+    settings.timeZone = 'Pacific/Auckland'
+    inspectionReminderSend.findUnique.mockResolvedValue(
+      send({ dueAt: new Date('2026-12-20T00:00:00Z'), expiresAt: new Date('2026-12-30T00:00:00Z') })
+    )
+    vi.setSystemTime(new Date('2026-11-20T00:00:00Z'))
+    try {
+      await confirmBooking({ token: TOKEN, start: slot.toISOString() })
+      settings.dateFormat = 'MM/dd/yyyy'
+      settings.timeFormat = '12h'
+      await confirmBooking({ token: TOKEN, start: slot.toISOString() })
+    } finally {
+      vi.useRealTimers()
+    }
+    const bodies = scheduledMessage.create.mock.calls.map((call) => call[0].data.body as string)
+    expect(bodies[0]).toContain('02/12/2026 20:00')
+    expect(bodies[1]).toContain('12/02/2026 08:00 PM')
+  })
+
   it('refuses a slot that was taken in the meantime', async () => {
     inspectionReminderSend.findUnique.mockResolvedValue(send())
     claimableResource.mockResolvedValue(null)

+ 2 - 2
src/__tests__/features/portal/chat-panel.test.tsx

@@ -123,7 +123,7 @@ function panel(
         enabled={options.enabled ?? true}
         initialMessages={messages}
         initialEvents={options.events}
-        clock={{ timeZone: 'Europe/Oslo', timeFormat: '24h' }}
+        clock={{ timeZone: 'Europe/Oslo', timeFormat: '24h', dateFormat: 'dd/MM/yyyy' }}
         stamps={options.stamps}
       />
     </QueryClientProvider>
@@ -549,7 +549,7 @@ describe('when things happened', () => {
       ],
     })
     const line = thread().getByRole('link', { name: /Invoice INV-2041/ })
-    expect(within(line).getByText('Nov 11')).toBeInTheDocument()
+    expect(within(line).getByText('11/11/2026')).toBeInTheDocument()
     expect(line).not.toHaveTextContent('00:00')
   })
 

+ 1 - 0
src/__tests__/features/portal/helpers/fixtures.ts

@@ -29,6 +29,7 @@ export const format: PortalHomeFormat = buildPortalFormat({
   locale: 'en-GB',
   timeZone: 'Europe/Oslo',
   timeFormat: '24h',
+  dateFormat: 'dd/MM/yyyy',
   money: (amount) => `${new Intl.NumberFormat('en-GB').format(amount).replace(/,/g, ' ')} kr`,
   today: 'today',
   tomorrow: 'tomorrow',

+ 12 - 10
src/__tests__/features/portal/home-colour.test.tsx

@@ -147,7 +147,7 @@ describe('the car in the workshop', () => {
     })
     const other = section('Also booked or under way')
     expect(other.getByText('Wheel alignment')).toBeInTheDocument()
-    expect(other.getByText('Volvo V60 · Booked for 20 Nov at 09:00')).toBeInTheDocument()
+    expect(other.getByText('Volvo V60 · Booked for 20/11/2026 at 09:00')).toBeInTheDocument()
   })
 
   it('keeps a long job title and a car without a plate in full', async () => {
@@ -175,7 +175,7 @@ describe('what needs an answer', () => {
     const quote = section('Needs your answer')
     expect(quote.getByText('Front discs and pads')).toBeInTheDocument()
     expect(quote.getByText('4 850 kr')).toBeInTheDocument()
-    expect(quote.getByText('Valid until 29 Nov')).toBeInTheDocument()
+    expect(quote.getByText('Valid until 29/11/2026')).toBeInTheDocument()
     expect(quote.getByText('Quote Q-2041 · Volvo V60')).toBeInTheDocument()
     expect(quote.getByRole('link', { name: 'Read the quote' })).toHaveAttribute(
       'href',
@@ -230,8 +230,8 @@ describe('what there is to pay', () => {
     const pay = section('To pay')
     expect(pay.getByText('EU inspection and service')).toBeInTheDocument()
     expect(pay.getByText('4 280 kr')).toBeInTheDocument()
-    expect(pay.getByText('Due 28 Nov')).toBeInTheDocument()
-    expect(pay.getByText('Invoice 1042 · Toyota RAV4 · 9 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Due 28/11/2026')).toBeInTheDocument()
+    expect(pay.getByText('Invoice 1042 · Toyota RAV4 · 09/11/2026')).toBeInTheDocument()
     expect(pay.getByRole('link', { name: 'Pay now' })).toHaveAttribute(
       'href',
       '/share/invoice/fjordside/tok-i1'
@@ -266,7 +266,7 @@ describe('what there is to pay', () => {
       toPayOverdueCount: 1,
     })
     const pay = section('To pay')
-    expect(pay.getByText('Overdue since 10 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Overdue since 10/11/2026')).toBeInTheDocument()
     expect(pay.queryByText(/^Due /)).not.toBeInTheDocument()
     expect(pay.getByText('3 280 kr')).toBeInTheDocument()
     expect(pay.getByText('1 000 kr of 4 280 kr paid')).toBeInTheDocument()
@@ -291,7 +291,7 @@ describe('what there is to pay', () => {
     expect(pay.getByText('Most urgent')).toBeInTheDocument()
     expect(pay.getByText('EU inspection and service')).toBeInTheDocument()
     expect(pay.getByText('4 280 kr')).toBeInTheDocument()
-    expect(pay.getByText('Overdue since 10 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Overdue since 10/11/2026')).toBeInTheDocument()
     expect(pay.queryByText('Tyre change')).not.toBeInTheDocument()
     expect(pay.getByRole('link', { name: 'Pay now' })).toHaveAttribute(
       'href',
@@ -315,7 +315,7 @@ describe('what there is to pay', () => {
     expect(pay.getByText('8 560 kr')).toBeInTheDocument()
     expect(pay.getByText('2 invoices')).toBeInTheDocument()
     expect(pay.getByText('Next to pay')).toBeInTheDocument()
-    expect(pay.getByText('Due 28 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Due 28/11/2026')).toBeInTheDocument()
     expect(pay.queryByText(/overdue/i)).not.toBeInTheDocument()
   })
 })
@@ -360,7 +360,7 @@ describe('tyres stored with the workshop', () => {
       within(tires.getByText('tread left').closest('div') as HTMLElement).getByText('5 mm')
     ).toBeInTheDocument()
     expect(
-      within(tires.getByText('Stored since').closest('div') as HTMLElement).getByText('21 Oct')
+      within(tires.getByText('Stored since').closest('div') as HTMLElement).getByText('21/10/2026')
     ).toBeInTheDocument()
   })
 
@@ -387,7 +387,9 @@ describe('tyres stored with the workshop', () => {
     expect(tires.getByText('Tread not measured yet')).toBeInTheDocument()
     expect(tires.queryByText('Stored since')).not.toBeInTheDocument()
     expect(tires.getByText('Winter tyres')).toBeInTheDocument()
-    expect(tires.getByText(/studded · stored since 21 Oct · 6.5 mm tread left/)).toBeInTheDocument()
+    expect(
+      tires.getByText(/studded · stored since 21\/10\/2026 · 6.5 mm tread left/)
+    ).toBeInTheDocument()
   })
 })
 
@@ -476,7 +478,7 @@ describe('a customer with no car in the workshop', () => {
     })
     const sent = section('Sent to the workshop')
     expect(sent.getByText('Winter tyres on, and a look at the wipers')).toBeInTheDocument()
-    expect(sent.getByText('Sent 12 Nov · Waiting for an answer')).toBeInTheDocument()
+    expect(sent.getByText('Sent 12/11/2026 · Waiting for an answer')).toBeInTheDocument()
   })
 
   it('offers no way to change how the portal looks', async () => {

+ 9 - 9
src/__tests__/features/portal/home-daylight.test.tsx

@@ -164,7 +164,7 @@ describe('the car in the workshop', () => {
     })
     const other = section('Also booked or under way')
     expect(other.getByText('Wheel alignment')).toBeInTheDocument()
-    expect(other.getByText('Volvo V60 · Booked for 20 Nov at 09:00')).toBeInTheDocument()
+    expect(other.getByText('Volvo V60 · Booked for 20/11/2026 at 09:00')).toBeInTheDocument()
   })
 })
 
@@ -174,7 +174,7 @@ describe('what needs an answer', () => {
     const quote = section('Needs your answer')
     expect(quote.getByText('Front discs and pads')).toBeInTheDocument()
     expect(quote.getByText('4 850 kr')).toBeInTheDocument()
-    expect(quote.getByText('Valid until 29 Nov')).toBeInTheDocument()
+    expect(quote.getByText('Valid until 29/11/2026')).toBeInTheDocument()
     expect(quote.getByText('Quote Q-2041 · Volvo V60')).toBeInTheDocument()
     expect(quote.getByRole('link', { name: 'Read the quote' })).toHaveAttribute(
       'href',
@@ -229,8 +229,8 @@ describe('what there is to pay', () => {
     const pay = section('To pay')
     expect(pay.getByText('EU inspection and service')).toBeInTheDocument()
     expect(pay.getByText('4 280 kr')).toBeInTheDocument()
-    expect(pay.getByText('Due 28 Nov')).toBeInTheDocument()
-    expect(pay.getByText('Invoice 1042 · Toyota RAV4 · 9 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Due 28/11/2026')).toBeInTheDocument()
+    expect(pay.getByText('Invoice 1042 · Toyota RAV4 · 09/11/2026')).toBeInTheDocument()
     expect(pay.getByRole('link', { name: 'Pay now' })).toHaveAttribute(
       'href',
       '/share/invoice/fjordside/tok-i1'
@@ -264,7 +264,7 @@ describe('what there is to pay', () => {
       toPayOverdueCount: 1,
     })
     const pay = section('To pay')
-    expect(pay.getByText('Overdue since 10 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Overdue since 10/11/2026')).toBeInTheDocument()
     expect(pay.getByText('3 280 kr')).toBeInTheDocument()
     expect(pay.getByText(/1 000 kr of 4 280 kr paid/)).toBeInTheDocument()
     expect(pay.queryByRole('link', { name: /See all/ })).not.toBeInTheDocument()
@@ -290,7 +290,7 @@ describe('what there is to pay', () => {
     expect(pay.getByText('Most urgent')).toBeInTheDocument()
     expect(pay.getByText('EU inspection and service')).toBeInTheDocument()
     expect(pay.getByText('3 280 kr')).toBeInTheDocument()
-    expect(pay.getByText('Overdue since 10 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Overdue since 10/11/2026')).toBeInTheDocument()
     expect(pay.getAllByRole('link', { name: 'Pay now' })).toHaveLength(1)
     expect(pay.getByRole('link', { name: 'See all 11 invoices' })).toHaveAttribute(
       'href',
@@ -308,7 +308,7 @@ describe('what there is to pay', () => {
     })
     const pay = section('To pay')
     expect(pay.getByText('Next to pay')).toBeInTheDocument()
-    expect(pay.getByText('Due 28 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Due 28/11/2026')).toBeInTheDocument()
     expect(pay.queryByText(/overdue/i)).not.toBeInTheDocument()
   })
 })
@@ -348,7 +348,7 @@ describe('tyres stored with the workshop', () => {
     const tires = section('Tyre hotel')
     expect(tires.getByText('Summer tyres stored with us')).toBeInTheDocument()
     expect(tires.getByText(/Toyota RAV4 · Michelin Primacy 4/)).toBeInTheDocument()
-    expect(tires.getByText(/225\/60 R18 · stored since 21 Oct/)).toBeInTheDocument()
+    expect(tires.getByText(/225\/60 R18 · stored since 21\/10\/2026/)).toBeInTheDocument()
     expect(tires.getByText('5 mm')).toBeInTheDocument()
     expect(tires.getByText('tread left')).toBeInTheDocument()
   })
@@ -449,6 +449,6 @@ describe('a customer with nothing going on', () => {
     })
     const sent = section('Sent to the workshop')
     expect(sent.getByText('Winter tyres on, and a look at the wipers')).toBeInTheDocument()
-    expect(sent.getByText('Sent 12 Nov · Waiting for an answer')).toBeInTheDocument()
+    expect(sent.getByText('Sent 12/11/2026 · Waiting for an answer')).toBeInTheDocument()
   })
 })

+ 10 - 10
src/__tests__/features/portal/home-garage.test.tsx

@@ -173,7 +173,7 @@ describe('the car in the workshop', () => {
     })
     const other = section('Also booked or under way')
     expect(other.getByText('Wheel alignment')).toBeInTheDocument()
-    expect(other.getByText('Volvo V60 · Booked for 20 Nov at 09:00')).toBeInTheDocument()
+    expect(other.getByText('Volvo V60 · Booked for 20/11/2026 at 09:00')).toBeInTheDocument()
     expect(other.getByRole('link', { name: /Wheel alignment/ })).toHaveAttribute(
       'href',
       '/portal/fjordside/vehicles/v60'
@@ -204,7 +204,7 @@ describe('what needs an answer', () => {
     expect(quote.getByText('Front discs and pads')).toBeInTheDocument()
     expect(quote.getByText('4 850 kr')).toBeInTheDocument()
     expect(quote.getByText('Quote Q-2041')).toBeInTheDocument()
-    expect(quote.getByText('Volvo V60 · Valid until 29 Nov')).toBeInTheDocument()
+    expect(quote.getByText('Volvo V60 · Valid until 29/11/2026')).toBeInTheDocument()
     expect(quote.getByRole('link', { name: 'Read the quote' })).toHaveAttribute(
       'href',
       '/portal/fjordside/quotes/q1'
@@ -258,8 +258,8 @@ describe('what there is to pay', () => {
     const pay = section('To pay')
     expect(pay.getByText('EU inspection and service')).toBeInTheDocument()
     expect(pay.getByText('4 280 kr')).toBeInTheDocument()
-    expect(pay.getByText('Invoice 1042 · 9 Nov')).toBeInTheDocument()
-    expect(pay.getByText('Toyota RAV4 · Due 28 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Invoice 1042 · 09/11/2026')).toBeInTheDocument()
+    expect(pay.getByText('Toyota RAV4 · Due 28/11/2026')).toBeInTheDocument()
     expect(pay.getByRole('link', { name: 'Pay now' })).toHaveAttribute(
       'href',
       '/share/invoice/fjordside/tok-i1'
@@ -293,8 +293,8 @@ describe('what there is to pay', () => {
       toPayOverdueCount: 1,
     })
     const pay = section('To pay')
-    expect(pay.getByText('Overdue since 10 Nov')).toBeInTheDocument()
-    expect(pay.queryByText(/Due 10 Nov/)).not.toBeInTheDocument()
+    expect(pay.getByText('Overdue since 10/11/2026')).toBeInTheDocument()
+    expect(pay.queryByText(/Due 10\/11\/2026/)).not.toBeInTheDocument()
     expect(pay.getByText('3 280 kr')).toBeInTheDocument()
     expect(pay.getByText(/1 000 kr of 4 280 kr paid/)).toBeInTheDocument()
     expect(pay.queryByRole('link', { name: /See all/ })).not.toBeInTheDocument()
@@ -319,7 +319,7 @@ describe('what there is to pay', () => {
     expect(pay.getByText('Most urgent')).toBeInTheDocument()
     expect(pay.getByText('EU inspection and service')).toBeInTheDocument()
     expect(pay.getByText('3 280 kr')).toBeInTheDocument()
-    expect(pay.getByText('Overdue since 10 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Overdue since 10/11/2026')).toBeInTheDocument()
     expect(
       pay.getByText(/Invoice 1042 · Toyota RAV4 · 1 000 kr of 4 280 kr paid/)
     ).toBeInTheDocument()
@@ -345,7 +345,7 @@ describe('what there is to pay', () => {
     const pay = section('To pay')
     expect(pay.getByText('4 780 kr')).toBeInTheDocument()
     expect(pay.getByText('Next to pay')).toBeInTheDocument()
-    expect(pay.getByText(/Due 28 Nov/)).toBeInTheDocument()
+    expect(pay.getByText(/Due 28\/11\/2026/)).toBeInTheDocument()
     expect(pay.queryByText(/overdue/i)).not.toBeInTheDocument()
   })
 
@@ -390,7 +390,7 @@ describe('tyres stored with the workshop', () => {
     await home(fullHome)
     const tires = section('Tyre hotel')
     expect(tires.getByText('Summer tyres stored with us')).toBeInTheDocument()
-    expect(tires.getByText('stored since 21 Oct')).toBeInTheDocument()
+    expect(tires.getByText('stored since 21/10/2026')).toBeInTheDocument()
     expect(spec(tires, 'Car')).toHaveTextContent('Toyota RAV4')
     expect(spec(tires, 'Tyres')).toHaveTextContent('Michelin Primacy 4')
     expect(spec(tires, 'Size')).toHaveTextContent('225/60 R18')
@@ -523,7 +523,7 @@ describe('a customer with no car in the workshop', () => {
     })
     const sent = section('Sent to the workshop')
     expect(sent.getByText('Winter tyres on, and a look at the wipers')).toBeInTheDocument()
-    expect(sent.getByText('Sent 12 Nov · Waiting for an answer')).toBeInTheDocument()
+    expect(sent.getByText('Sent 12/11/2026 · Waiting for an answer')).toBeInTheDocument()
   })
 })
 

+ 7 - 7
src/__tests__/features/portal/home-print.test.tsx

@@ -181,7 +181,7 @@ describe('the car in the workshop', () => {
     })
     const other = section('Also booked or under way')
     expect(other.getByText('Wheel alignment')).toBeInTheDocument()
-    expect(other.getByText('Volvo V60 · Booked for 20 Nov at 09:00')).toBeInTheDocument()
+    expect(other.getByText('Volvo V60 · Booked for 20/11/2026 at 09:00')).toBeInTheDocument()
   })
 
   it('prints a long job title and a long workshop name in full', async () => {
@@ -211,7 +211,7 @@ describe('the ledger of what waits for the customer', () => {
     const quote = ledgerRow('Front discs and pads')
     expect(quote.getByText('Needs your answer')).toBeInTheDocument()
     expect(quote.getByText('4 850 kr')).toBeInTheDocument()
-    expect(quote.getByText('Valid until 29 Nov')).toBeInTheDocument()
+    expect(quote.getByText('Valid until 29/11/2026')).toBeInTheDocument()
     expect(quote.getByText('Quote Q-2041 · Volvo V60')).toBeInTheDocument()
     expect(quote.getByRole('link', { name: 'Read the quote' })).toHaveAttribute(
       'href',
@@ -254,8 +254,8 @@ describe('the ledger of what waits for the customer', () => {
     const pay = ledgerRow('EU inspection and service')
     expect(pay.getByText('To pay')).toBeInTheDocument()
     expect(pay.getByText('4 280 kr')).toBeInTheDocument()
-    expect(pay.getByText('Due 28 Nov')).toBeInTheDocument()
-    expect(pay.getByText('Invoice 1042 · Toyota RAV4 · 9 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Due 28/11/2026')).toBeInTheDocument()
+    expect(pay.getByText('Invoice 1042 · Toyota RAV4 · 09/11/2026')).toBeInTheDocument()
     expect(pay.getByRole('link', { name: 'Pay now' })).toHaveAttribute(
       'href',
       '/share/invoice/fjordside/tok-i1'
@@ -292,7 +292,7 @@ describe('the ledger of what waits for the customer', () => {
       section('Waiting for you').getByText('2 items · 3 280 kr to pay on 1 invoice · 1 overdue')
     ).toBeInTheDocument()
     const pay = ledgerRow('EU inspection and service')
-    expect(pay.getByText('Overdue since 10 Nov')).toBeInTheDocument()
+    expect(pay.getByText('Overdue since 10/11/2026')).toBeInTheDocument()
     expect(pay.getByText('3 280 kr')).toBeInTheDocument()
     expect(pay.getByText(/1 000 kr of 4 280 kr paid/)).toBeInTheDocument()
   })
@@ -373,7 +373,7 @@ describe('tyres stored with the workshop', () => {
     await home(fullHome)
     const tires = section('Tyre hotel')
     expect(tires.getByText('Summer tyres stored with us')).toBeInTheDocument()
-    expect(tires.getByText('stored since 21 Oct')).toBeInTheDocument()
+    expect(tires.getByText('stored since 21/10/2026')).toBeInTheDocument()
     const fact = (label: string) => tires.getByText(label).nextElementSibling
     expect(fact('Car')).toHaveTextContent('Toyota RAV4')
     expect(fact('Tyre')).toHaveTextContent('Michelin Primacy 4')
@@ -499,7 +499,7 @@ describe('a customer with no car in the workshop', () => {
     })
     const sent = section('Sent to the workshop')
     expect(sent.getByText('Winter tyres on, and a look at the wipers')).toBeInTheDocument()
-    expect(sent.getByText('Sent 12 Nov · Waiting for an answer')).toBeInTheDocument()
+    expect(sent.getByText('Sent 12/11/2026 · Waiting for an answer')).toBeInTheDocument()
   })
 })
 

+ 18 - 9
src/__tests__/features/portal/portal-format.test.ts

@@ -10,11 +10,12 @@ import { buildPortalFormat } from '@/features/portal/Lib/portalFormat'
 // 18 Nov 2026, 11:00 in Auckland; still 17 Nov in UTC.
 const now = new Date('2026-11-17T22:00:00Z')
 
-const make = (locale: string, timeFormat: '12h' | '24h') =>
+const make = (locale: string, timeFormat: '12h' | '24h', dateFormat = 'dd/MM/yyyy') =>
   buildPortalFormat({
     locale,
     timeZone: 'Pacific/Auckland',
     timeFormat,
+    dateFormat,
     money: (amount) => `${amount} kr`,
     today: locale === 'nb' ? 'i dag' : 'today',
     tomorrow: locale === 'nb' ? 'i morgen' : 'tomorrow',
@@ -34,9 +35,17 @@ describe('portal dates and times, en-GB', () => {
   const f24 = make('en-GB', '24h')
   const f12 = make('en-GB', '12h')
 
-  it('prints the day on the workshop calendar, with the year only when it is not this one', () => {
-    expect(f24.day(later)).toBe('3 Dec')
-    expect(f24.day(nextYear)).toBe('4 Feb 2027')
+  it("prints the day on the workshop calendar in the workshop's date format", () => {
+    expect(f24.day(later)).toBe('03/12/2026')
+    expect(f24.day(nextYear)).toBe('04/02/2027')
+    // Still 17 Nov in UTC, already 18 Nov in Auckland.
+    expect(f24.day(morning)).toBe('18/11/2026')
+  })
+
+  it('follows another date format the workshop chose', () => {
+    const us = make('en-GB', '24h', 'MM/dd/yyyy')
+    expect(us.day(later)).toBe('12/03/2026')
+    expect(us.relativeDay(later)).toBe('12/03/2026')
   })
 
   it('prints the long day with its weekday', () => {
@@ -56,7 +65,7 @@ describe('portal dates and times, en-GB', () => {
   it('names today and tomorrow on the workshop calendar, and any other day by date', () => {
     expect(f24.relativeDay(morning)).toBe('today')
     expect(f24.relativeDay(tomorrowAfternoon)).toBe('tomorrow')
-    expect(f24.relativeDay(later)).toBe('3 Dec')
+    expect(f24.relativeDay(later)).toBe('03/12/2026')
   })
 
   it('prints a bare opening time as it stands, in either clock', () => {
@@ -70,9 +79,8 @@ describe('portal dates and times, en-GB', () => {
 describe('portal dates and times, Norwegian', () => {
   const f24 = make('nb', '24h')
 
-  it('prints the day in Norwegian', () => {
-    expect(f24.day(later)).toBe('3. des.')
-    expect(f24.day(nextYear)).toBe('4. feb. 2027')
+  it('prints the long day in Norwegian and the day in the workshop format', () => {
+    expect(f24.day(later)).toBe('03/12/2026')
     expect(f24.dayLong(later)).toBe('torsdag 3. desember')
   })
 
@@ -84,7 +92,7 @@ describe('portal dates and times, Norwegian', () => {
   it('names today and tomorrow in the portal language', () => {
     expect(f24.relativeDay(morning)).toBe('i dag')
     expect(f24.relativeDay(tomorrowAfternoon)).toBe('i morgen')
-    expect(f24.relativeDay(later)).toBe('3. des.')
+    expect(f24.relativeDay(later)).toBe('03/12/2026')
   })
 })
 
@@ -92,6 +100,7 @@ describe('tread depth', () => {
   const base = {
     timeZone: 'Pacific/Auckland',
     timeFormat: '24h' as const,
+    dateFormat: 'dd/MM/yyyy',
     money: (amount: number) => `${amount} kr`,
     today: 'today',
     tomorrow: 'tomorrow',

+ 10 - 9
src/__tests__/features/portal/portal-lists.test.tsx

@@ -65,6 +65,7 @@ vi.mock('@/features/portal/Lib/portalFormat', async () => {
         locale: 'nb',
         timeZone: 'Europe/Oslo',
         timeFormat: '24h',
+        dateFormat: 'dd/MM/yyyy',
         money: (n) => `kr ${n.toFixed(2)}`,
         today: 'i dag',
         tomorrow: 'i morgen',
@@ -140,9 +141,9 @@ describe('the invoice list', () => {
     return screen.getAllByRole('list')[0]
   }
 
-  it('prints the date as the workshop day in the portal language', async () => {
+  it('prints the date as the workshop day in the workshop date format', async () => {
     const cards = await renderList()
-    expect(within(cards).getAllByText('8. nov.')).toHaveLength(3)
+    expect(within(cards).getAllByText('08/11/2026')).toHaveLength(3)
     expect(screen.queryByText('11/8/2026')).not.toBeInTheDocument()
   })
 
@@ -173,7 +174,7 @@ describe('the invoice list', () => {
     // 1000 unpaid and 600 left on the partly paid one.
     expect(within(summary).getByText('kr 1600.00')).toBeInTheDocument()
     expect(within(summary).getByText(/on 2 invoices/)).toBeInTheDocument()
-    expect(within(summary).getByText(/Next due 22\. nov\./)).toBeInTheDocument()
+    expect(within(summary).getByText(/Next due 22\/11\/2026/)).toBeInTheDocument()
     expect(within(summary).getByRole('link', { name: 'Open Invoice 1001' })).toHaveAttribute(
       'href',
       '/portal/verksted/invoices/a'
@@ -199,9 +200,9 @@ describe('the invoice list', () => {
 
   it('says what is left to pay and when it is due, but not on a paid one', async () => {
     const cards = await renderList()
-    expect(within(cards).getByText('Due 22. nov.')).toBeInTheDocument()
+    expect(within(cards).getByText('Due 22/11/2026')).toBeInTheDocument()
     expect(within(cards).getByText('kr 600.00 left to pay')).toBeInTheDocument()
-    expect(within(cards).queryByText('Due 1. nov.')).not.toBeInTheDocument()
+    expect(within(cards).queryByText('Due 01/11/2026')).not.toBeInTheDocument()
   })
 
   it('says an unpaid bill is overdue once its due day has passed at the workshop', async () => {
@@ -223,11 +224,11 @@ describe('the invoice list', () => {
     const lateCard = within(cards).getAllByRole('listitem')[0]
     expect(lateCard.querySelector('[data-payment="overdue"]')).toHaveTextContent('Overdue')
     expect(lateCard.querySelector('[data-payment="overdue"]')).toHaveClass('p-badge--danger')
-    const late = within(cards).getByText('Overdue since 14. nov.')
+    const late = within(cards).getByText('Overdue since 14/11/2026')
     // The theme's own warning colour, which every theme defines.
     expect(late).toHaveClass('text-[color:var(--p-danger)]')
-    expect(within(cards).queryByText('Due 14. nov.')).not.toBeInTheDocument()
-    expect(within(cards).getByText('Due 15. nov.')).toBeInTheDocument()
+    expect(within(cards).queryByText('Due 14/11/2026')).not.toBeInTheDocument()
+    expect(within(cards).getByText('Due 15/11/2026')).toBeInTheDocument()
   })
 
   it('opens the invoice from the whole card and keeps the download its own link', async () => {
@@ -415,7 +416,7 @@ describe('the vehicle page', () => {
     expect(within(tires).getByText('Winter tyres stored with us')).toBeInTheDocument()
     expect(
       within(tires).getByText(
-        'Nokian Hakkapeliitta 10 · 225/60 R18 · 4 tyres · studded · on rims · stored since 20. okt.'
+        'Nokian Hakkapeliitta 10 · 225/60 R18 · 4 tyres · studded · on rims · stored since 20/10/2026'
       )
     ).toBeInTheDocument()
   })

+ 2 - 1
src/__tests__/features/portal/portal-quote-page.test.tsx

@@ -53,6 +53,7 @@ vi.mock('@/features/portal/Lib/portalFormat', async (importOriginal) => {
         locale: 'en-NZ',
         timeZone: 'Pacific/Auckland',
         timeFormat: '24h',
+        dateFormat: 'dd/MM/yyyy',
         money: (amount) => `NZ$${amount.toFixed(2)}`,
         today: 'Today',
         tomorrow: 'Tomorrow',
@@ -84,7 +85,7 @@ describe('a quote in the customer portal', () => {
     expect(screen.getByRole('heading', { name: 'Brake overhaul' })).toBeInTheDocument()
     expect(screen.getByText('NZ$4200.00')).toBeInTheDocument()
     expect(screen.getByText('Sent')).toBeInTheDocument()
-    expect(screen.getByText('1 Dec')).toBeInTheDocument()
+    expect(screen.getByText('01/12/2026')).toBeInTheDocument()
     expect(screen.getByTestId('sheet')).toBeInTheDocument()
     expect(screen.getByRole('link', { name: /Back to quotes/ })).toHaveAttribute(
       'href',

+ 9 - 4
src/__tests__/features/reports/report-range-workshop-today.test.tsx

@@ -55,12 +55,12 @@ afterEach(() => {
   vi.useRealTimers()
 })
 
-async function openReports(zone: string, now: string) {
+async function openReports(zone: string, now: string, dateFormat = 'dd/MM/yyyy') {
   vi.useFakeTimers({ toFake: ['Date'] })
   vi.setSystemTime(new Date(now))
   await act(async () => {
     render(
-      <DateSettingsProvider dateFormat="dd/MM/yyyy" timeFormat="24h" timezone={zone}>
+      <DateSettingsProvider dateFormat={dateFormat} timeFormat="24h" timezone={zone}>
         <ReportsClient currencyCode="NZD" primaryColor="#d97706" organizationName="Test" />
       </DateSettingsProvider>
     )
@@ -71,7 +71,7 @@ describe('the default report range', () => {
   it("ends on the Auckland workshop's today for a viewer in London", async () => {
     // 16:00 on 24 November in London, 05:00 on the 25th in Auckland.
     await openReports('Pacific/Auckland', '2026-11-24T16:00:00Z')
-    expect(screen.getByText(/Jan 01, 2026 – Nov 25, 2026/)).toBeInTheDocument()
+    expect(screen.getByText('01/01/2026 – 25/11/2026')).toBeInTheDocument()
     expect(getRevenueReport).toHaveBeenCalledWith(
       expect.objectContaining({ startDate: '2026-01-01', endDate: '2026-11-25' })
     )
@@ -80,12 +80,17 @@ describe('the default report range', () => {
   it("ends on the Los Angeles workshop's today, a day behind London", async () => {
     // 06:00 on 25 November in London, 22:00 on the 24th in Los Angeles.
     await openReports('America/Los_Angeles', '2026-11-25T06:00:00Z')
-    expect(screen.getByText(/Jan 01, 2026 – Nov 24, 2026/)).toBeInTheDocument()
+    expect(screen.getByText('01/01/2026 – 24/11/2026')).toBeInTheDocument()
     expect(getRevenueReport).toHaveBeenCalledWith(
       expect.objectContaining({ startDate: '2026-01-01', endDate: '2026-11-24' })
     )
   })
 
+  it("writes the range in the workshop's date format, whichever it chose", async () => {
+    await openReports('Pacific/Auckland', '2026-11-24T16:00:00Z', 'MM/dd/yyyy')
+    expect(screen.getByText('01/01/2026 – 11/25/2026')).toBeInTheDocument()
+  })
+
   it("starts on the workshop's new year while London is still in the old one", async () => {
     // 12:00 UTC on 31 December is already 1 January 2027 in Auckland.
     await openReports('Pacific/Auckland', '2026-12-31T12:00:00Z')

+ 13 - 11
src/__tests__/features/status-reports/report-day.test.tsx

@@ -1,8 +1,9 @@
 /**
  * The day on a status report's share page is the workshop's day, written by
- * the server. The browser used to write it, in the phone's zone and the
- * phone's date style, so a customer far from the server read another day
- * than the server had rendered and React drew the page twice.
+ * the server in the workshop's date format, the same way the expiry date
+ * beside it is. The browser used to write it, in the phone's zone and the
+ * phone's date style, and then the server wrote it in the language's long
+ * form ("November 24, 2026") next to a "08/12/2026" expiry.
  */
 import { render, screen } from '@testing-library/react'
 import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
@@ -29,17 +30,18 @@ afterAll(() => {
 
 describe('the day a status report was made', () => {
   it("is the workshop's day, whatever clock the machine has", () => {
-    expect(formatReportDay(MADE, 'en', 'Australia/Sydney')).toBe('December 1, 2026')
-    expect(formatReportDay(MADE, 'en', 'Pacific/Honolulu')).toBe('November 30, 2026')
+    expect(formatReportDay(MADE, 'dd/MM/yyyy', 'Australia/Sydney')).toBe('01/12/2026')
+    expect(formatReportDay(MADE, 'dd/MM/yyyy', 'Pacific/Honolulu')).toBe('30/11/2026')
   })
 
-  it("is written in the page's language", () => {
-    expect(formatReportDay(MADE, 'nl', 'Europe/Brussels')).toBe('30 november 2026')
-    expect(formatReportDay(MADE, 'fr', 'Europe/Brussels')).toBe('30 novembre 2026')
+  it("is written in the workshop's date format", () => {
+    expect(formatReportDay(MADE, 'MM/dd/yyyy', 'Australia/Sydney')).toBe('12/01/2026')
+    expect(formatReportDay(MADE, 'yyyy-MM-dd', 'Australia/Sydney')).toBe('2026-12-01')
+    expect(formatReportDay(MADE, 'dd.MM.yyyy', 'Europe/Brussels')).toBe('30.11.2026')
   })
 
   it('falls back to the day in UTC for a zone the runtime does not know', () => {
-    expect(formatReportDay(MADE, 'en', 'Mars/Olympus')).toBe('November 30, 2026')
+    expect(formatReportDay(MADE, 'dd/MM/yyyy', 'Mars/Olympus')).toBe('30/11/2026')
   })
 
   it('is shown on the share page exactly as the server wrote it', () => {
@@ -52,7 +54,7 @@ describe('the day a status report was made', () => {
           videoUrl: null,
           videoFileName: null,
           status: 'sent',
-          createdDay: formatReportDay(MADE, 'en', 'Australia/Sydney'),
+          createdDay: formatReportDay(MADE, 'dd/MM/yyyy', 'Australia/Sydney'),
           customerFeedback: null,
           feedbackAt: null,
         }}
@@ -67,6 +69,6 @@ describe('the day a status report was made', () => {
         showBranding={false}
       />
     )
-    expect(screen.getByText('December 1, 2026')).toBeInTheDocument()
+    expect(screen.getByText('01/12/2026')).toBeInTheDocument()
   })
 })

+ 1 - 1
src/app/(authenticated)/(dashboard)/dashboard-client.tsx

@@ -504,7 +504,7 @@ export function DashboardClient({
     if (diffMins < 60) return t('relativeTime.minutes', { count: diffMins })
     if (diffHours < 24) return t('relativeTime.hours', { count: diffHours })
     if (diffDays < 7) return t('relativeTime.days', { count: diffDays })
-    return d.toLocaleDateString([], { month: 'short', day: 'numeric' })
+    return formatDate(d)
   }
 
   /**

+ 25 - 7
src/app/(authenticated)/reports/reports-client.tsx

@@ -77,6 +77,7 @@ import {
 } from '@/features/reports/Actions/reportActions'
 import { useFormatCurrency } from '@/components/currency-settings-context'
 import { useDateSettings } from '@/components/date-settings-context'
+import { useFormatDate } from '@/lib/use-format-date'
 import { dayKeyToLocalDate, workshopTodayKey } from '@/lib/workshop-datetime'
 import type {
   RevenueReport,
@@ -180,6 +181,8 @@ export default function ReportsClient({
   // The workshop's day, not the viewer's: a London viewer of an Auckland
   // workshop otherwise ends the range on a day the workshop has left behind.
   const { timezone } = useDateSettings()
+  // Days in the workshop's date format: the picked range and the day columns.
+  const { formatDay } = useFormatDate()
   const workshopToday = dayKeyToLocalDate(workshopTodayKey(timezone))
   const currentYear = workshopToday.getFullYear()
 
@@ -574,8 +577,8 @@ export default function ReportsClient({
   const handlePdfExport = async () => {
     setPdfLoading(true)
     try {
-      const from = dateRange.from ? format(dateRange.from, 'LLL dd, y') : ''
-      const to = dateRange.to ? format(dateRange.to, 'LLL dd, y') : ''
+      const from = dateRange.from ? formatDay(dateRange.from) : ''
+      const to = dateRange.to ? formatDay(dateRange.to) : ''
       const dateRangeStr = from && to ? `${from} – ${to}` : from || to
 
       const labels: Record<string, string> = {
@@ -694,7 +697,13 @@ export default function ReportsClient({
           pdfProps.taxData = taxData
           filename = 'tax-report'
         } else if (financialSubTab === 'past-due-invoices') {
-          pdfProps.pastDueData = pastDueData
+          pdfProps.pastDueData = pastDueData && {
+            ...pastDueData,
+            invoices: pastDueData.invoices.map((inv) => ({
+              ...inv,
+              dueDate: formatDay(inv.dueDate),
+            })),
+          }
           filename = 'past-due-invoices-report'
         }
       } else {
@@ -711,6 +720,15 @@ export default function ReportsClient({
         }
         const entry = dataMap[activeTab]
         if (entry) pdfProps[entry[0] as string] = entry[1]
+        if (activeTab === 'vehicles' && vehicleData) {
+          pdfProps.vehicleData = {
+            ...vehicleData,
+            serviceHistory: vehicleData.serviceHistory.map((row) => ({
+              ...row,
+              date: formatDay(row.date),
+            })),
+          }
+        }
       }
 
       const blob = await pdf(
@@ -870,10 +888,10 @@ export default function ReportsClient({
                   {dateRange.from ? (
                     dateRange.to ? (
                       <>
-                        {format(dateRange.from, 'LLL dd, y')} – {format(dateRange.to, 'LLL dd, y')}
+                        {formatDay(dateRange.from)} – {formatDay(dateRange.to)}
                       </>
                     ) : (
-                      format(dateRange.from, 'LLL dd, y')
+                      formatDay(dateRange.from)
                     )
                   ) : (
                     <span>{t('dateRange.pickDate')}</span>
@@ -1445,7 +1463,7 @@ export default function ReportsClient({
                                 {fmtCurrency(inv.amountPaid)}
                               </TableCell>
                               <TableCell className="text-right text-sm hidden md:table-cell">
-                                {inv.dueDate}
+                                {formatDay(inv.dueDate)}
                               </TableCell>
                               <TableCell className="text-right">
                                 <Badge
@@ -2664,7 +2682,7 @@ export default function ReportsClient({
                                 )}
                               >
                                 <TableCell className="text-sm text-muted-foreground">
-                                  {row.date}
+                                  {formatDay(row.date)}
                                 </TableCell>
                                 <TableCell className="text-sm font-medium">{row.title}</TableCell>
                                 <TableCell className="text-sm">

+ 4 - 12
src/app/(authenticated)/settings/report-schedule/report-schedule-settings.tsx

@@ -3,6 +3,7 @@
 import { useState, useTransition } from 'react'
 import { useRouter } from 'next/navigation'
 import { useTranslations } from 'next-intl'
+import { useFormatDate } from '@/lib/use-format-date'
 import { toast } from 'sonner'
 import { Button } from '@/components/ui/button'
 import { Card, CardContent } from '@/components/ui/card'
@@ -378,6 +379,7 @@ function ScheduleCard({
   onEdit: () => void
 }) {
   const t = useTranslations('settings.reportSchedule')
+  const { formatDate, formatDateTime } = useFormatDate()
   const router = useRouter()
   const [isPending, startTransition] = useTransition()
   const [deleting, setDeleting] = useState(false)
@@ -499,13 +501,7 @@ function ScheduleCard({
           {schedule.isActive && (
             <span className="flex items-center gap-1">
               <Clock className="h-3 w-3" />
-              {t('nextRun')}:{' '}
-              {new Date(schedule.nextRunDate).toLocaleDateString(undefined, {
-                month: 'short',
-                day: 'numeric',
-                hour: '2-digit',
-                minute: '2-digit',
-              })}
+              {t('nextRun')}: {formatDateTime(schedule.nextRunDate)}
             </span>
           )}
           {schedule.runCount > 0 && (
@@ -517,11 +513,7 @@ function ScheduleCard({
           {schedule.lastRunAt && (
             <span className="flex items-center gap-1">
               <CalendarClock className="h-3 w-3" />
-              {t('lastRun')}:{' '}
-              {new Date(schedule.lastRunAt).toLocaleDateString(undefined, {
-                month: 'short',
-                day: 'numeric',
-              })}
+              {t('lastRun')}: {formatDate(schedule.lastRunAt)}
             </span>
           )}
         </div>

+ 3 - 1
src/app/(authenticated)/settings/team/team-settings.tsx

@@ -3,6 +3,7 @@
 import { useMemo, useState } from 'react'
 import { useRouter } from 'next/navigation'
 import { useTranslations } from 'next-intl'
+import { useFormatDate } from '@/lib/use-format-date'
 import { toast } from 'sonner'
 import { Button } from '@/components/ui/button'
 import { Input } from '@/components/ui/input'
@@ -146,6 +147,7 @@ export function TeamSettings({
 }) {
   const router = useRouter()
   const t = useTranslations('settings')
+  const { formatDate } = useFormatDate()
   const tPerm = useTranslations('permissions')
   const modal = useGlassModal()
   const confirm = useConfirm()
@@ -774,7 +776,7 @@ export function TeamSettings({
                     {t('team.invitedAs', { role: invitation.customRole?.name || invitation.role })}{' '}
                     &middot;{' '}
                     {t('team.expires', {
-                      date: new Date(invitation.expiresAt).toLocaleDateString(),
+                      date: formatDate(invitation.expiresAt),
                     })}
                   </p>
                 </div>

+ 5 - 14
src/app/(authenticated)/vehicles/[id]/job-warning.tsx

@@ -3,8 +3,9 @@
 import Link from 'next/link'
 import { useMemo } from 'react'
 import { AlertTriangle } from 'lucide-react'
-import { useFormatter, useTranslations } from 'next-intl'
+import { useTranslations } from 'next-intl'
 import { useDateSettings } from '@/components/date-settings-context'
+import { useFormatDate } from '@/lib/use-format-date'
 import { awayEdges } from '@/features/workshop-calendar/Lib/format'
 import type { VehicleJobWarning } from '@/features/vehicles/Lib/vehicleJobWarnings'
 
@@ -18,22 +19,12 @@ export function useJobWarningText() {
   const t = useTranslations('vehicles.detail.jobWarning')
   const tCal = useTranslations('workshopCalendar')
   const tSchedule = useTranslations('service.schedule')
-  const format = useFormatter()
   const { timezone } = useDateSettings()
+  // Days in the workshop's date format, times on its clock, as on the work order.
+  const { formatDate: day, formatDateTime: dayAndClock, formatTime: clock } = useFormatDate()
 
   return useMemo(() => {
     const timeZone = timezone || undefined
-    const day = (at: Date) => format.dateTime(at, { day: 'numeric', month: 'short', timeZone })
-    const dayAndClock = (at: Date) =>
-      format.dateTime(at, {
-        day: 'numeric',
-        month: 'short',
-        hour: '2-digit',
-        minute: '2-digit',
-        timeZone,
-      })
-    const clock = (at: Date) =>
-      format.dateTime(at, { hour: '2-digit', minute: '2-digit', timeZone })
     const reason = (stored: string) =>
       tCal.has(`reasons.${stored}`) ? tCal(`reasons.${stored}`) : stored
 
@@ -68,7 +59,7 @@ export function useJobWarningText() {
     }
 
     return { lines, heading: t('heading') }
-  }, [t, tCal, tSchedule, format, timezone])
+  }, [t, tCal, tSchedule, day, dayAndClock, clock, timezone])
 }
 
 /**

+ 5 - 3
src/app/(authenticated)/vehicles/[id]/vehicle-activity-feed.tsx

@@ -1,5 +1,6 @@
 'use client'
 
+import { formatDate } from '@/lib/format'
 import Link from 'next/link'
 import { useMemo, useState } from 'react'
 import { useFormatter, useTranslations } from 'next-intl'
@@ -144,7 +145,8 @@ export function VehicleActivityFeed({
   // Days and years are the workshop's, on the server and in the browser
   // alike: a job at half past midnight Oslo time is on that day whichever
   // machine draws the row, and the two never disagree about it.
-  const timeZone = safeTimeZone(useDateSettings().timezone)
+  const { timezone, dateFormat } = useDateSettings()
+  const timeZone = safeTimeZone(timezone)
   const [showAll, setShowAll] = useState(false)
   const [showAllOpen, setShowAllOpen] = useState(false)
   const warningFor = useMemo(
@@ -219,8 +221,8 @@ export function VehicleActivityFeed({
     else groups.push({ year, items: [event] })
   }
 
-  const dayMonth = (date: Date) =>
-    numberFormat.dateTime(date, { day: 'numeric', month: 'short', timeZone })
+  // In the workshop's date format, like the next booking beside the table.
+  const dayMonth = (date: Date) => formatDate(date, dateFormat, timeZone)
   const reading = (km: number | null) => (km ? `${numberFormat.number(km)} ${distUnit}` : null)
   const money = (amount: number) => (amount > 0 ? formatCurrency(amount, currencyCode) : null)
 

+ 4 - 5
src/app/(public)/b/[token]/booking-client.tsx

@@ -1,11 +1,12 @@
 'use client'
 
 import { useMemo, useState } from 'react'
-import { useFormatter, useTranslations } from 'next-intl'
+import { useFormatter, useLocale, useTranslations } from 'next-intl'
 import { toast } from 'sonner'
 import { CalendarCheck, CalendarX, Loader2, Phone } from 'lucide-react'
 import { Button } from '@/components/ui/button'
 import { Textarea } from '@/components/ui/textarea'
+import { formatDate } from '@/lib/format'
 import {
   type BookingPage,
   cancelBooking,
@@ -21,6 +22,7 @@ import {
 export function BookingClient({ token, initial }: { token: string; initial: BookingPage }) {
   const t = useTranslations('portal.booking')
   const format = useFormatter()
+  const locale = useLocale()
   const [page, setPage] = useState(initial)
   const [day, setDay] = useState<string | null>(null)
   const [start, setStart] = useState<string | null>(null)
@@ -104,10 +106,7 @@ export function BookingClient({ token, initial }: { token: string; initial: Book
       </p>
       <p className="text-muted-foreground">
         {t('due', {
-          date: format.dateTime(new Date(page.dueAt), {
-            dateStyle: 'long',
-            timeZone: page.timeZone,
-          }),
+          date: formatDate(page.dueAt, page.dateFormat, page.timeZone, locale),
         })}
       </p>
     </div>

+ 5 - 4
src/app/(public)/share/status-report/[orgId]/[token]/page.tsx

@@ -9,7 +9,7 @@ import { StatusReportView } from './status-report-view'
 import { resolvePortalOrg } from '@/lib/portal-slug'
 import { getFeatures } from '@/lib/features'
 import { formatReportDay } from '@/features/status-reports/Lib/reportDay'
-import { workshopTimeZone } from '@/lib/workshop-timezone'
+import { workshopDateSettings } from '@/lib/workshop-timezone'
 import type { Metadata } from 'next'
 
 function toPublicFileUrl(fileUrl: string, token: string): string {
@@ -108,7 +108,7 @@ export default async function PublicStatusReportPage({
   }
 
   // Fetch workshop settings
-  const [settings, features, locale, timeZone] = await Promise.all([
+  const [settings, features, dates, locale] = await Promise.all([
     db.appSetting.findMany({
       where: {
         organizationId: orgId,
@@ -125,8 +125,9 @@ export default async function PublicStatusReportPage({
       },
     }),
     getFeatures(orgId),
+    workshopDateSettings(orgId),
+    // The page's language: the workshop's when it decides, else the customer's.
     getLocale(),
-    workshopTimeZone(orgId),
   ])
 
   const settingsMap: Record<string, string> = {}
@@ -144,7 +145,7 @@ export default async function PublicStatusReportPage({
         videoUrl,
         videoFileName: report.videoFileName,
         status: report.status,
-        createdDay: formatReportDay(report.createdAt, locale, timeZone),
+        createdDay: formatReportDay(report.createdAt, dates.dateFormat, dates.timeZone, locale),
         customerFeedback: report.customerFeedback,
         feedbackAt: report.feedbackAt?.toISOString() || null,
       }}

+ 5 - 7
src/app/api/v1/tech/jobs/[id]/notes/route.ts

@@ -2,7 +2,8 @@ import { z } from 'zod'
 import { db } from '@/lib/db'
 import { PermissionAction, PermissionSubject } from '@/lib/permissions'
 import { apiError, apiOk, withApiAuth } from '@/lib/with-api-auth'
-import { workshopTimeZone } from '@/lib/workshop-timezone'
+import { formatDate } from '@/lib/format'
+import { workshopDateSettings } from '@/lib/workshop-timezone'
 import { jobScopeFor } from '@/features/workboard/Lib/jobTeam'
 
 /**
@@ -47,12 +48,9 @@ export async function POST(request: Request, { params }: { params: Promise<{ id:
       // Stamped, because a shared field with several authors and no
       // attribution becomes unreadable within a week. The web editor stores
       // HTML, so this matches rather than injecting bare newlines into it.
-      // Dated on the workshop's calendar, not the server's.
-      const stamp = new Date().toLocaleDateString('en-GB', {
-        day: 'numeric',
-        month: 'short',
-        timeZone: await workshopTimeZone(ctx.organizationId),
-      })
+      // Dated on the workshop's calendar, not the server's, in its date format.
+      const shop = await workshopDateSettings(ctx.organizationId)
+      const stamp = formatDate(new Date(), shop.dateFormat, shop.timeZone)
       const line = `<p><strong>${technician?.name ?? 'Technician'}, ${stamp}:</strong> ${escapeHtml(note.trim())}</p>`
 
       const updated = await db.serviceRecord.update({

+ 4 - 3
src/components/sent-copy-note.tsx

@@ -7,7 +7,7 @@ import {
   ConfirmFrameCancel,
   ConfirmFrameText,
 } from '@/components/confirm-dialog'
-import { useDayFormatter } from '@/features/calendar/Components/useDayFormatter'
+import { useFormatDate } from '@/lib/use-format-date'
 import { cn } from '@/lib/utils'
 
 /**
@@ -28,9 +28,10 @@ export function SentCopyNote({
   className?: string
 }) {
   const t = useTranslations('common.sentCopy')
-  const format = useDayFormatter()
+  // The day it was issued, in the workshop's date format and on its clock.
+  const { formatDate } = useFormatDate()
   if (!sentAt) return null
-  const date = format.dateTime(new Date(sentAt), { dateStyle: 'medium' })
+  const date = formatDate(new Date(sentAt))
   return (
     <p data-testid="sent-copy-note" className={cn('text-xs text-muted-foreground', className)}>
       {t('note', { date })}

+ 17 - 8
src/components/ui/datetime-picker.tsx

@@ -663,6 +663,7 @@ const LocalDateTimePicker = React.forwardRef<
     },
     ref
   ) => {
+    const { dateFormat } = useDateSettings()
     const [month, setMonth] = React.useState<Date>(value ?? defaultPopupValue)
     const buttonRef = useRef<HTMLButtonElement>(null)
     const [displayDate, setDisplayDate] = React.useState<Date | undefined>(value ?? undefined)
@@ -710,13 +711,12 @@ const LocalDateTimePicker = React.forwardRef<
       [displayDate]
     )
 
+    // The date reads the way the workshop writes dates (Settings, Localization),
+    // not date-fns' own long English form.
+    const seconds = !granularity || granularity === 'second' ? ':ss' : ''
     const initHourFormat = {
-      hour24:
-        displayFormat?.hour24 ??
-        `PPP HH:mm${!granularity || granularity === 'second' ? ':ss' : ''}`,
-      hour12:
-        displayFormat?.hour12 ??
-        `PP hh:mm${!granularity || granularity === 'second' ? ':ss' : ''} b`,
+      hour24: displayFormat?.hour24 ?? `${dateFormat} HH:mm${seconds}`,
+      hour12: displayFormat?.hour12 ?? `${dateFormat} hh:mm${seconds} a`,
     }
 
     let loc = enUS
@@ -744,10 +744,10 @@ const LocalDateTimePicker = React.forwardRef<
           >
             <CalendarIcon className="mr-2 h-4 w-4" />
             {displayDate ? (
-              format(
+              formatDisplay(
                 displayDate,
                 hourCycle === 24 ? initHourFormat.hour24 : initHourFormat.hour12,
-                { locale: loc }
+                loc
               )
             ) : (
               <span>{placeholder}</span>
@@ -798,6 +798,15 @@ const LocalDateTimePicker = React.forwardRef<
 
 LocalDateTimePicker.displayName = 'LocalDateTimePicker'
 
+/** A pattern date-fns refuses (an odd stored setting) falls back to its own long form. */
+function formatDisplay(date: Date, pattern: string, locale: Locale): string {
+  try {
+    return format(date, pattern, { locale })
+  } catch {
+    return format(date, 'PPP HH:mm', { locale })
+  }
+}
+
 /**
  * The picker above works entirely in the browser's local time: it formats with
  * date-fns and types into `setHours`. A workshop that has chosen a timezone

+ 23 - 11
src/features/inspection-reminders/Actions/bookingActions.ts

@@ -1,10 +1,11 @@
 'use server'
 
 import { deleteCustomFieldValuesOf } from '@/features/custom-fields/Lib/deleteCustomFieldValues'
-import { getTranslations } from 'next-intl/server'
+import { getLocale, getTranslations } from 'next-intl/server'
 import { z } from 'zod'
 import { SETTING_KEYS } from '@/features/settings/Schema/settingsSchema'
 import { db } from '@/lib/db'
+import { formatDateTime } from '@/lib/format'
 import { notify } from '@/lib/notify'
 import { serviceRecordHref } from '@/lib/service-record'
 import { type BookableDay, availabilityFor, claimableResource } from '../Lib/booking'
@@ -52,6 +53,8 @@ export interface BookingPage {
   durationMinutes: number
   /** The workshop's zone; every time on the page is shown in it. */
   timeZone: string
+  /** The workshop's date format, for the due date. */
+  dateFormat?: string
   booking: { start: string; end: string; pendingApproval: boolean } | null
   days: BookableDay[]
   firstStart: string | null
@@ -156,6 +159,7 @@ export async function getBookingPage(rawToken: string): Promise<BookingPage | nu
     bookingMode: settings.bookingMode,
     durationMinutes: settings.durationMinutes,
     timeZone: settings.timeZone,
+    dateFormat: settings.dateFormat,
     booking: booking
       ? {
           start: booking.start.toISOString(),
@@ -253,11 +257,14 @@ export async function confirmBooking(raw: unknown) {
 
   // The server runs in UTC: the customer's confirmation and the desk's notice
   // both read the slot on the workshop's clock, as the cancellation already does.
-  const when = new Intl.DateTimeFormat(undefined, {
-    dateStyle: 'medium',
-    timeStyle: 'short',
-    timeZone: settings.timeZone,
-  }).format(start)
+  // Month names in the language the confirmation itself is written in.
+  const when = formatDateTime(
+    start,
+    settings.dateFormat,
+    settings.timeFormat,
+    settings.timeZone,
+    await getLocale()
+  )
   await notify({
     organizationId: send.organizationId,
     type: 'online_booking',
@@ -363,11 +370,16 @@ export async function cancelBooking(rawToken: string) {
     message: t('cancelledNotificationBody', {
       customer: send.customer.name,
       vehicle: vehicleLabel,
-      when: new Intl.DateTimeFormat(undefined, {
-        dateStyle: 'medium',
-        timeStyle: 'short',
-        timeZone: (await loadInspectionReminderSettings(send.organizationId)).timeZone,
-      }).format(booking.start),
+      when: await (async () => {
+        const shop = await loadInspectionReminderSettings(send.organizationId)
+        return formatDateTime(
+          booking.start,
+          shop.dateFormat,
+          shop.timeFormat,
+          shop.timeZone,
+          await getLocale()
+        )
+      })(),
     }),
     // A cancelled request stays listed on the customer, marked cancelled; a
     // booked slot is deleted, which leaves the vehicle as the place to look.

+ 8 - 2
src/features/inspection-reminders/Lib/campaign.ts

@@ -1,4 +1,5 @@
 import { db } from '@/lib/db'
+import { formatDate } from '@/lib/format'
 import {
   addZonedDays,
   atZonedTime,
@@ -81,8 +82,13 @@ export function templateValues(input: {
     customerName: candidate.customerName ?? '',
     vehicle: candidate.vehicle,
     plate: candidate.licensePlate ?? '',
-    dueDate: new Intl.DateTimeFormat(input.locale, { dateStyle: 'long' }).format(
-      new Date(candidate.dueAt)
+    // The customer reads the day on the workshop's calendar, written the way
+    // the workshop writes dates on everything else it sends.
+    dueDate: formatDate(
+      new Date(candidate.dueAt),
+      settings.dateFormat,
+      settings.timeZone,
+      input.locale
     ),
     workshopName: settings.workshopName,
     bookingLink: input.link,

+ 8 - 0
src/features/inspection-reminders/Lib/settings.ts

@@ -25,6 +25,10 @@ export interface InspectionReminderSettings {
   timeZone: string
   /** True when the zone came from the browser's detection rather than a choice. */
   timeZoneDetected: boolean
+  /** How the workshop writes a date (Settings, Localization); the default when left out. */
+  dateFormat?: string
+  /** The workshop's 12 or 24 hour clock; 12 hour when left out. */
+  timeFormat?: '12h' | '24h'
 }
 
 /** A link stays open at least this long, whatever the workshop typed. */
@@ -57,6 +61,8 @@ export async function loadInspectionReminderSettings(
     'workboard.showWeekends',
     SETTING_KEYS.TIMEZONE,
     SETTING_KEYS.TIMEZONE_DETECTED,
+    SETTING_KEYS.DATE_FORMAT,
+    SETTING_KEYS.TIME_FORMAT,
   ]
   const [rows, org] = await Promise.all([
     db.appSetting.findMany({
@@ -75,6 +81,8 @@ export async function loadInspectionReminderSettings(
   return {
     timeZone,
     timeZoneDetected: !get(SETTING_KEYS.TIMEZONE)?.trim(),
+    dateFormat: get(SETTING_KEYS.DATE_FORMAT) || undefined,
+    timeFormat: get(SETTING_KEYS.TIME_FORMAT) === '24h' ? '24h' : '12h',
     durationMinutes: int(
       get(SETTING_KEYS.INSPECTION_DURATION_MINUTES),
       DEFAULT_DURATION_MINUTES,

+ 18 - 12
src/features/integrations/Actions/videoCallActions.ts

@@ -1,12 +1,14 @@
 'use server'
 
 import { z } from 'zod'
-import { getLocale, getTranslations } from 'next-intl/server'
+import { getTranslations } from 'next-intl/server'
+import { resolveDocumentLocale } from '@/i18n/locale-from-request'
 import { db } from '@/lib/db'
 import { withAuth } from '@/lib/with-auth'
 import { PermissionAction, PermissionSubject } from '@/lib/permissions'
 import { demoGuard } from '@/lib/demo'
-import { workshopTimeZone } from '@/lib/workshop-timezone'
+import { formatDateTime } from '@/lib/format'
+import { workshopDateSettings } from '@/lib/workshop-timezone'
 import { sendSmsToCustomer } from '@/features/sms/Actions/smsActions'
 import { sendNotificationEmail } from '@/features/email/Actions/emailActions'
 import { sendTelegramToCustomer } from '@/features/telegram/Actions/telegramActions'
@@ -62,18 +64,22 @@ export async function sendServiceVideoCall(input: unknown) {
       if (!link) throw new Error('No video call on this work order')
 
       const vehicle = record.vehicle ? `${vehicleName(record.vehicle)}` : record.title
-      const t = await getTranslations('service.videoCall.notify')
+      // What the customer receives is in the workshop's language, whatever
+      // language the person sending it reads the app in.
+      const locale = await resolveDocumentLocale(organizationId)
+      const t = await getTranslations({ locale, namespace: 'service.videoCall.notify' })
       let when: string | null = null
       if (record.startDateTime) {
-        const [locale, timeZone] = await Promise.all([
-          getLocale(),
-          workshopTimeZone(organizationId),
-        ])
-        when = new Intl.DateTimeFormat(locale, {
-          dateStyle: 'full',
-          timeStyle: 'short',
-          timeZone,
-        }).format(record.startDateTime)
+        // The customer reads the time on the workshop's clock, written the
+        // way the workshop writes dates and times on everything it sends.
+        const shop = await workshopDateSettings(organizationId)
+        when = formatDateTime(
+          record.startDateTime,
+          shop.dateFormat,
+          shop.timeFormat,
+          shop.timeZone,
+          locale
+        )
       }
       const body = videoCallMessage({
         customMessage: data.customMessage,

+ 17 - 6
src/features/messaging/Components/EmailConversation.tsx

@@ -3,6 +3,9 @@
 import { useCallback, useEffect, useMemo, useRef, useState, useTransition } from 'react'
 import { useRouter } from 'next/navigation'
 import { useTranslations } from 'next-intl'
+import { useFormatDate } from '@/lib/use-format-date'
+import { useDateSettings } from '@/components/date-settings-context'
+import { zonedDayKey } from '@/lib/timezone'
 import { toast } from 'sonner'
 import {
   AlertCircle,
@@ -326,12 +329,19 @@ function formatSize(bytes: number): string {
   return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
 }
 
-/** Today's mail shows the time; older mail needs the day too. */
-function formatWhen(value: string | Date): string {
-  const date = new Date(value)
-  const time = date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
-  if (date.toDateString() === new Date().toDateString()) return time
-  return `${date.toLocaleDateString([], { day: 'numeric', month: 'short' })} ${time}`
+/**
+ * Today's mail shows the time; older mail needs the day too. Both on the
+ * workshop's clock and the day in its date format.
+ */
+function useFormatWhen(): (value: string | Date) => string {
+  const { timezone } = useDateSettings()
+  const { formatDateTime, formatTime } = useFormatDate()
+  return (value) => {
+    const date = new Date(value)
+    const zone = timezone || Intl.DateTimeFormat().resolvedOptions().timeZone
+    if (zonedDayKey(date, zone) === zonedDayKey(new Date(), zone)) return formatTime(date)
+    return formatDateTime(date)
+  }
 }
 
 /**
@@ -349,6 +359,7 @@ function EmailMessageItem({
   mounted: boolean
 }) {
   const t = useTranslations('messaging.email')
+  const formatWhen = useFormatWhen()
   const [showQuoted, setShowQuoted] = useState(false)
   const isOutbound = message.direction === 'outbound'
   const failed = message.status === 'failed'

+ 4 - 9
src/features/messaging/Components/PortalConversation.tsx

@@ -3,6 +3,7 @@
 import { ChevronUp, ImagePlus, Loader2, Paperclip, Send, X } from 'lucide-react'
 import Link from 'next/link'
 import { useTranslations } from 'next-intl'
+import { useFormatDate } from '@/lib/use-format-date'
 import { useCallback, useEffect, useRef, useState, useTransition } from 'react'
 import { toast } from 'sonner'
 import { z } from 'zod'
@@ -84,6 +85,8 @@ export function PortalConversation({
   className?: string
 }) {
   const t = useTranslations('messaging.portal')
+  // On the workshop's clock, the day in its date format.
+  const { formatDateTime } = useFormatDate()
   const [messages, setMessages] = useState<PortalInboxMessage[]>([])
   const [nextCursor, setNextCursor] = useState<string | null>(null)
   const [canReply, setCanReply] = useState(true)
@@ -304,15 +307,7 @@ export function PortalConversation({
     })
   }
 
-  const when = (iso: string) =>
-    mounted
-      ? new Date(iso).toLocaleString([], {
-          day: 'numeric',
-          month: 'short',
-          hour: '2-digit',
-          minute: '2-digit',
-        })
-      : ''
+  const when = (iso: string) => (mounted ? formatDateTime(iso) : '')
 
   return (
     <div className={cn('flex h-[500px] flex-col', className)}>

+ 4 - 5
src/features/meters/Components/VehicleMeters.tsx

@@ -29,6 +29,7 @@ import {
 } from '@/components/ui/dropdown-menu'
 import { useConfirm } from '@/components/confirm-dialog'
 import { useDateSettings } from '@/components/date-settings-context'
+import { useFormatDate } from '@/lib/use-format-date'
 import { useServiceType } from '@/components/service-type-context'
 import { zonedDayKey } from '@/lib/timezone'
 import { cn } from '@/lib/utils'
@@ -60,12 +61,10 @@ function useMeterText() {
   }
 }
 
-/** A reading's date on the workshop's clock. */
+/** A reading's date on the workshop's clock, in the workshop's date format. */
 function useReadingDate() {
-  const format = useFormatter()
-  const { timezone } = useDateSettings()
-  return (iso: string) =>
-    format.dateTime(new Date(iso), { dateStyle: 'medium', timeZone: timezone || undefined })
+  const { formatDate } = useFormatDate()
+  return (iso: string) => formatDate(iso)
 }
 
 /** Today on the workshop's calendar, for a reading date field. */

+ 10 - 4
src/features/portal/Components/Chat/PortalChatPanel.tsx

@@ -29,6 +29,7 @@ import {
   buildPortalThread,
   type PortalChatStampKind,
   type PortalChatStamps,
+  type PortalChatClock,
   portalChatFormats,
   workshopDayKey,
 } from './chatThread'
@@ -69,8 +70,8 @@ export interface PortalChatPanelProps {
    * without it the events arrive with the chat's first poll.
    */
   initialEvents?: PortalChatEvent[]
-  /** How times are printed: the workshop's zone and its 12 or 24 hour clock. */
-  clock: { timeZone: string; timeFormat: '12h' | '24h' }
+  /** How times are printed: the workshop's zone, its 12 or 24 hour clock and its date format. */
+  clock: PortalChatClock
   /**
    * The times and days of that first thread as the server printed them, so
    * the page reads the same before and after the browser takes over. Optional:
@@ -132,8 +133,13 @@ export function PortalChatPanel({
   const canWrite = enabled && thread.enabled
 
   const formats = useMemo(
-    () => portalChatFormats(locale, { timeZone: clock.timeZone, timeFormat: clock.timeFormat }),
-    [locale, clock.timeZone, clock.timeFormat]
+    () =>
+      portalChatFormats(locale, {
+        timeZone: clock.timeZone,
+        timeFormat: clock.timeFormat,
+        dateFormat: clock.dateFormat,
+      }),
+    [locale, clock.timeZone, clock.timeFormat, clock.dateFormat]
   )
   /**
    * A moment as the thread prints it. What the server already printed is

+ 11 - 4
src/features/portal/Components/Chat/chatThread.ts

@@ -1,3 +1,4 @@
+import { DEFAULT_DATE_FORMAT, formatDate } from '@/lib/format'
 import {
   type PortalChatEvent,
   type PortalChatMessage,
@@ -149,10 +150,12 @@ function foldEvents(events: PortalChatEvent[], timeZone: string): Entry[] {
   return entries
 }
 
-/** How the workshop prints its times: its zone and its 12 or 24 hour clock. */
+/** How the workshop prints its times: its zone, its 12 or 24 hour clock and its date format. */
 export interface PortalChatClock {
   timeZone: string
   timeFormat: '12h' | '24h'
+  /** The workshop's date format (Settings, Localization); the default one when left out. */
+  dateFormat?: string
 }
 
 /** The four ways the thread prints a moment, in the portal's language on the workshop's clock. */
@@ -166,7 +169,7 @@ export type PortalChatStampKind = 'time' | 'day' | 'shortDay' | 'dayWithYear'
 export function portalChatFormats(
   locale: string,
   clock: PortalChatClock
-): Record<PortalChatStampKind, Intl.DateTimeFormat> {
+): Record<PortalChatStampKind, { format: (date: Date) => string }> {
   const zone = { timeZone: clock.timeZone }
   return {
     time: new Intl.DateTimeFormat(locale, {
@@ -181,8 +184,12 @@ export function portalChatFormats(
       day: 'numeric',
       month: 'long',
     }),
-    // The day alone, for an event that has no time of day.
-    shortDay: new Intl.DateTimeFormat(locale, { ...zone, day: 'numeric', month: 'short' }),
+    // The day alone, for an event that has no time of day (an invoice's
+    // date): written the way the workshop writes dates, as on the invoice.
+    shortDay: {
+      format: (date) =>
+        formatDate(date, clock.dateFormat || DEFAULT_DATE_FORMAT, clock.timeZone, locale),
+    },
     dayWithYear: new Intl.DateTimeFormat(locale, {
       ...zone,
       day: 'numeric',

+ 1 - 1
src/features/portal/Lib/homeTypes.ts

@@ -243,7 +243,7 @@ export interface PortalHomeData {
  */
 export interface PortalHomeFormat {
   money: (amount: number) => string
-  /** "3 Dec" or "3 Dec 2027" when the year is not this one. */
+  /** The day in the workshop's date format: "03/12/2026" for dd/MM/yyyy. */
   day: (iso: string) => string
   /** "Thursday 3 December". */
   dayLong: (iso: string) => string

+ 18 - 16
src/features/portal/Lib/portalFormat.ts

@@ -3,14 +3,16 @@ import { SETTING_KEYS } from '@/features/settings/Schema/settingsSchema'
 import { MM_PER_32ND } from '@/features/tire-hotel/Lib/tireConstants'
 import { addDays } from '@/features/workshop-calendar/Lib/calendar'
 import { db } from '@/lib/db'
+import { DEFAULT_DATE_FORMAT, formatDate } from '@/lib/format'
 import { zonedDayKey } from '@/lib/timezone'
 import { workshopMoneyFormatter } from '@/lib/workshop-currency'
 import { workshopTimeZone } from '@/lib/workshop-timezone'
 import type { PortalHomeFormat } from './homeTypes'
 
 /**
- * Dates, times and money as the portal prints them: on the workshop's clock
- * and in its currency, in the language the portal is being read in.
+ * Dates, times and money as the portal prints them: on the workshop's clock,
+ * in its date format and its currency, in the language the portal is being
+ * read in.
  *
  * The portal's language is already the workshop's when it forces one for its
  * customers, and the customer's browser language otherwise (see
@@ -23,7 +25,12 @@ export async function portalFormat(organizationId: string): Promise<PortalHomeFo
     workshopTimeZone(organizationId),
     workshopMoneyFormatter(organizationId),
     db.appSetting.findMany({
-      where: { organizationId, key: { in: [SETTING_KEYS.TIME_FORMAT, SETTING_KEYS.UNIT_SYSTEM] } },
+      where: {
+        organizationId,
+        key: {
+          in: [SETTING_KEYS.TIME_FORMAT, SETTING_KEYS.DATE_FORMAT, SETTING_KEYS.UNIT_SYSTEM],
+        },
+      },
       select: { key: true, value: true },
     }),
     getTranslations('portal.format'),
@@ -34,6 +41,7 @@ export async function portalFormat(organizationId: string): Promise<PortalHomeFo
     locale,
     timeZone,
     timeFormat,
+    dateFormat: value(SETTING_KEYS.DATE_FORMAT) || DEFAULT_DATE_FORMAT,
     imperial: value(SETTING_KEYS.UNIT_SYSTEM) === 'imperial',
     money,
     today: t('today'),
@@ -46,6 +54,8 @@ export function buildPortalFormat(options: {
   locale: string
   timeZone: string
   timeFormat: '12h' | '24h'
+  /** The workshop's date format (Settings, Localization), such as "dd/MM/yyyy". */
+  dateFormat: string
   money: (amount: number) => string
   today: string
   tomorrow: string
@@ -54,15 +64,8 @@ export function buildPortalFormat(options: {
   /** The moment "today" is judged from; now when left out. */
   now?: Date
 }): PortalHomeFormat {
-  const { locale, timeZone, timeFormat, money } = options
+  const { locale, timeZone, timeFormat, dateFormat, money } = options
   const todayKey = () => zonedDayKey(options.now ?? new Date(), timeZone)
-  const withYear = new Intl.DateTimeFormat(locale, {
-    timeZone,
-    day: 'numeric',
-    month: 'short',
-    year: 'numeric',
-  })
-  const withoutYear = new Intl.DateTimeFormat(locale, { timeZone, day: 'numeric', month: 'short' })
   const long = new Intl.DateTimeFormat(locale, {
     timeZone,
     weekday: 'long',
@@ -80,11 +83,10 @@ export function buildPortalFormat(options: {
   // A bare "HH:mm" is already on the workshop's clock, so it is printed as
   // that moment in UTC to keep it from being shifted.
   const wallTime = new Intl.DateTimeFormat(locale, { timeZone: 'UTC', ...timeOptions })
-  const day = (iso: string) => {
-    const date = new Date(iso)
-    const sameYear = zonedDayKey(date, timeZone).slice(0, 4) === todayKey().slice(0, 4)
-    return (sameYear ? withoutYear : withYear).format(date)
-  }
+  // A calendar day is written the way the workshop writes it on its invoices
+  // and share pages, year included: "24/11/2026", never the language's own
+  // "24 Nov" beside a "24/11/2026" on the invoice it opens.
+  const day = (iso: string) => formatDate(new Date(iso), dateFormat, timeZone, locale)
   return {
     money,
     day,

+ 9 - 14
src/features/portal/Lib/workshop.server.ts

@@ -8,7 +8,11 @@ import { dayState } from '@/features/workshop-calendar/Lib/calendar'
 import { loadWorkshopCalendar } from '@/features/workshop-calendar/Lib/loadCalendar.server'
 import { db } from '@/lib/db'
 import { zonedDayKey } from '@/lib/timezone'
-import { workshopTimeZone } from '@/lib/workshop-timezone'
+import {
+  type WorkshopDateSettings,
+  workshopDateSettings,
+  workshopTimeZone,
+} from '@/lib/workshop-timezone'
 import { workshopHoursLine, workshopHoursNow } from './homeData'
 import type { PortalWorkshop } from './homeTypes'
 import { readPortalOpeningHours } from './openingHours.server'
@@ -102,19 +106,10 @@ export const loadPortalWorkshop = cache(
 )
 
 /**
- * How the workshop prints a time: its zone and its 12 or 24 hour clock. For
- * client components that print times themselves (the chat), which cannot be
- * handed `PortalHomeFormat`'s functions.
+ * How the workshop prints a time and a date: its zone, its 12 or 24 hour
+ * clock and its date format. For client components that print times
+ * themselves (the chat), which cannot be handed `PortalHomeFormat`'s functions.
  */
 export const portalClock = cache(
-  async (organizationId: string): Promise<{ timeZone: string; timeFormat: '12h' | '24h' }> => {
-    const [timeZone, row] = await Promise.all([
-      workshopTimeZone(organizationId),
-      db.appSetting.findFirst({
-        where: { organizationId, key: SETTING_KEYS.TIME_FORMAT },
-        select: { value: true },
-      }),
-    ])
-    return { timeZone, timeFormat: row?.value === '24h' ? '24h' : '12h' }
-  }
+  (organizationId: string): Promise<WorkshopDateSettings> => workshopDateSettings(organizationId)
 )

+ 4 - 2
src/features/settings/Components/license-settings.tsx

@@ -4,6 +4,7 @@ import { useState } from 'react'
 import Link from 'next/link'
 import { useRouter } from 'next/navigation'
 import { useLocale, useTranslations } from 'next-intl'
+import { useFormatDate } from '@/lib/use-format-date'
 import { toast } from 'sonner'
 import { Input } from '@/components/ui/input'
 import { Button } from '@/components/ui/button'
@@ -167,6 +168,7 @@ export function LicenseSettings({
 }) {
   const router = useRouter()
   const t = useTranslations('settings')
+  const { formatDate } = useFormatDate()
   const locale = useLocale()
   const [licenseKey, setLicenseKey] = useState(initialKey)
   const [status, setStatus] = useState<LicenseTokenStatus>(initialStatus)
@@ -291,12 +293,12 @@ export function LicenseSettings({
           )}
           {!perpetual && initialExpiresAt && (
             <span className="text-xs text-muted-foreground">
-              {t('license.expiresOn', { date: new Date(initialExpiresAt).toLocaleDateString() })}
+              {t('license.expiresOn', { date: formatDate(initialExpiresAt) })}
             </span>
           )}
           {!perpetual && initialCheckedAt && (
             <span className="text-xs text-muted-foreground">
-              {t('license.lastChecked', { date: new Date(initialCheckedAt).toLocaleDateString() })}
+              {t('license.lastChecked', { date: formatDate(initialCheckedAt) })}
             </span>
           )}
         </div>

+ 7 - 28
src/features/status-reports/Components/StatusReportList.tsx

@@ -5,6 +5,7 @@ import { interactiveRow } from '@/lib/interactive-row'
 import { useState } from 'react'
 import { useRouter } from 'next/navigation'
 import { useTranslations } from 'next-intl'
+import { useFormatDate } from '@/lib/use-format-date'
 import {
   Plus,
   Copy,
@@ -95,6 +96,7 @@ export function StatusReportList({
   initialReports,
 }: StatusReportListProps) {
   const t = useTranslations('statusReport.list')
+  const { formatDate, formatDateTime } = useFormatDate()
   const router = useRouter()
   const [showCreate, setShowCreate] = useState(false)
   const tableNav = useTableKeyboardNav()
@@ -135,15 +137,8 @@ export function StatusReportList({
     }
   }
 
-  function fmtDate(iso: string) {
-    return new Date(iso).toLocaleDateString(undefined, {
-      month: 'short',
-      day: 'numeric',
-      year: 'numeric',
-      hour: '2-digit',
-      minute: '2-digit',
-    })
-  }
+  // In the workshop's date format and on its clock, not the browser's.
+  const fmtDate = (iso: string) => formatDateTime(iso)
 
   return (
     <>
@@ -217,12 +212,7 @@ export function StatusReportList({
                         </Badge>
                       )}
                       <span className="text-xs text-muted-foreground" suppressHydrationWarning>
-                        {new Date(report.createdAt).toLocaleDateString(undefined, {
-                          month: 'short',
-                          day: 'numeric',
-                          hour: '2-digit',
-                          minute: '2-digit',
-                        })}
+                        {formatDateTime(report.createdAt)}
                       </span>
                     </div>
                   </button>
@@ -317,12 +307,7 @@ export function StatusReportList({
                             className="py-2 text-xs text-muted-foreground hidden sm:table-cell"
                             suppressHydrationWarning
                           >
-                            {new Date(report.createdAt).toLocaleDateString(undefined, {
-                              month: 'short',
-                              day: 'numeric',
-                              hour: '2-digit',
-                              minute: '2-digit',
-                            })}
+                            {formatDateTime(report.createdAt)}
                           </TableCell>
                           <TableCell className="py-2 hidden md:table-cell">
                             {report.customerFeedback ? (
@@ -465,13 +450,7 @@ export function StatusReportList({
                   {detailReport.expiresAt && (
                     <div>
                       <p className="text-xs text-muted-foreground">{t('expires')}</p>
-                      <p className="mt-0.5">
-                        {new Date(detailReport.expiresAt).toLocaleDateString(undefined, {
-                          month: 'short',
-                          day: 'numeric',
-                          year: 'numeric',
-                        })}
-                      </p>
+                      <p className="mt-0.5">{formatDate(detailReport.expiresAt)}</p>
                     </div>
                   )}
                 </div>

+ 14 - 9
src/features/status-reports/Lib/reportDay.ts

@@ -1,17 +1,22 @@
+import { formatDate } from '@/lib/format'
+import { safeTimeZone } from '@/lib/timezone'
+
 /**
  * The day a status report was made, as the customer reads it on the share
- * page: on the workshop's clock and in the page's language.
+ * page: on the workshop's clock and in the workshop's date format, the same
+ * way the expiry date beside it is written, with any month name in the
+ * page's language.
  *
  * Written on the server and sent down as text. Formatted in the browser it
  * was the phone's own day and the phone's own way of writing one, which is
  * neither, and differs from what the server had already rendered.
  */
-export function formatReportDay(createdAt: Date, locale: string, timeZone: string): string {
-  const options: Intl.DateTimeFormatOptions = { year: 'numeric', month: 'long', day: 'numeric' }
-  try {
-    return new Intl.DateTimeFormat(locale, { ...options, timeZone }).format(createdAt)
-  } catch {
-    // A zone this runtime does not know: the day in UTC rather than no day.
-    return new Intl.DateTimeFormat(locale, { ...options, timeZone: 'UTC' }).format(createdAt)
-  }
+export function formatReportDay(
+  createdAt: Date,
+  dateFormat: string,
+  timeZone: string,
+  locale?: string
+): string {
+  // A zone this runtime does not know: the day in UTC rather than no day.
+  return formatDate(createdAt, dateFormat, safeTimeZone(timeZone), locale)
 }

+ 6 - 3
src/features/telegram/Components/TelegramMessagesClient.tsx

@@ -3,6 +3,7 @@
 import { useState, useEffect, useCallback, useTransition, useRef } from 'react'
 import { useSearchParams, useRouter } from 'next/navigation'
 import { useTranslations } from 'next-intl'
+import { useFormatDate } from '@/lib/use-format-date'
 import { Trash2 } from 'lucide-react'
 import { useConfirm } from '@/components/confirm-dialog'
 import { toast } from 'sonner'
@@ -30,7 +31,7 @@ export interface TelegramMessage {
 
 const PAGE_SIZE = 50
 
-function formatRelativeTime(date: string | Date) {
+function formatRelativeTime(date: string | Date, formatDate: (date: Date) => string) {
   const diffMs = Date.now() - new Date(date).getTime()
   const mins = Math.floor(diffMs / 60000)
   if (mins < 1) return 'now'
@@ -39,7 +40,7 @@ function formatRelativeTime(date: string | Date) {
   if (hrs < 24) return `${hrs}h`
   const days = Math.floor(diffMs / 86400000)
   if (days < 7) return `${days}d`
-  return new Date(date).toLocaleDateString([], { month: 'short', day: 'numeric' })
+  return formatDate(new Date(date))
 }
 
 export function TelegramMessagesClient({
@@ -52,6 +53,8 @@ export function TelegramMessagesClient({
   const searchParams = useSearchParams()
   const router = useRouter()
   const t = useTranslations('telegramMessages.threads')
+  // An older thread's day in the workshop's date format, on its clock.
+  const { formatDate } = useFormatDate()
   const tc = useTranslations('common.buttons')
   const [threads, setThreads] = useState<TelegramThread[]>(initialThreads)
   const [hasMore, setHasMore] = useState(initialHasMore)
@@ -202,7 +205,7 @@ export function TelegramMessagesClient({
         isLoadingMore={isLoadingMore}
         onSelectThread={handleSelectThread}
         onLoadMore={handleLoadMore}
-        formatRelativeTime={formatRelativeTime}
+        formatRelativeTime={(date: string | Date) => formatRelativeTime(date, formatDate)}
         t={t}
       />
       <TelegramConversationPanel

+ 4 - 1
src/features/vehicles/Components/PlateLookupCommand.tsx

@@ -3,6 +3,7 @@
 import { useGuardedPush } from '@/hooks/use-guarded-push'
 import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import { useFormatter, useTranslations } from 'next-intl'
+import { useFormatDate } from '@/lib/use-format-date'
 import {
   ArrowRight,
   Building2,
@@ -79,6 +80,7 @@ export function PlateLookupCommand() {
   const t = useTranslations('vehicles.plateLookup')
   const tf = useTranslations('vehicles.form')
   const format = useFormatter()
+  const { formatDay } = useFormatDate()
   const go = useGuardedPush()
   const { available, canCreate, registryName } = usePlateLookupAccess()
   const { canBook } = useBookingAccess()
@@ -220,7 +222,8 @@ export function PlateLookupCommand() {
     const known = ['automatic', 'manual', 'cvt']
     return known.includes(gearbox) ? tf(gearbox) : gearbox
   }
-  const date = (iso: string) => format.dateTime(new Date(iso), { dateStyle: 'medium' })
+  // Registry dates in the workshop's date format; a bare day stays that day.
+  const date = (iso: string) => formatDay(iso)
 
   const registry = result?.registry ?? null
   const vehicle = result?.vehicle ?? null

+ 3 - 2
src/features/vehicles/Components/ReminderFormDialog.tsx

@@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from 'react'
 import { useTranslations } from 'next-intl'
 import { useDateSettings } from '@/components/date-settings-context'
 import { zonedDateInput, zonedTimeInput } from '@/lib/timezone'
-import { format } from 'date-fns'
+import { useFormatDate } from '@/lib/use-format-date'
 import { Button } from '@/components/ui/button'
 import { Input } from '@/components/ui/input'
 import { Label } from '@/components/ui/label'
@@ -103,6 +103,7 @@ export function ReminderFormDialog({
   onSaved,
 }: ReminderFormDialogProps) {
   const t = useTranslations('reminders')
+  const { formatDay } = useFormatDate()
   const { timezone } = useDateSettings()
   const tv = useTranslations('vehicles.reminders')
   const tc = useTranslations('common.buttons')
@@ -441,7 +442,7 @@ export function ReminderFormDialog({
                     )}
                   >
                     <CalendarIcon className="mr-2 h-4 w-4" />
-                    {formDueDate ? format(formDueDate, 'PPP') : t('pickDate')}
+                    {formDueDate ? formatDay(formDueDate) : t('pickDate')}
                   </Button>
                 </PopoverTrigger>
                 <PopoverContent className="w-auto p-0" align="start">

+ 5 - 8
src/features/vehicles/Components/VehicleForm.tsx

@@ -43,6 +43,7 @@ import {
 } from '@/features/customers/Actions/customerActions'
 import { CustomerCombobox } from '@/features/quotes/Components/CustomerCombobox'
 import { useFormatter, useTranslations } from 'next-intl'
+import { useFormatDate } from '@/lib/use-format-date'
 import { useServiceType } from '@/components/service-type-context'
 import type { CreateVehicleInput } from '../Schema/vehicleSchema'
 import { clearableInput } from '@/lib/clearable'
@@ -189,6 +190,7 @@ export function VehicleForm({
   const tc = useTranslations('common.buttons')
   const tCommon = useTranslations('common')
   const format = useFormatter()
+  const { formatDay } = useFormatDate()
   const [loading, setLoading] = useState(false)
   // What the server refused, said under each field it was about.
   const fieldErrors = useFieldErrors()
@@ -797,11 +799,8 @@ export function VehicleForm({
   const mileageInputRef = useRef<HTMLInputElement>(null)
   const inspectionShown = inspectionDraft
     ? {
-        // A date key, read at noon UTC so it names the same day everywhere.
-        text: format.dateTime(new Date(`${inspectionDraft}T12:00:00Z`), {
-          dateStyle: 'medium',
-          timeZone: 'UTC',
-        }),
+        // A date key: the same day everywhere, in the workshop's date format.
+        text: formatDay(inspectionDraft),
         tone: inspectionTone(inspectionDraft),
       }
     : null
@@ -1247,9 +1246,7 @@ export function VehicleForm({
                       {lookupNote.inspectionDue
                         ? t('lookupInspectionDue', {
                             source: lookupNote.source,
-                            date: format.dateTime(new Date(lookupNote.inspectionDue), {
-                              dateStyle: 'medium',
-                            }),
+                            date: formatDay(lookupNote.inspectionDue),
                           })
                         : t('lookupSource', { source: lookupNote.source })}
                     </p>

+ 18 - 38
src/features/vehicles/Components/service-edit/ScheduleTimesSection.tsx

@@ -38,6 +38,7 @@ import {
 import { toast } from 'sonner'
 import { DateTimePicker } from '@/components/ui/datetime-picker'
 import { useDateSettings } from '@/components/date-settings-context'
+import { useFormatDate } from '@/lib/use-format-date'
 import {
   addJobHelper,
   assignTechnician,
@@ -135,6 +136,7 @@ export function ScheduleTimesSection({
   // Booked times belong to the workshop's clock, not to the clock of whoever
   // happens to be looking at them.
   const { timezone } = useDateSettings()
+  const { formatDate, formatDateTime, formatTime } = useFormatDate()
   const [selectedTechId, setSelectedTechId] = useState(initialTechnicianId || '')
   // Who else is on the job. Only ever beside a technician: a job with nobody
   // leading it has no helpers either.
@@ -841,11 +843,7 @@ export function ScheduleTimesSection({
             {startDateTime && technicians.length > 0 && (
               <span className="text-[11px] text-muted-foreground" suppressHydrationWarning>
                 {t('loadOn', {
-                  date: startDateTime.toLocaleDateString(undefined, {
-                    day: 'numeric',
-                    month: 'short',
-                    timeZone: timezone || undefined,
-                  }),
+                  date: formatDate(startDateTime),
                 })}
               </span>
             )}
@@ -962,7 +960,6 @@ export function ScheduleTimesSection({
               granularity="minute"
               hourCycle={24}
               placeholder={t('startTime')}
-              displayFormat={{ hour24: 'PPP HH:mm' }}
             />
           ) : (
             <div className="h-9 rounded-md border" />
@@ -982,7 +979,6 @@ export function ScheduleTimesSection({
               granularity="minute"
               hourCycle={24}
               placeholder={t('endTime')}
-              displayFormat={{ hour24: 'PPP HH:mm' }}
             />
           ) : (
             <div className="h-9 rounded-md border" />
@@ -1063,24 +1059,13 @@ export function ScheduleTimesSection({
                               : c.label,
                           })}
                           {' · '}
-                          {awayWhen(c.start, c.end, timezone)}
+                          {awayWhen(c.start, c.end, timezone, formatDate, formatDateTime)}
                         </>
                       ) : (
                         <>
-                          {c.label || t('anotherJob')} ·{' '}
-                          {new Date(c.start).toLocaleString(undefined, {
-                            day: 'numeric',
-                            month: 'short',
-                            hour: '2-digit',
-                            minute: '2-digit',
-                            timeZone: timezone || undefined,
-                          })}
+                          {c.label || t('anotherJob')} · {formatDateTime(c.start)}
                           {' – '}
-                          {new Date(c.end).toLocaleTimeString(undefined, {
-                            hour: '2-digit',
-                            minute: '2-digit',
-                            timeZone: timezone || undefined,
-                          })}
+                          {formatTime(c.end)}
                           {' · '}
                           {c.onTechnician && c.onBay
                             ? t('clashBoth')
@@ -1146,7 +1131,6 @@ export function ScheduleTimesSection({
               granularity="minute"
               hourCycle={24}
               placeholder={t('promisedPlaceholder')}
-              displayFormat={{ hour24: 'PPP HH:mm' }}
             />
           ) : (
             <div className="h-9 rounded-md border" />
@@ -1158,23 +1142,19 @@ export function ScheduleTimesSection({
 }
 
 /**
- * When a technician is away, as days: "16 Nov – 17 Nov", or with a clock
- * only where the time off starts or ends inside a day. The end of a stretch
- * is the midnight after its last day, which reads as that last day.
+ * When a technician is away, as days in the workshop's date format
+ * ("16/11/2026 – 17/11/2026"), with a clock only where the time off starts or
+ * ends inside a day. The end of a stretch is the midnight after its last day,
+ * which reads as that last day.
  */
-function awayWhen(startIso: string, endIso: string, timeZone: string | null | undefined): string {
-  const zone = timeZone || undefined
-  const { start, end, startClock, endClock } = awayEdges(startIso, endIso, zone)
-  const day = (at: Date) =>
-    at.toLocaleDateString(undefined, { day: 'numeric', month: 'short', timeZone: zone })
-  const dayAndClock = (at: Date) =>
-    at.toLocaleString(undefined, {
-      day: 'numeric',
-      month: 'short',
-      hour: '2-digit',
-      minute: '2-digit',
-      timeZone: zone,
-    })
+function awayWhen(
+  startIso: string,
+  endIso: string,
+  timeZone: string | null | undefined,
+  day: (at: Date) => string,
+  dayAndClock: (at: Date) => string
+): string {
+  const { start, end, startClock, endClock } = awayEdges(startIso, endIso, timeZone || undefined)
   const from = startClock ? dayAndClock(start) : day(start)
   const to = endClock ? dayAndClock(end) : day(end)
   return from === to ? from : `${from} – ${to}`

+ 3 - 2
src/features/vehicles/Components/service-page/ServicePageClient.tsx

@@ -81,6 +81,7 @@ import {
 } from '@/features/inventory/Lib/partPricing'
 import { vehicleName } from '@/lib/vehicle-name'
 import { useDateSettings } from '@/components/date-settings-context'
+import { useFormatDate } from '@/lib/use-format-date'
 import { addDaysToDayKey, dayKeyToLocalDate, workshopTodayKey } from '@/lib/workshop-datetime'
 
 export type { ServicePageClientProps, BoardTechnicianOption } from './service-page-types'
@@ -229,8 +230,8 @@ export function ServicePageClient({
   const [updatingDates, setUpdatingDates] = useState(false)
   const [customizingDates, setCustomizingDates] = useState(false)
 
-  const formatDate = (date: Date) =>
-    date.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })
+  // The picked days, in the workshop's date format.
+  const { formatDay: formatDate } = useFormatDate()
   const toISODate = (date: Date) =>
     `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
 

+ 0 - 2
src/features/workboard/Components/JobDetailPopover.tsx

@@ -203,7 +203,6 @@ export function JobDetailPopover({
               granularity="minute"
               hourCycle={24}
               placeholder={t('startTime')}
-              displayFormat={{ hour24: 'PPP HH:mm' }}
             />
           </div>
 
@@ -219,7 +218,6 @@ export function JobDetailPopover({
               granularity="minute"
               hourCycle={24}
               placeholder={t('endTime')}
-              displayFormat={{ hour24: 'PPP HH:mm' }}
             />
           </div>
 

+ 11 - 4
src/features/workboard/Components/JobTooltip.tsx

@@ -11,6 +11,7 @@ import { normalizeStatus } from '../utils/job-colors'
 import { formatDuration } from './DurationSlider'
 import { isPromiseOverdue } from '@/features/vehicles/Lib/promise'
 import { useDateSettings } from '@/components/date-settings-context'
+import { formatDate } from '@/lib/format'
 import { toBoardDate } from '../utils/board-time'
 import { vehicleName } from '@/lib/vehicle-name'
 
@@ -52,7 +53,7 @@ export function JobTooltip({
 }) {
   const t = useTranslations('workBoard.job')
   const tStatus = useTranslations('workBoard.presenter.statusLabels')
-  const { timezone } = useDateSettings()
+  const { timezone, dateFormat } = useDateSettings()
 
   // The job as the board draws it, already on the workshop's clock.
   const { start, end } = getJobDateRange(job)
@@ -119,7 +120,7 @@ export function JobTooltip({
           {job.promisedAt && (
             <Row
               label={t('promised')}
-              value={formatPromised(job.promisedAt, timeFormat, timezone)}
+              value={formatPromised(job.promisedAt, timeFormat, timezone, dateFormat)}
               late={isPromiseOverdue(job.promisedAt, job.status)}
             />
           )}
@@ -141,10 +142,16 @@ export function JobTooltip({
  * real instant (the board only rewrites a job's start and end), so it is put
  * on the workshop's clock here.
  */
-function formatPromised(promisedAt: string, timeFormat: ClockFormat, timeZone: string): string {
+function formatPromised(
+  promisedAt: string,
+  timeFormat: ClockFormat,
+  timeZone: string,
+  dateFormat: string
+): string {
   const at = toBoardDate(new Date(promisedAt), timeZone)
   const time = formatClock(at.getHours() * 60 + at.getMinutes(), timeFormat)
-  return `${at.toLocaleDateString(undefined, { day: 'numeric', month: 'short' })} ${time}`
+  // `at` already carries the workshop's wall clock, so no zone here.
+  return `${formatDate(at, dateFormat)} ${time}`
 }
 
 function Row({

+ 14 - 10
src/lib/cron/report-schedules.ts

@@ -1,6 +1,7 @@
 import { resolveCurrencyCode, resolveCurrencyFormat } from '@/lib/currencies'
 import { CronJob } from 'cron'
 import { db } from '@/lib/db'
+import { DEFAULT_DATE_FORMAT, formatDate, formatDayKey } from '@/lib/format'
 import { renderToBuffer } from '@react-pdf/renderer'
 import { pdfFontsReady } from '@/features/vehicles/Components/invoice-pdf/fonts'
 import React from 'react'
@@ -110,14 +111,8 @@ function getDateRange(dateRange: string, now: Date, timeZone: string): { start:
 }
 
 /** The period as the email reads it; `end` is exclusive, so the last day shown is the one before. */
-function formatDateRange(start: Date, end: Date, timeZone: string): string {
-  const fmt = (d: Date) =>
-    d.toLocaleDateString('en-US', {
-      timeZone,
-      month: 'short',
-      day: 'numeric',
-      year: 'numeric',
-    })
+function formatDateRange(start: Date, end: Date, timeZone: string, dateFormat: string): string {
+  const fmt = (d: Date) => formatDate(d, dateFormat, timeZone)
   return `${fmt(start)} – ${fmt(new Date(end.getTime() - 1))}`
 }
 
@@ -545,7 +540,6 @@ export async function processOneSchedule(
   const sections: string[] = JSON.parse(schedule.sections)
   const recipientIds: string[] = JSON.parse(schedule.recipients)
   const { start, end } = getDateRange(schedule.dateRange || 'last30d', now, timeZone)
-  const dateRangeStr = formatDateRange(start, end, timeZone)
 
   // Fetch org settings
   const settings = await db.appSetting.findMany({
@@ -556,6 +550,7 @@ export async function processOneSchedule(
           SETTING_KEYS.CURRENCY_CODE,
           SETTING_KEYS.CURRENCY_FORMAT,
           SETTING_KEYS.INVOICE_PRIMARY_COLOR,
+          SETTING_KEYS.DATE_FORMAT,
         ],
       },
     },
@@ -567,6 +562,9 @@ export async function processOneSchedule(
     settingsMap[SETTING_KEYS.CURRENCY_FORMAT]
   )
   const primaryColor = settingsMap[SETTING_KEYS.INVOICE_PRIMARY_COLOR] || '#d97706'
+  // The range and the days in the report read in the workshop's date format.
+  const dateFormat = settingsMap[SETTING_KEYS.DATE_FORMAT] || DEFAULT_DATE_FORMAT
+  const dateRangeStr = formatDateRange(start, end, timeZone, dateFormat)
 
   // Fetch report data for selected sections
   const [
@@ -608,7 +606,13 @@ export async function processOneSchedule(
     labels: {},
     revenueData,
     taxData,
-    pastDueData,
+    pastDueData: pastDueData && {
+      ...pastDueData,
+      invoices: pastDueData.invoices.map((inv) => ({
+        ...inv,
+        dueDate: formatDayKey(inv.dueDate, dateFormat),
+      })),
+    },
     serviceData,
     customerData,
     technicianData,

+ 135 - 100
src/lib/format.ts

@@ -4,6 +4,7 @@ import {
   DEFAULT_CURRENCY_CODE,
   DEFAULT_CURRENCY_FORMAT,
 } from '@/lib/currencies'
+import { zonedParts } from '@/lib/timezone'
 
 export { type CurrencyFormat, DEFAULT_CURRENCY_FORMAT } from '@/lib/currencies'
 
@@ -91,36 +92,46 @@ export function getCurrencySymbol(
 }
 
 /**
- * Convert a date to a specific timezone by shifting its local representation.
- * Uses Intl.DateTimeFormat to get the date parts in the target timezone,
- * then reconstructs a Date object whose local time matches those parts.
+ * The fields a date pattern prints: the wall clock in `timezone` when one is
+ * given, else this runtime's own. Read straight from Intl, never by building
+ * a browser-local Date out of them: a local Date cannot hold a wall-clock
+ * time that falls in the viewer's own DST gap (02:30 on the night Los
+ * Angeles springs forward does not exist there and comes out as 03:30).
  */
-function toTimezone(date: Date, timezone: string): Date {
-  try {
-    const parts = new Intl.DateTimeFormat('en-US', {
-      timeZone: timezone,
-      year: 'numeric',
-      month: '2-digit',
-      day: '2-digit',
-      hour: '2-digit',
-      minute: '2-digit',
-      second: '2-digit',
-      hour12: false,
-    }).formatToParts(date)
-
-    const get = (type: Intl.DateTimeFormatPartTypes) =>
-      Number(parts.find((p) => p.type === type)?.value || 0)
-
-    return new Date(
-      get('year'),
-      get('month') - 1,
-      get('day'),
-      get('hour') === 24 ? 0 : get('hour'),
-      get('minute'),
-      get('second')
-    )
-  } catch {
-    return date
+interface DateFields {
+  year: number
+  /** 1 to 12. */
+  month: number
+  day: number
+  hour: number
+  minute: number
+  second: number
+}
+
+function fieldsOf(date: Date, timezone?: string): DateFields {
+  if (timezone) {
+    try {
+      const p = zonedParts(date, timezone)
+      return {
+        year: p.year,
+        month: p.month,
+        day: p.day,
+        hour: p.hour,
+        minute: p.minute,
+        // No zone in use today is offset by a part of a minute.
+        second: date.getUTCSeconds(),
+      }
+    } catch {
+      // A zone this runtime does not know: the runtime's own clock below.
+    }
+  }
+  return {
+    year: date.getFullYear(),
+    month: date.getMonth() + 1,
+    day: date.getDate(),
+    hour: date.getHours(),
+    minute: date.getMinutes(),
+    second: date.getSeconds(),
   }
 }
 
@@ -130,48 +141,56 @@ function toTimezone(date: Date, timezone: string): Date {
 export const DEFAULT_DATE_FORMAT = 'MMM d, yyyy'
 export const DEFAULT_TIME_FORMAT = '12h' as const
 
+const MONTHS_LONG = [
+  'January',
+  'February',
+  'March',
+  'April',
+  'May',
+  'June',
+  'July',
+  'August',
+  'September',
+  'October',
+  'November',
+  'December',
+]
+const MONTHS_SHORT = MONTHS_LONG.map((name) => name.slice(0, 3))
+
+const monthNames = new Map<string, { long: string[]; short: string[] }>()
+
+/**
+ * The month names of a language, from the runtime's own data (every locale
+ * the app ships, with no date library to bundle). Without a language, or for
+ * one the runtime does not know, the English names the app has always used.
+ */
+function monthsFor(locale?: string): { long: string[]; short: string[] } {
+  if (!locale) return { long: MONTHS_LONG, short: MONTHS_SHORT }
+  let names = monthNames.get(locale)
+  if (!names) {
+    try {
+      const name = (month: 'long' | 'short') => {
+        // Standalone, not in a date: "november", not a genitive form.
+        const f = new Intl.DateTimeFormat(locale, { month, timeZone: 'UTC' })
+        return Array.from({ length: 12 }, (_, i) => f.format(new Date(Date.UTC(2000, i, 15))))
+      }
+      names = { long: name('long'), short: name('short') }
+    } catch {
+      names = { long: MONTHS_LONG, short: MONTHS_SHORT }
+    }
+    monthNames.set(locale, names)
+  }
+  return names
+}
+
 /**
  * Simple date-fns-style format function that handles common tokens.
  * Tokens: yyyy, yy, MMMM, MMM, MM, dd, d, HH, hh, mm, ss, a
  */
-function formatWithPattern(date: Date, pattern: string): string {
-  const months = [
-    'January',
-    'February',
-    'March',
-    'April',
-    'May',
-    'June',
-    'July',
-    'August',
-    'September',
-    'October',
-    'November',
-    'December',
-  ]
-  const monthsShort = [
-    'Jan',
-    'Feb',
-    'Mar',
-    'Apr',
-    'May',
-    'Jun',
-    'Jul',
-    'Aug',
-    'Sep',
-    'Oct',
-    'Nov',
-    'Dec',
-  ]
-
-  const y = date.getFullYear()
-  const M = date.getMonth()
-  const d = date.getDate()
-  const H = date.getHours()
-  const m = date.getMinutes()
-  const s = date.getSeconds()
-  const h12 = H % 12 || 12
-  const ampm = H < 12 ? 'AM' : 'PM'
+function formatWithPattern(f: DateFields, pattern: string, locale?: string): string {
+  const months = monthsFor(locale)
+  const h12 = f.hour % 12 || 12
+  const ampm = f.hour < 12 ? 'AM' : 'PM'
 
   // Use placeholders for month names to avoid collisions with later replacements
   // (e.g. "a" in "May" being replaced by the AM/PM token)
@@ -179,33 +198,57 @@ function formatWithPattern(date: Date, pattern: string): string {
   const MONTH_SHORT = '\x02'
 
   return pattern
-    .replace('yyyy', String(y))
-    .replace('yy', String(y).slice(-2))
+    .replace('yyyy', String(f.year))
+    .replace('yy', String(f.year).slice(-2))
     .replace('MMMM', MONTH_LONG)
     .replace('MMM', MONTH_SHORT)
-    .replace('MM', String(M + 1).padStart(2, '0'))
-    .replace(/\bdd\b/, String(d).padStart(2, '0'))
-    .replace(/\bd\b/, String(d))
-    .replace('HH', String(H).padStart(2, '0'))
+    .replace('MM', String(f.month).padStart(2, '0'))
+    .replace(/\bdd\b/, String(f.day).padStart(2, '0'))
+    .replace(/\bd\b/, String(f.day))
+    .replace('HH', String(f.hour).padStart(2, '0'))
     .replace('hh', String(h12).padStart(2, '0'))
-    .replace('mm', String(m).padStart(2, '0'))
-    .replace('ss', String(s).padStart(2, '0'))
+    .replace('mm', String(f.minute).padStart(2, '0'))
+    .replace('ss', String(f.second).padStart(2, '0'))
     .replace('a', ampm)
-    .replace(MONTH_LONG, months[M])
-    .replace(MONTH_SHORT, monthsShort[M])
+    .replace(MONTH_LONG, months.long[f.month - 1])
+    .replace(MONTH_SHORT, months.short[f.month - 1])
 }
 
+const toDate = (date: Date | string) => (typeof date === 'string' ? new Date(date) : date)
+
 /**
- * Format a date using the org date format and optional timezone.
+ * Format a date using the org date format and optional timezone. `locale`
+ * names the months for a format that spells them ("d MMMM yyyy"); without
+ * one they are English.
  */
 export function formatDate(
   date: Date | string,
   dateFormat: string = DEFAULT_DATE_FORMAT,
-  timezone?: string
+  timezone?: string,
+  locale?: string
 ): string {
-  let d = typeof date === 'string' ? new Date(date) : date
-  if (timezone) d = toTimezone(d, timezone)
-  return formatWithPattern(d, dateFormat)
+  return formatWithPattern(fieldsOf(toDate(date), timezone), dateFormat, locale)
+}
+
+/**
+ * A calendar day already worked out on the workshop's clock ("2026-11-24",
+ * as `zonedDayKey` gives it) in the org date format. No zone is applied: the
+ * key is the day, whatever clock formats it. Anything that is not a key is
+ * returned as it is.
+ */
+export function formatDayKey(
+  key: string,
+  dateFormat: string = DEFAULT_DATE_FORMAT,
+  locale?: string
+): string {
+  const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(key)
+  if (!m) return key
+  const fields = { year: Number(m[1]), month: Number(m[2]), day: Number(m[3]) }
+  return formatWithPattern({ ...fields, hour: 0, minute: 0, second: 0 }, dateFormat, locale)
+}
+
+function timeOf(f: DateFields, timeFormat: '12h' | '24h'): string {
+  return formatWithPattern(f, timeFormat === '24h' ? 'HH:mm' : 'hh:mm a')
 }
 
 /**
@@ -215,14 +258,11 @@ export function formatDateTime(
   date: Date | string,
   dateFormat: string = DEFAULT_DATE_FORMAT,
   timeFormat: '12h' | '24h' = '12h',
-  timezone?: string
+  timezone?: string,
+  locale?: string
 ): string {
-  let d = typeof date === 'string' ? new Date(date) : date
-  if (timezone) d = toTimezone(d, timezone)
-  const datePart = formatWithPattern(d, dateFormat)
-  const timePart =
-    timeFormat === '24h' ? formatWithPattern(d, 'HH:mm') : formatWithPattern(d, 'hh:mm a')
-  return `${datePart} ${timePart}`
+  const f = fieldsOf(toDate(date), timezone)
+  return `${formatWithPattern(f, dateFormat, locale)} ${timeOf(f, timeFormat)}`
 }
 
 /**
@@ -233,23 +273,18 @@ export function formatTime(
   timeFormat: '12h' | '24h' = '12h',
   timezone?: string
 ): string {
-  let d = typeof date === 'string' ? new Date(date) : date
-  if (timezone) d = toTimezone(d, timezone)
-  return timeFormat === '24h' ? formatWithPattern(d, 'HH:mm') : formatWithPattern(d, 'hh:mm a')
+  return timeOf(fieldsOf(toDate(date), timezone), timeFormat)
 }
 
 /**
- * Format a date for server-side PDF/invoice rendering (uses toLocaleDateString for full month names).
- * Applies timezone if provided, otherwise UTC for server contexts.
+ * Format a date for server-side PDF/invoice rendering.
+ * Applies timezone if provided, otherwise the runtime's own clock.
  */
 export function formatDateForPdf(
   date: Date | string,
   dateFormat: string = DEFAULT_DATE_FORMAT,
-  timezone?: string
+  timezone?: string,
+  locale?: string
 ): string {
-  let d = typeof date === 'string' ? new Date(date) : date
-  if (timezone) {
-    d = toTimezone(d, timezone)
-  }
-  return formatWithPattern(d, dateFormat)
+  return formatDate(date, dateFormat, timezone, locale)
 }

+ 13 - 0
src/lib/use-format-date.ts

@@ -4,6 +4,7 @@ import { useDateSettings } from '@/components/date-settings-context'
 import {
   formatDate as fmtDate,
   formatDateTime as fmtDateTime,
+  formatDayKey,
   formatTime as fmtTime,
 } from '@/lib/format'
 
@@ -15,5 +16,17 @@ export function useFormatDate() {
     formatDate: (date: Date | string) => fmtDate(date, dateFormat, tz),
     formatDateTime: (date: Date | string) => fmtDateTime(date, dateFormat, timeFormat, tz),
     formatTime: (date: Date | string) => fmtTime(date, timeFormat, tz),
+    /**
+     * A calendar day that is already a day, not an instant: a "YYYY-MM-DD"
+     * key, or a date picker's local midnight. Written in the workshop's date
+     * format without moving it through any zone. Any other string is an
+     * instant, and is read on the workshop's clock like `formatDate`.
+     */
+    formatDay: (day: Date | string) =>
+      typeof day !== 'string'
+        ? fmtDate(day, dateFormat)
+        : /^\d{4}-\d{2}-\d{2}$/.test(day)
+          ? formatDayKey(day, dateFormat)
+          : fmtDate(day, dateFormat, tz),
   }
 }

+ 39 - 0
src/lib/workshop-timezone.ts

@@ -1,5 +1,6 @@
 import { SETTING_KEYS } from '@/features/settings/Schema/settingsSchema'
 import { db } from '@/lib/db'
+import { DEFAULT_DATE_FORMAT } from '@/lib/format'
 import { resolveWorkshopTimeZone } from '@/lib/timezone'
 
 export { resolveWorkshopTimeZone }
@@ -23,3 +24,41 @@ export async function workshopTimeZone(organizationId: string): Promise<string>
     map.get(SETTING_KEYS.TIMEZONE_DETECTED)
   )
 }
+
+export interface WorkshopDateSettings {
+  timeZone: string
+  dateFormat: string
+  timeFormat: '12h' | '24h'
+}
+
+/**
+ * How the workshop writes a date and a time, and the zone it reads them in,
+ * for server code that renders dates a customer reads: share pages and the
+ * portal. Hand the result to `formatDate`/`formatDateTime` from `@/lib/format`;
+ * never format with the viewer's or the server's locale.
+ */
+export async function workshopDateSettings(organizationId: string): Promise<WorkshopDateSettings> {
+  const rows = await db.appSetting.findMany({
+    where: {
+      organizationId,
+      key: {
+        in: [
+          SETTING_KEYS.TIMEZONE,
+          SETTING_KEYS.TIMEZONE_DETECTED,
+          SETTING_KEYS.DATE_FORMAT,
+          SETTING_KEYS.TIME_FORMAT,
+        ],
+      },
+    },
+    select: { key: true, value: true },
+  })
+  const map = new Map(rows.map((r) => [r.key, r.value]))
+  return {
+    timeZone: resolveWorkshopTimeZone(
+      map.get(SETTING_KEYS.TIMEZONE),
+      map.get(SETTING_KEYS.TIMEZONE_DETECTED)
+    ),
+    dateFormat: map.get(SETTING_KEYS.DATE_FORMAT) || DEFAULT_DATE_FORMAT,
+    timeFormat: map.get(SETTING_KEYS.TIME_FORMAT) === '24h' ? '24h' : '12h',
+  }
+}