From 9e8ae9ad161c7dc587ed8e06566bb3e8aed6bfe9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 15 Jun 2011 04:12:11 +0300 Subject: Add option to use local time in chat. --- src/gui/widgets/chattab.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 76f74dec8..3f2166de0 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -221,15 +221,25 @@ void ChatTab::chatLog(std::string line, Own own, time_t t; time(&t); - // Format the time string properly - std::stringstream timeStr; - timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "") - << static_cast(((t / 60) / 60) % 24) - << ":" << (((t / 60) % 60 < 10) ? "0" : "") - << static_cast((t / 60) % 60) - << "] "; - - line = lineColor + timeStr.str() + tmp.nick + tmp.text; + if (config.getBoolValue("useLocalTime")) + { + struct tm *timeInfo; + timeInfo = localtime(&t); + 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" : "") + << static_cast(((t / 60) / 60) % 24) + << ":" << (((t / 60) % 60 < 10) ? "0" : "") + << static_cast((t / 60) % 60) + << "] "; + line = lineColor + timeStr.str() + tmp.nick + tmp.text; + } if (config.getBoolValue("enableChatLog")) saveToLogFile(line); -- cgit v1.2.3-70-g09d2