Bug 521114 - Calendar today-highlight shows the previous day when local timezone is ahead of UTC and local time is before UTC midnight (regression of bug 394423)
Summary: Calendar today-highlight shows the previous day when local timezone is ahead ...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Digital Clock widget (other bugs)
Version First Reported In: 6.6.4
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2026-06-06 00:08 UTC by Mahmud Farooque
Modified: 2026-06-12 13:46 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.6.6
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mahmud Farooque 2026-06-06 00:08:16 UTC
Steps to reproduce
  1. Set the systemwide timezone to one ahead of UTC, e.g. Asia/Dhaka (UTC+6), as the only zone in the Digital Clock timezone list.
  2. Wait until local time is between 00:00 and 06:00, so the local date is the next day while UTC is still the previous day. 
  3. Click the panel clock to open the calendar grid.

  Observed result
  The clock face shows the correct local date and time (e.g. Sat 6 Jun 05:49). The calendar grid below highlights the previous day as today (Fri 5). It
  corrects itself only when UTC passes midnight (06:00 local). Restarting plasmashell does not help, so it is a date computation, not a stale render. The
  applet is pinned to Asia/Dhaka, so it is not a misconfiguration.

  Expected result
  The calendar today-highlight should follow the same local timezone as the clock and highlight 6 Jun.

  Additional information
  Regression of bug 394423, fixed for Plasma 5 / Qt 5.11 by switching QDate to QDateTime so the date carries a timezone. Plasma 6 appears to compute today
  from the UTC date again. Fault window is the offset-sized period after local midnight (00:00 to 06:00 for UTC+6); outside it the highlight is correct.
  Plasma 6.6.4, Qt 6.10.2, KDE Frameworks 6.x, Ubuntu 26.04 LTS, kernel 7.0.0-22-generic, Wayland.
Comment 1 Bug Janitor Service 2026-06-07 15:52:26 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/6693
Comment 2 Fushan Wen 2026-06-12 00:23:23 UTC
Git commit 15e4ca1137599e093b71a9c57bb3e742cac3e707 by Fushan Wen.
Committed on 12/06/2026 at 00:22.
Pushed by fusionfuture into branch 'master'.

components/calendar: fix today-highlight showing wrong day for UTC+x timezones before UTC midnight

Calendar::setToday() calls .date() on a QDateTime with Qt::UTC timeSpec,
which returns the UTC date. This gives the wrong date when the system
timezone is ahead of UTC and local time is before UTC midnight, because
the local date has already advanced past the UTC date (e.g. UTC+6 at
04:00 local is still 22:00 UTC the previous day).

The incoming QDateTime originates from Clock::jsDateTime() which retains
Qt::UTC timeSpec. Replace dateTime.date() with dateTime.toLocalTime().date()
so the stored date matches the system local timezone, consistent with what
JS Date.getDate() returns for the same value.

Apply the same fix to setDisplayedDate(const QDateTime &) so it also
handles QDateTime values with Qt::UTC timeSpec correctly.

M  +13   -2    components/calendar/calendar.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/15e4ca1137599e093b71a9c57bb3e742cac3e707
Comment 3 Mahmud Farooque 2026-06-12 00:47:32 UTC
Thanks for the quick fix! I can see the cherry-pick to Plasma/6.7 in MR 6740. Could this also be picked to Plasma/6.6? Distros on the 6.6 series (e.g. Kubuntu 26.04 LTS, where I hit this on 6.6.4) would otherwise carry the regression for the life of the release. The change is small and self-contained (+13/-2 in components/calendar/calendar.cpp with autotests), so it seems like a good candidate for a 6.6.x point release.
Comment 4 Nate Graham 2026-06-12 11:05:50 UTC
We'll consider it!
Comment 5 Fushan Wen 2026-06-12 11:06:36 UTC
Git commit e1e46fa91c91cbc56ced2d339947e13e0cff5174 by Fushan Wen.
Committed on 12/06/2026 at 11:06.
Pushed by fusionfuture into branch 'Plasma/6.7'.

components/calendar: fix today-highlight showing wrong day for UTC+x timezones before UTC midnight

Calendar::setToday() calls .date() on a QDateTime with Qt::UTC timeSpec,
which returns the UTC date. This gives the wrong date when the system
timezone is ahead of UTC and local time is before UTC midnight, because
the local date has already advanced past the UTC date (e.g. UTC+6 at
04:00 local is still 22:00 UTC the previous day).

The incoming QDateTime originates from Clock::jsDateTime() which retains
Qt::UTC timeSpec. Replace dateTime.date() with dateTime.toLocalTime().date()
so the stored date matches the system local timezone, consistent with what
JS Date.getDate() returns for the same value.

Apply the same fix to setDisplayedDate(const QDateTime &) so it also
handles QDateTime values with Qt::UTC timeSpec correctly.


(cherry picked from commit 15e4ca1137599e093b71a9c57bb3e742cac3e707)

Co-authored-by: Fushan Wen <qydwhotmail@gmail.com>

M  +13   -2    components/calendar/calendar.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/e1e46fa91c91cbc56ced2d339947e13e0cff5174
Comment 6 Fushan Wen 2026-06-12 13:01:36 UTC
Git commit 1967ff8c8ccca57744ee2bb1b629f8d46fbf3869 by Fushan Wen.
Committed on 12/06/2026 at 11:09.
Pushed by fusionfuture into branch 'Plasma/6.6'.

components/calendar: fix today-highlight showing wrong day for UTC+x timezones before UTC midnight

Calendar::setToday() calls .date() on a QDateTime with Qt::UTC timeSpec,
which returns the UTC date. This gives the wrong date when the system
timezone is ahead of UTC and local time is before UTC midnight, because
the local date has already advanced past the UTC date (e.g. UTC+6 at
04:00 local is still 22:00 UTC the previous day).

The incoming QDateTime originates from Clock::jsDateTime() which retains
Qt::UTC timeSpec. Replace dateTime.date() with dateTime.toLocalTime().date()
so the stored date matches the system local timezone, consistent with what
JS Date.getDate() returns for the same value.

Apply the same fix to setDisplayedDate(const QDateTime &) so it also
handles QDateTime values with Qt::UTC timeSpec correctly.


(cherry picked from commit 15e4ca1137599e093b71a9c57bb3e742cac3e707)

Co-authored-by: Fushan Wen <qydwhotmail@gmail.com>

M  +13   -2    components/calendar/calendar.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/1967ff8c8ccca57744ee2bb1b629f8d46fbf3869