Skip to content

fix(datetime): parse stored values as UTC in edit form getters#2480

Open
samuelx12 wants to merge 3 commits intonextcloud:mainfrom
samuelx12:fix/datetime-edit-utc-drift
Open

fix(datetime): parse stored values as UTC in edit form getters#2480
samuelx12 wants to merge 3 commits intonextcloud:mainfrom
samuelx12:fix/datetime-edit-utc-drift

Conversation

@samuelx12
Copy link
Copy Markdown
Contributor

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 TimezoneHelper
to frontend-side UTC conversion. The display formatters and form setters
were correctly updated to use .utc() / .utc().local(), but the form
getters (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 getter
  • DatetimeTimeForm.vue — time-only modal edit form getter
  • TableCellDateTime.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):

  • Datetime values remain stable across multiple open→save cycles
  • Both modal edit and inline edit verified
  • Summer (CEST, UTC+2) and winter (CET, UTC+1) dates tested

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

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>
@samuelx12 samuelx12 requested review from blizzz and enjeck as code owners April 14, 2026 20:56
@AndyScherzinger AndyScherzinger added the 3. to review Waiting for reviews label Apr 15, 2026
Comment thread src/shared/components/ncTable/partials/rowTypePartials/DatetimeTimeForm.vue Outdated
Comment thread src/shared/components/ncTable/partials/rowTypePartials/DatetimeForm.vue Outdated
samuelx12 and others added 2 commits April 24, 2026 12:28
…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>
@samuelx12
Copy link
Copy Markdown
Contributor Author

Not directly related to this PR, but a question came up to me:
There's no migration strategy for switching to Tables 2.x.x. People will see all their existing times shifted by their UTC offset (unless they live in England 😉). That's bad UX. Just throwing it out there, even though I don't have a good solution either.

@samuelx12 samuelx12 requested a review from enjeck April 27, 2026 09:11
@github-actions
Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Datetime column shifts time by timezone offset on every save (DST-aware, Tables 2.0.x)

3 participants