diff options
author | Hartmnt <hartmunt@protonmail.com> | 2022-10-08 14:03:15 +0300 |
---|---|---|
committer | Hartmnt <hartmunt@protonmail.com> | 2022-10-08 14:24:30 +0300 |
commit | 98056b6da9734adde183228d65bbbc2071db3b34 (patch) | |
tree | 3c0d1b9877af561123d25ec70fb98ba4caa543cb | |
parent | 3d1aae3730f914d0b2af499c49e513d8d30ce46d (diff) |
FIX(server): Explicitly set parsed timestamps to UTC for rememberchannelduration
In ccbf4072c 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 acutally 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) { |