fix(datetime): parse stored values as UTC in edit form getters#2480
Open
samuelx12 wants to merge 1 commit intonextcloud:mainfrom
Open
fix(datetime): parse stored values as UTC in edit form getters#2480samuelx12 wants to merge 1 commit intonextcloud:mainfrom
samuelx12 wants to merge 1 commit intonextcloud:mainfrom
Conversation
Commit 78f8131 moved datetime handling from a backend TimezoneHelper to frontend-side UTC conversion, updating display formatters and form setters to use .utc()/.utc().local(). The form getters (which load the stored value into the date picker) were missed and still parsed the stored UTC string as local time. As a result, every open→save cycle of the edit form subtracted the current UTC offset (DST-aware: -2h in summer CEST, -1h in winter CET). Fix: update the three affected getters to use Moment.utc(...).local().toDate() to match the pattern already used by the setters and display formatters. Fixes nextcloud#2479 Signed-off-by: Samuel Barmet <samuel@barmet.ch>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this fixes
Every time a row with a datetime column is opened for editing and saved,
the time shifts by the current UTC offset (−2h in summer CEST, −1h in
winter CET). The shift is DST-aware — dates created before the March DST
switch shift by −1h, dates after by −2h.
Root cause
Commit 78f8131 moved datetime handling from a backend
TimezoneHelperto frontend-side UTC conversion. The display formatters and form setters
were correctly updated to use
.utc()/.utc().local(), but the formgetters (which load the stored value into the date picker) were missed.
They still parsed the stored UTC string as local time, causing an offset
drift on every open→save cycle.
Fix
Update the three affected getters to use
Moment.utc(...).local().toDate()— matching the pattern already used by the setters and display formatters.
Files changed:
DatetimeForm.vue— modal edit form getterDatetimeTimeForm.vue— time-only modal edit form getterTableCellDateTime.vue— inline edit getter (both datetime and time-only)DatetimeDateForm.vue(date-only) is not affected — its setter never had.utc()added, so getter and setter were already symmetric.Testing
Manually tested with Docker (Nextcloud 33, Europe/Zurich timezone):
No unit tests added — the affected components (Vue form getters) are not
covered by the existing test suite. A Playwright E2E test for datetime
round-trip stability would be a useful follow-up.
Fixes #2479