Fix timezone issue in seminar datetime input - always use Pisa time #93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When users entered seminar dates and times, the system was using their local browser timezone instead of Pisa time. This caused incorrect times to be stored in the database and displayed to users.
For example:
This violated the requirement that all seminar times should be entered and displayed in Pisa time, regardless of the user's location.
Solution
Changed all date/time handling to use UTC methods throughout the application, treating all input and output as Pisa time. The key insight is to store times directly in UTC without any timezone conversion, and consistently use UTC methods for both reading and writing.
Changes Made
Frontend Input Component (
src/components/DatetimeInput.js):updateDatetimeFromString()to usesetUTCFullYear(),setUTCMonth(),setUTCDate(),setUTCHours(),setUTCMinutes()instead of their local timezone equivalentsformatDate()to usegetUTCFullYear(),getUTCMonth(), etc.DatetimeInputcomponent to initialize state using UTC gettersDisplay Functions - Added
timeZone: 'UTC'parameter to all date formatting:widgets/src/utils.js- Widget display functions (formatDate,formatTime)src/processes/RoomsBookings.js- Room booking time displayserver/controllers/processes/seminars.js- Seminar notification formattingserver/controllers/processes/visits.js- Visit notification formattingserver/worker.js- Background worker notification formattingResult
Now all datetime handling is timezone-independent:
Testing
Verified that:
Closes issue about "Ora locale nell'inserimento dei dati" (Local time in data entry).
Original prompt
Fixes #54
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.