Bug 452554 - Desync between date in taskbar and real date
Summary: Desync between date in taskbar and real date
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Unclassified
Component: Digital Clock (show other bugs)
Version: 5.24.4
Platform: Debian testing Linux
: HI normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-12 17:28 UTC by Gaëtan Gilbert
Modified: 2022-04-21 17:37 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.24.5


Attachments
tooltip from mouse hover and taskbar do not agree (tooltip is correct) (5.30 KB, image/png)
2022-04-12 17:28 UTC, Gaëtan Gilbert
Details
~/.config/plasma-org.kde.plasma.desktop-appletsrc (7.77 KB, text/plain)
2022-04-14 15:51 UTC, Gaëtan Gilbert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gaëtan Gilbert 2022-04-12 17:28:54 UTC
Created attachment 148121 [details]
tooltip from mouse hover and taskbar do not agree (tooltip is correct)

SUMMARY

At midnight (Paris time) the time shown in the taskbar does not change day. This seems to persist until the next day, staying 1 day behind reality.
The system knows the real date: hovering over the clock shows the correct date in the tooltip (see attached screenshot), command line date produces the correct date, etc.
Restarting plasmashell or going into widget edit mode resyncs, until the next day.


STEPS TO REPRODUCE
1. wait until midnight

OBSERVED RESULT
date does not change

EXPECTED RESULT
date should change


SOFTWARE/OS VERSIONS
Linux: 5.16.0-5-amd64
(available in About System)
KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
This started around the daylight saving time change (27 march) but I wasn't paying attention enough to tell if that was it or if something else.
Comment 1 David Edmundson 2022-04-14 15:31:04 UTC
I do have a theory

We call dateTimeChanged once per day

It checks if the formatted date matches the last date.
If not it goes into "timeFormatCorrection" which then updates the labels

But the value it's using for the "only do this once per day" is potentially in a different timezone to the one used by formatting
            const currentDate = Qt.formatDateTime(dataSource.data["Local"]["DateTime"], "yyyy-MM-dd");
            if (main.lastDate !== currentDate) {
                doCorrections = true;
                main.lastDate = currentDate
            }


should be the current one right? 

Which means if my local is EU and I show UK time. it'd only update once per EU date change to the current UK date time, and be one day off.

Can you attach your ~/.config/plasma-org.kde.plasma.desktop-appletsrc please

-----

Also this code should be rewritten declaratively so we don't have this sort of problem!
Comment 2 Gaëtan Gilbert 2022-04-14 15:51:51 UTC
Created attachment 148158 [details]
~/.config/plasma-org.kde.plasma.desktop-appletsrc
Comment 3 Gaëtan Gilbert 2022-04-14 15:53:11 UTC
I also have LC_TIME=fr_FR.UTF-8 in my env variables
Comment 4 David Edmundson 2022-04-18 23:11:02 UTC
lastSelectedTimezone=Europe/Paris
selectedTimeZones=Europe/Paris

Which isn't the default of Local. They should still match, but maybe the dataengine isn't atomic
Comment 5 Nate Graham 2022-04-21 17:17:05 UTC
Git commit 5430c3a029590f824419dce5774a5e10efd72df5 by Nate Graham, on behalf of David Edmundson.
Committed on 21/04/2022 at 17:17.
Pushed by ngraham into branch 'master'.

applets/digital-clock: Fix date drift

dateTimeChanged is called every second. This in turn checks if the date
has changed. If so we call setupLabels which updates the clock.

The date label used to use main.currentTime which is a value set in the
binding of the timeLabel's text property. The order of this being
updated vs running this code is undefined.

Bug 1: We compare an ever so slightly different date source to the one
used in the date text label.

Bug 2: We are not necessarily updating the date label with the most
updated time.

Overall we can't mix declarative and imperative design patterns. This
patch commits to being imperative and introduces a function to get the
current time so that the date label and time label will always get the
most up to date value even if they update from different trigers.
FIXED-IN: 5.24.5

M  +14   -15   applets/digital-clock/package/contents/ui/DigitalClock.qml

https://invent.kde.org/plasma/plasma-workspace/commit/5430c3a029590f824419dce5774a5e10efd72df5
Comment 6 Nate Graham 2022-04-21 17:37:38 UTC
Git commit ab86bd37adeed851e460aa7ffd74c1fba0a99b12 by Nate Graham, on behalf of David Edmundson.
Committed on 21/04/2022 at 17:37.
Pushed by ngraham into branch 'Plasma/5.24'.

applets/digital-clock: Fix date drift

dateTimeChanged is called every second. This in turn checks if the date
has changed. If so we call setupLabels which updates the clock.

The date label used to use main.currentTime which is a value set in the
binding of the timeLabel's text property. The order of this being
updated vs running this code is undefined.

Bug 1: We compare an ever so slightly different date source to the one
used in the date text label.

Bug 2: We are not necessarily updating the date label with the most
updated time.

Overall we can't mix declarative and imperative design patterns. This
patch commits to being imperative and introduces a function to get the
current time so that the date label and time label will always get the
most up to date value even if they update from different trigers.
FIXED-IN: 5.24.5
(cherry picked from commit 5430c3a029590f824419dce5774a5e10efd72df5)

M  +14   -15   applets/digital-clock/package/contents/ui/DigitalClock.qml

https://invent.kde.org/plasma/plasma-workspace/commit/ab86bd37adeed851e460aa7ffd74c1fba0a99b12