diff --git a/src/db/main-db-p.h b/src/db/main-db-p.h index bd2076407..35c93f42d 100644 --- a/src/db/main-db-p.h +++ b/src/db/main-db-p.h @@ -44,6 +44,8 @@ private: // Misc helpers. // --------------------------------------------------------------------------- + static time_t getTmAsTimeT (const tm &t); + std::shared_ptr findChatRoom (const ChatRoomId &chatRoomId) const; // --------------------------------------------------------------------------- diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index dcb589a60..bd5245f67 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -226,6 +226,12 @@ static string buildSqlEventFilter ( // Misc helpers. // ----------------------------------------------------------------------------- +time_t MainDbPrivate::getTmAsTimeT (const tm &t) { + tm t2 = t; + t2.tm_isdst = 0; + return Utils::getTmAsTimeT(t2); +} + shared_ptr MainDbPrivate::findChatRoom (const ChatRoomId &chatRoomId) const { L_Q(); shared_ptr chatRoom = q->getCore()->findChatRoom(chatRoomId); @@ -610,7 +616,7 @@ shared_ptr MainDbPrivate::selectConferenceChatMessageEvent ( dChatMessage->forceFromAddress(IdentityAddress(row.get(3))); dChatMessage->forceToAddress(IdentityAddress(row.get(4))); - dChatMessage->setTime(Utils::getTmAsTimeT(row.get(5))); + dChatMessage->setTime(MainDbPrivate::getTmAsTimeT(row.get(5))); dChatMessage->setImdnMessageId(row.get(6)); dChatMessage->setPositiveDeliveryNotificationRequired(bool(row.get(14))); dChatMessage->setDisplayNotificationRequired(bool(row.get(15))); @@ -1976,7 +1982,7 @@ list MainDb::getChatMessageParticipantsThatHaveDisplay list result; for (const auto &row : rows) - result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::Displayed, Utils::getTmAsTimeT(row.get(1))); + result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::Displayed, MainDbPrivate::getTmAsTimeT(row.get(1))); return result; }; } @@ -2029,7 +2035,7 @@ list MainDb::getChatMessageParticipantsThatHaveReceive list result; for (const auto &row : rows) - result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::DeliveredToUser, Utils::getTmAsTimeT(row.get(1))); + result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::DeliveredToUser, MainDbPrivate::getTmAsTimeT(row.get(1))); return result; }; } @@ -2483,8 +2489,8 @@ list> MainDb::getChatRooms () const { continue; // Not fetched. AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate(); - dChatRoom->setCreationTime(Utils::getTmAsTimeT(creationTime)); - dChatRoom->setLastUpdateTime(Utils::getTmAsTimeT(lastUpdateTime)); + dChatRoom->setCreationTime(MainDbPrivate::getTmAsTimeT(creationTime)); + dChatRoom->setLastUpdateTime(MainDbPrivate::getTmAsTimeT(lastUpdateTime)); lInfo() << "Found chat room in DB: (peer=" << chatRoomId.getPeerAddress().asString() << ", local=" << chatRoomId.getLocalAddress().asString() << ")."; diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index a2eda88c3..b05174a63 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -188,11 +188,11 @@ string Utils::trim (const string &str) { // ----------------------------------------------------------------------------- tm Utils::getTimeTAsTm (time_t time) { - #ifndef _WIN32 + #ifdef _WIN32 + return *gmtime(&time); + #else tm result; return *gmtime_r(&time, &result); - #else - return *gmtime(&time); #endif }