diff options
author | Robert Adam <dev@robert-adam.de> | 2022-10-13 09:01:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 09:01:10 +0300 |
commit | 78350de057a75c062e2cc314cf2df675517712e6 (patch) | |
tree | 1b7d918e6798d3187c3c92e7b7e4da24e1afae11 | |
parent | 7f7b9ecf1277325ded2febfdc86a1ccd187d2e77 (diff) | |
parent | 98056b6da9734adde183228d65bbbc2071db3b34 (diff) |
Merge PR #5918: FIX(server): Explicitly set parsed timestamps to UTC for rememberchannelduration
In ccbf407 the rememberchannelduration logic was improved. An explicit call to 'setTimeSpec(Qt::UTC)' was removed, because it was assumed that 'secsTo' would already be sufficient as it converts both inputs to UTC automatically. Due to an oversight this lead to a regression.
The reason setTimeSpec is actually needed is because the DB already contains UTC values. The setTimeSpec call tells Qt that the loaded values are actually already UTC and do not have to be converted. Without the call to setTimeSpec, the DB values are effectively converted twice, which gives rememberchannelduration an offset based on the server local time.
-rw-r--r-- | src/murmur/ServerDB.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/murmur/ServerDB.cpp b/src/murmur/ServerDB.cpp index d8924c858..981839533 100644 --- a/src/murmur/ServerDB.cpp +++ b/src/murmur/ServerDB.cpp @@ -2225,12 +2225,14 @@ int Server::readLastChannel(int id) { } QDateTime last_active = QDateTime::fromString(query.value(1).toString(), Qt::ISODate); + last_active.setTimeSpec(Qt::UTC); QDateTime last_disconnect; // NULL column for last_disconnect will yield an empty invalid QDateTime object. // Using that object with QDateTime::secsTo() will return 0 as per Qt specification. if (!query.value(2).isNull()) { last_disconnect = QDateTime::fromString(query.value(2).toString(), Qt::ISODate); + last_disconnect.setTimeSpec(Qt::UTC); } if (last_active.secsTo(last_disconnect) <= 0) { |