Bug 522037 - Negative clock offsets display incorrectly for fractional hours
Summary: Negative clock offsets display incorrectly for fractional hours
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Digital Clock widget (other bugs)
Version First Reported In: 6.7.0
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-06-23 05:05 UTC by Michael Kohl
Modified: 2026-07-01 17:34 UTC (History)
1 user (show)

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


Attachments
A screenshot showing the wrong time offset formatting (11.12 KB, image/png)
2026-06-23 05:05 UTC, Michael Kohl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kohl 2026-06-23 05:05:15 UTC
Created attachment 193574 [details]
A screenshot showing the wrong time offset formatting

DESCRIPTION

Negative clock offsets display incorrectly for time zones with fractional hour offsets. For example. I'm 1:30h ahead of India Standard Time (IST). On hover, the widget displays this as "2:-30" earlier, instead of "1:30 hours earlier".

STEPS TO REPRODUCE
1. Add a timezone with a negative offset containing fractional hours. India (IST, UTC+5:30) or Nepal (NPT, UTC+5:45) are good candidates.
2. Hover over the widget or click on it.
3. The time is formatted wrongly.

OBSERVED RESULT

"2:-30 earlier"

EXPECTED RESULT

"1:30 hours earlier"

SOFTWARE/OS VERSIONS
Operating System (available in the Info Center app, or by running `kinfo` in a terminal window):
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Michael Kohl 2026-06-23 05:10:09 UTC
Sorry, submitted too early. Additional information:

Operating System: Aurora 44
KDE Plasma Version: 6.7.0
KDE Frameworks Version: 6.27.0
Qt Version: 6.11.1

The issue seems to arise in formatOffset in applets/digital-clock/main.qml. It calculates the hour component with Math.abs(Math.floor(offset / 60)) and the minute component as offset % 60. For -90 minutes, this results in 2 and -30. The sign should only be used for determining "earlier" or "later", the calculation should happen on the absolute value.
Comment 2 Bug Janitor Service 2026-06-23 06:52:53 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/6788
Comment 3 Bug Janitor Service 2026-06-23 06:52:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/6788
Comment 4 Nate Graham 2026-07-01 16:01:40 UTC
Git commit c011421f837b47db928b5ef280782b4acd7c9a98 by Nate Graham, on behalf of Michael Kohl.
Committed on 01/07/2026 at 16:01.
Pushed by ngraham into branch 'master'.

applets/digital-clock: fix timezone offset

`formatOffset()` used a floored signed offset to calculate hours,
but used a signed modulo to calculate minutes. This produced
invalid output for negative offsets with a minute component, such
as "2:-30 earlier" for a -90 minute offset.

Calculate both components from the absolute offset while retaining
the original sign to choose between "earlier" and "later".
FIXED-IN: 6.7.3

M  +3    -2    applets/digital-clock/main.qml

https://invent.kde.org/plasma/plasma-workspace/-/commit/c011421f837b47db928b5ef280782b4acd7c9a98
Comment 5 Nate Graham 2026-07-01 17:34:41 UTC
Git commit 246e662d5cc19ee742fb4b14821731f06075581d by Nate Graham.
Committed on 01/07/2026 at 16:02.
Pushed by ngraham into branch 'Plasma/6.7'.

applets/digital-clock: fix timezone offset

`formatOffset()` used a floored signed offset to calculate hours,
but used a signed modulo to calculate minutes. This produced
invalid output for negative offsets with a minute component, such
as "2:-30 earlier" for a -90 minute offset.

Calculate both components from the absolute offset while retaining
the original sign to choose between "earlier" and "later".
FIXED-IN: 6.7.3


(cherry picked from commit c011421f837b47db928b5ef280782b4acd7c9a98)

c3d83e92 applets/digital-clock: fix timezone offset

Co-authored-by: Michael Kohl <me@citizen428.net>

M  +3    -2    applets/digital-clock/main.qml

https://invent.kde.org/plasma/plasma-workspace/-/commit/246e662d5cc19ee742fb4b14821731f06075581d