fix: implement timezone-aware datetime display and editing

All datetime values are stored in UTC but were displaying raw UTC times
to users, causing confusion (e.g., 10:00 Bucharest showing as 08:00).
This implements proper timezone conversion throughout the app using each
user's profile timezone setting.

Changes:
- Frontend: Replace local formatters with timezone-aware utilities
- Backend: Add timezone conversion to PUT /bookings endpoint
- FullCalendar: Configure to display events in user timezone
- Fix edit modal to preserve times when editing bookings

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-02-11 13:43:31 +00:00
parent df4031d99c
commit b93b8d2e71
10 changed files with 899 additions and 87 deletions

View File

@@ -467,9 +467,20 @@ def update_booking(
detail="Can only edit pending bookings",
)
# Convert input times from user timezone to UTC
user_timezone = current_user.timezone or "UTC" # type: ignore[attr-defined]
# Prepare updated values (don't update model yet - validate first)
updated_start = data.start_datetime if data.start_datetime is not None else booking.start_datetime # type: ignore[assignment]
updated_end = data.end_datetime if data.end_datetime is not None else booking.end_datetime # type: ignore[assignment]
# Convert datetimes to UTC if provided
if data.start_datetime is not None:
updated_start = convert_to_utc(data.start_datetime, user_timezone) # type: ignore[assignment]
else:
updated_start = booking.start_datetime # type: ignore[assignment]
if data.end_datetime is not None:
updated_end = convert_to_utc(data.end_datetime, user_timezone) # type: ignore[assignment]
else:
updated_end = booking.end_datetime # type: ignore[assignment]
# Re-validate booking rules BEFORE updating the model
user_id = int(current_user.id) # type: ignore[arg-type]
@@ -494,9 +505,9 @@ def update_booking(
if data.description is not None:
booking.description = data.description # type: ignore[assignment]
if data.start_datetime is not None:
booking.start_datetime = data.start_datetime # type: ignore[assignment]
booking.start_datetime = convert_to_utc(data.start_datetime, user_timezone) # type: ignore[assignment]
if data.end_datetime is not None:
booking.end_datetime = data.end_datetime # type: ignore[assignment]
booking.end_datetime = convert_to_utc(data.end_datetime, user_timezone) # type: ignore[assignment]
db.commit()
db.refresh(booking)