From 74ed6f0c114b21c58b5e636f56b28648f5540d63 Mon Sep 17 00:00:00 2001 From: counterweight Date: Sun, 21 Dec 2025 18:20:22 +0100 Subject: [PATCH] Revert to local timezone display for user-facing times - Changed formatTime back to use toLocaleTimeString (local time) - Changed formatDateTime back to use toLocaleString (local time) - App now displays all times in user's local timezone - Backend still stores times in UTC, frontend converts for display --- Makefile | 12 +++++++++--- frontend/app/utils/date.ts | 35 +++++++++++++++-------------------- scripts/e2e.sh | 7 ++++++- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index c603191..178f042 100644 --- a/Makefile +++ b/Makefile @@ -48,14 +48,20 @@ dev: cd frontend && npm run dev & \ wait +# TEST variable can be used to select specific tests: +# Backend: TEST="-m auth" (marker) or TEST="tests/test_booking.py" (file) or TEST="tests/test_booking.py::TestBooking::test_specific" (specific test) +# Frontend: TEST="app/login" (file pattern matching app/**/*.test.{ts,tsx}) +# E2E: TEST="auth" (file pattern matching e2e/*.spec.ts) +TEST ?= + test-backend: db-clean db-ready - cd backend && uv run pytest -v + cd backend && uv run pytest -v $(TEST) test-frontend: - cd frontend && npm run test + cd frontend && npm run test $(if $(TEST),-- $(TEST),) test-e2e: db-clean db-ready - ./scripts/e2e.sh + ./scripts/e2e.sh $(TEST) test: check-constants check-types-fresh test-backend test-frontend test-e2e diff --git a/frontend/app/utils/date.ts b/frontend/app/utils/date.ts index 2e34103..380a9c4 100644 --- a/frontend/app/utils/date.ts +++ b/frontend/app/utils/date.ts @@ -13,35 +13,30 @@ export function formatDate(d: Date): string { } /** - * Format time from ISO string to HH:MM format in UTC. - * Uses UTC to avoid timezone conversion issues when displaying booking slots. + * Format time from ISO string to HH:MM format in local timezone. */ export function formatTime(isoString: string): string { const d = new Date(isoString); - // Use UTC methods to avoid timezone conversion - const hours = String(d.getUTCHours()).padStart(2, "0"); - const minutes = String(d.getUTCMinutes()).padStart(2, "0"); - return `${hours}:${minutes}`; + return d.toLocaleTimeString("en-US", { + hour: "2-digit", + minute: "2-digit", + hour12: false, + }); } /** - * Format datetime from ISO string to a readable format in UTC. - * Uses UTC to avoid timezone conversion issues when displaying appointment times. + * Format datetime from ISO string to a readable format in local timezone. */ export function formatDateTime(isoString: string): string { const d = new Date(isoString); - - // Use UTC methods to avoid timezone conversion - const weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; - const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - - const weekday = weekdays[d.getUTCDay()]; - const month = months[d.getUTCMonth()]; - const day = d.getUTCDate(); - const hours = String(d.getUTCHours()).padStart(2, "0"); - const minutes = String(d.getUTCMinutes()).padStart(2, "0"); - - return `${weekday}, ${month} ${day}, ${hours}:${minutes}`; + return d.toLocaleString("en-US", { + weekday: "short", + month: "short", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + hour12: false, + }); } /** diff --git a/scripts/e2e.sh b/scripts/e2e.sh index 6089d3d..66ee55f 100755 --- a/scripts/e2e.sh +++ b/scripts/e2e.sh @@ -36,8 +36,13 @@ npm run generate-api-types cd .. # Run tests (suppress Node.js color warnings) +# If TEST argument is provided, use it as a file pattern cd frontend -NODE_NO_WARNINGS=1 npm run test:e2e +if [ -n "$1" ]; then + NODE_NO_WARNINGS=1 npx playwright test "$1" +else + NODE_NO_WARNINGS=1 npm run test:e2e +fi EXIT_CODE=$? # Cleanup