[nightcolor] Use local time in Automatic and Location mode
ClosedPublic

Authored by zzag on Sep 22 2019, 11:20 PM.

Details

Summary

Currently Night Color doesn't handle time zones very well. For example,
if the user's time zone is UTC-8, then computed timings of sunrise and
sunset (in UTC) will be a bit gibberish as sunset occurs before sunrise
rather than vice versa.

This change switches relevant parts of Night Color to local time in
order to fix expectations about the order of morning and evening in
updateSunTimings() method as well to simplify the code a bit (dealing
with UTC and local time can be painful sometimes).

CCBUG: 412211

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
zzag created this revision.Sep 22 2019, 11:20 PM
Restricted Application added a project: KWin. · View Herald TranscriptSep 22 2019, 11:20 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
zzag requested review of this revision.Sep 22 2019, 11:20 PM
romangg requested changes to this revision.Sep 23 2019, 5:49 PM
romangg added a subscriber: romangg.

Thanks for looking into it. But please change only the logic first and not add directly all the const qualifiers and variable renames as well. This patch should be only a bug fix and not a code style cleanup at the same time.

This revision now requires changes to proceed.Sep 23 2019, 5:49 PM
zzag updated this revision to Diff 66708.Sep 23 2019, 8:10 PM

Undo const changes and use todayNow variable name.

zzag edited the summary of this revision. (Show Details)Sep 24 2019, 7:51 AM
romangg accepted this revision.EditedSep 25 2019, 9:20 PM

From feedback it does not fix the bug completely but I think conceptually it makes sense. Maybe add a comment that all times are in local timezone from now on.

colorcorrection/suncalc.cpp
157

Why call this variable fraction now what is less descriptive about what it represents?

164

Here as well.

This revision is now accepted and ready to land.Sep 25 2019, 9:20 PM
zzag added inline comments.Sep 26 2019, 8:33 AM
colorcorrection/suncalc.cpp
157

The calculated number is fraction of a day. I'll change it to dayFraction.

This revision was automatically updated to reflect the committed changes.
zzag added a comment.Sep 26 2019, 8:51 AM

But please change only the logic first and not add directly all the const qualifiers

Follow up patch D24235