Show dates, times and prices in a European format and the studio's timezone

Formatting with the default locale rendered US dates (MM/DD/YYYY, 12-hour)
on the server. Everything shown to people now uses DISPLAY_LOCALE (en-GB)
and booking times use SITE_TIMEZONE. The public layout reloads on every
navigation so places left are never stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
This commit is contained in:
agent 2026-10-24 09:32:56 +00:00
parent 7075ab7883
commit 214db95186
5 changed files with 47 additions and 21 deletions

View file

@ -2,6 +2,8 @@ import { defaultColors, defaultFooter, defaultHeader } from '$lib/types';
import type { ItemRecord, SlotRecord } from '$lib/types';
import { BASKET_COOKIE, getBasket } from '$lib/server/shop';
import { loadShopData } from '$shared/server/shop';
import { DEFAULT_TIMEZONE } from '$shared/calendar';
import { env } from '$env/dynamic/private';
import type { LayoutServerLoad } from './$types';
async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
@ -13,7 +15,12 @@ async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
}
}
export const load: LayoutServerLoad = async ({ locals, cookies }) => {
export const load: LayoutServerLoad = async ({ locals, cookies, url }) => {
// Reading the path makes this load run again on every navigation, so the
// slots and basket are fresh on each page — places free up or get taken
// (holds lapse, other customers book) while the visitor browses.
void url.pathname;
const [header, footer, colors] = await Promise.all([
getGlobal(locals.pb, 'header', defaultHeader),
getGlobal(locals.pb, 'footer', defaultFooter),
@ -35,5 +42,8 @@ export const load: LayoutServerLoad = async ({ locals, cookies }) => {
const items: ItemRecord[] = shop?.items ?? [];
const slots: SlotRecord[] = shop?.slots ?? [];
return { header, footer, colors, user: locals.user, basket, items, slots };
// Booking times are shown in the studio's timezone, wherever the visitor is.
const timezone = env.SITE_TIMEZONE || DEFAULT_TIMEZONE;
return { header, footer, colors, user: locals.user, basket, items, slots, timezone };
};

View file

@ -1,21 +1,12 @@
<script lang="ts">
import { onMount } from 'svelte';
import { formatInstant, formatPrice } from '$shared/calendar';
let { data } = $props();
// "Friday 15 January, 10:00" in the studio's timezone.
function formatSlotDate(iso?: string | null) {
if (!iso) return '';
return new Date(iso).toLocaleString(undefined, {
weekday: 'long',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
}
function formatPrice(amount: number) {
return new Intl.NumberFormat(undefined, { style: 'currency', currency: 'EUR' }).format(amount);
return formatInstant(iso, data.timezone, { weekday: 'long', day: 'numeric', month: 'long', hour: '2-digit', minute: '2-digit' });
}
</script>