summaryrefslogtreecommitdiff
path: root/src/gui/widgets/tabs/chat
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2023-10-11 23:10:24 +0200
committerFedja Beader <fedja@protonmail.ch>2023-10-12 00:04:37 +0200
commit2720c161c933f9dbb5aa4fa87b67bf215d67a026 (patch)
tree493d4e0f98032a680b0a99e37be7f6fbd020f5f0 /src/gui/widgets/tabs/chat
parent0a2d34be04d72b8982cc2cd488f7e6432d30b40b (diff)
downloadplus-2720c161c933f9dbb5aa4fa87b67bf215d67a026.tar.gz
plus-2720c161c933f9dbb5aa4fa87b67bf215d67a026.tar.bz2
plus-2720c161c933f9dbb5aa4fa87b67bf215d67a026.tar.xz
plus-2720c161c933f9dbb5aa4fa87b67bf215d67a026.zip
Use gmtime() for non-local-time chat timestamps
Diffstat (limited to 'src/gui/widgets/tabs/chat')
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
index 52ec7fb4f..48c0669fc 100644
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ b/src/gui/widgets/tabs/chat/chattab.cpp
@@ -246,32 +246,19 @@ void ChatTab::chatLog(std::string line,
time_t t;
time(&t);
- if (config.getBoolValue("useLocalTime"))
+ const tm* const timeInfo =
+ config.getBoolValue("useLocalTime") ? localtime(&t) : gmtime(&t);
+
+ if (timeInfo != nullptr)
{
- const tm *const timeInfo = localtime(&t);
- if (timeInfo != nullptr)
- {
- line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(),
- timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(),
- tmp.text.c_str());
- }
- else
- {
- line = strprintf("%s %s%s", lineColor.c_str(),
- tmp.nick.c_str(), tmp.text.c_str());
- }
+ line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(),
+ timeInfo->tm_hour, timeInfo->tm_min,
+ tmp.nick.c_str(), tmp.text.c_str());
}
else
{
- // Format the time string properly
- std::stringstream timeStr;
- timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
- << CAST_S32(((t / 60) / 60) % 24)
- << ":" << (((t / 60) % 60 < 10) ? "0" : "")
- << CAST_S32((t / 60) % 60)
- << "] ";
- line = std::string(lineColor).append(timeStr.str()).append(
- tmp.nick).append(tmp.text);
+ line = strprintf("%s %s%s", lineColor.c_str(),
+ tmp.nick.c_str(), tmp.text.c_str());
}
if (config.getBoolValue("enableChatLog"))