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
This commit is contained in:
parent
a5b941e748
commit
74ed6f0c11
3 changed files with 30 additions and 24 deletions
12
Makefile
12
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue