diff --git a/src/lib/date.ts b/src/lib/date.ts new file mode 100644 index 0000000..cf0e77c --- /dev/null +++ b/src/lib/date.ts @@ -0,0 +1,4 @@ +import { format } from "date-fns"; + +export const format_date = (date: string, formatstring: string): string => + format(new Date(date), formatstring); diff --git a/src/routes/racepicks/+page.svelte b/src/routes/racepicks/+page.svelte index 7885ab8..792c62e 100644 --- a/src/routes/racepicks/+page.svelte +++ b/src/routes/racepicks/+page.svelte @@ -19,9 +19,9 @@ RACE_PICTOGRAM_HEIGHT, RACE_PICTOGRAM_WIDTH, } from "$lib/config"; + import { format_date } from "$lib/date"; import type { CurrentPickedUser, RacePick } from "$lib/schema"; import { get_by_value, get_driver_headshot_template } from "$lib/database"; - import { format } from "date-fns"; let { data }: { data: PageData } = $props(); @@ -63,7 +63,6 @@ ); const dateformat: string = "dd.MM' 'HH:mm"; - const formatdate = (date: string): string => format(new Date(date), dateformat); const race_popupsettings = (target: string): PopupSettings => { return { @@ -96,20 +95,20 @@ {#if data.currentrace.sprintdate}
SQuali: - {formatdate(data.currentrace.sprintqualidate)} + {format_date(data.currentrace.sprintqualidate, dateformat)}
SRace: - {formatdate(data.currentrace.sprintdate)} + {format_date(data.currentrace.sprintdate, dateformat)}
{/if}
Quali: - {formatdate(data.currentrace.qualidate)} + {format_date(data.currentrace.qualidate, dateformat)}
Race: - {formatdate(data.currentrace.racedate)} + {format_date(data.currentrace.racedate, dateformat)}
@@ -265,7 +264,9 @@ {race?.name.slice(0, 8)}{(race?.name.length ?? 8) > 8 ? "." : ""} - +