Add trains endpoint handler
All checks were successful
Publish Package / build-and-publish (push) Successful in 8s

This commit is contained in:
2026-04-27 22:28:55 +01:00
parent d10dabf604
commit 3c81b5225f
7 changed files with 128 additions and 6 deletions

20
src/lib/helpers.ts Normal file
View File

@@ -0,0 +1,20 @@
/**
* Normalises input to YYYY-MM-DD string
* - Strings are passed through as is
* - Date objects are converted to UK time
*/
export const ensureDateString = (input: Date | string): string => {
if (typeof input === 'string') return input.trim();
const d = new Intl.DateTimeFormat('en-GB', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
timeZone: 'Europe/London'
}).formatToParts(input);
const part = (type: string) => d.find(p => p.type === type)?.value;
return `${part('year')}-${part('month')}-${part('day')}`
}