Fix timezone issue: display booking slots in UTC

- Changed formatTime() to use UTC methods instead of toLocaleTimeString()
- Prevents timezone conversion when displaying booking slots
- Now admin sets 9-17 and user sees 9-17, regardless of timezone
- Fixes 1-hour offset issue when user timezone differs from UTC
This commit is contained in:
counterweight 2025-12-21 18:10:15 +01:00
parent 38b5f2a0a7
commit 7926e3ae4c
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C

View file

@ -13,15 +13,15 @@ export function formatDate(d: Date): string {
} }
/** /**
* Format time from ISO string to HH:MM format. * Format time from ISO string to HH:MM format in UTC.
* Uses UTC to avoid timezone conversion issues when displaying booking slots.
*/ */
export function formatTime(isoString: string): string { export function formatTime(isoString: string): string {
const d = new Date(isoString); const d = new Date(isoString);
return d.toLocaleTimeString("en-US", { // Use UTC methods to avoid timezone conversion
hour: "2-digit", const hours = String(d.getUTCHours()).padStart(2, "0");
minute: "2-digit", const minutes = String(d.getUTCMinutes()).padStart(2, "0");
hour12: false, return `${hours}:${minutes}`;
});
} }
/** /**