Skip to content

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

Open
samuelx12 wants to merge 1 commit 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 1 commit intonextcloud:mainfrom
samuelx12:fix/datetime-edit-utc-drift

Conversation

@samuelx12
Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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)

1 participant