diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/chat.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 70b39ae3..ab654440 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -23,6 +23,8 @@ #include "chat.h" +#include <sstream> + #include <guichan/focushandler.hpp> #include <guichan/key.hpp> @@ -144,7 +146,21 @@ void ChatWindow::chat_log(std::string line, int own) break; } - line = lineColor + tmp.nick + line; + // Get the current system time + time_t t; + time(&t); + + // Format the time string properly + std::stringstream timeStr; + timeStr << "["; + timeStr << ((((t / 60) / 60) % 24 < 10) ? "0" : ""); + timeStr << (int)(((t / 60) / 60) % 24); + timeStr << ":"; + timeStr << (((t / 60) % 60 < 10) ? "0" : ""); + timeStr << (int)((t / 60) % 60); + timeStr << "] "; + + line = lineColor + timeStr.str() + tmp.nick + line; textOutput->addRow(line); scrollArea->setVerticalScrollAmount(scrollArea->getVerticalMaxScroll()); |