Skip to content

Timelines and reports: period and dates in the browser's time zone (#323) - #354

Merged
Martin-1997 merged 2 commits into
masterfrom
fix/323-timeline-period
Nov 22, 2026
Merged

Martin-1997 merged 2 commits into
masterfrom
fix/323-timeline-period

Conversation

@Martin-1997

Copy link
Copy Markdown
Collaborator

Completes #323, together with #352.

Builds on #352 (the "to" date, by @bfs2021), whose commit is included here. #352 comes from a fork, so this PR can't target its branch and targets master. Merge #352 first; this PR's diff then shrinks to its own commit. (If this one is merged first, #352 is merged along with it, since GitHub marks a PR as merged once its commit is in master.)

Problem (first part of #323)

  • Wrong period: the timeline period ("When" in Timelines and Timelines Admin) was formatted in UTC. East of UTC it started a day early ("October 31" for a period from 1 November in Berlin), west of UTC it ended a day late ("November 19" instead of 18 in Los Angeles).
  • Inconsistent grouping: report and timeline rows were grouped by day, week or month in the user's Nextcloud time zone, which falls back to UTC when it isn't set, while the browser sends its own day boundaries (with fix: include the whole "to" day in dashboard, reports and timelines #352: local 00:00 to 23:59:59). An entry at 23:30 in Los Angeles was grouped under the next day.

Found along the way

Timeline entries stored a Unix timestamp as their "Time Interval": the earliest entry's start, e.g. 1794987000. The timeline CSV export showed these numbers. This has been the case since before the recent refactorings (the old SQL version also selected start as time).

Fix

  • The browser sends its time zone: Reports, Timelines and the Dashboard send timezone (e.g. Europe/Berlin, from Intl.DateTimeFormat()) with the report request.
  • The server uses it (requestTimeZone()) for report grouping and for the timeline period. Without it (older clients such as the Android app), the user's Nextcloud setting applies, as before. An invalid name falls back the same way.
  • Timeline entries store the period's label (2026-11-17, 2026W47, …), or the date of the earliest entry when not grouped by time.
  • Not changed:
    • already saved timelines keep their text, since a timeline doesn't store its timestamps;
    • storing them in new columns (the issue's "better still" option) would need a migration and an API change for Android, so I left it out.

Testing

  • New integration test TimelinePeriodTest:

    • a period east and west of UTC;
    • day grouping of a late-evening entry in the report and the timeline;
    • the entry label without time grouping;
    • the fallback for an invalid time zone.

    Against fix: include the whole "to" day in dashboard, reports and timelines #352 without this fix, three of them fail exactly as reported: October 31, November 19, and the entry under 2026-11-18 instead of 2026-11-17.

  • All 48 integration tests and the unit tests pass; phpstan is clean; the build has no warnings.

  • Browser (time zone Europe/Berlin):

    • exporting a timeline sends timezone: "Europe/Berlin";
    • the period reads "October 24, 2026 - November 22, 2026" (the start is October 23 in UTC);
    • the CSV shows day labels instead of timestamps;
    • no console errors.

Fixes #323

🤖 Generated with Claude Code

bfs2021 and others added 2 commits November 21, 2026 19:25
The period of a timeline ("When") was formatted in UTC, so it started
a day early east of UTC and ended a day late west of it. Report and
timeline dates were grouped in the user's Nextcloud time zone, which
falls back to UTC when it isn't set, while the browser sends its own
day boundaries.

- Reports, Timelines and the Dashboard send the browser's time zone
  ("timezone", e.g. Europe/Berlin); report grouping and the timeline
  period use it. Without it (older clients) the user's Nextcloud
  setting applies.
- Timeline entries store the period's label ("2026-11-17", "2026W47")
  or the date of the earliest entry, instead of its raw start
  timestamp, which the CSV export showed as a number.

Existing timelines keep their stored text.

Fixes #323 (together with #352 for the "to" date)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Martin-1997
Martin-1997 merged commit f280293 into master Nov 22, 2026
20 checks passed
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.

Timelines show the wrong period (formatted in UTC), and the "to" date is excluded from Reports, Timelines and Dashboard

2 participants