diff options
-rw-r--r-- | src/gui/widgets/tabs/chat/chattab.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp index 48c0669fc..f619a881c 100644 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ b/src/gui/widgets/tabs/chat/chattab.cpp @@ -251,13 +251,27 @@ void ChatTab::chatLog(std::string line, 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()); + char timeStamp[64]; // 64 bytes should be enough for everybody?? C.. + + size_t res = strftime(timeStamp, 64, "[%H:%M]", timeInfo); + // strftime returns 0 even in case of success (empty format or %p) + // see strftime(3) for further details. + if (res > 0) + { + line = strprintf("%s%s %s%s", lineColor.c_str(), timeStamp, + tmp.nick.c_str(), tmp.text.c_str()); + } + else + { + line = strprintf("%s[(strftime error)%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(), + line = strprintf("(local/gm-time error)%s %s%s", lineColor.c_str(), tmp.nick.c_str(), tmp.text.c_str()); } |