fix(datetime): parse stored values as UTC in edit form getters#2480
fix(datetime): parse stored values as UTC in edit form getters#2480samuelx12 wants to merge 3 commits 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>
…eTimeForm.vue Co-authored-by: Enjeck <32180937+enjeck@users.noreply.github.com> Signed-off-by: Samuel <90173331+samuelx12@users.noreply.github.com>
…eForm.vue Co-authored-by: Enjeck <32180937+enjeck@users.noreply.github.com> Signed-off-by: Samuel <90173331+samuelx12@users.noreply.github.com>
|
Not directly related to this PR, but a question came up to me: |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
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