summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-04-27 21:57:09 +0300
committerAndrei Karas <akaras@inbox.ru>2015-04-27 21:57:09 +0300
commitd0866a481199f01b68c00a319749f110f0439417 (patch)
tree5cb22903974592609775fbb3d81575fcb3a71f9f
parentcff8879242e1f692dee58ac764c5a54da1a996cd (diff)
downloadplus-d0866a481199f01b68c00a319749f110f0439417.tar.gz
plus-d0866a481199f01b68c00a319749f110f0439417.tar.bz2
plus-d0866a481199f01b68c00a319749f110f0439417.tar.xz
plus-d0866a481199f01b68c00a319749f110f0439417.zip
Add into mail message field with date in string format.
-rw-r--r--src/gui/mailmessage.h2
-rw-r--r--src/net/eathena/mailhandler.cpp3
-rw-r--r--src/utils/stringutils.cpp11
-rw-r--r--src/utils/stringutils.h2
4 files changed, 18 insertions, 0 deletions
diff --git a/src/gui/mailmessage.h b/src/gui/mailmessage.h
index e8b51344c..0558448b3 100644
--- a/src/gui/mailmessage.h
+++ b/src/gui/mailmessage.h
@@ -28,6 +28,7 @@ struct MailMessage final
MailMessage() :
title(),
sender(),
+ strTime(),
id(0),
time(0),
unread(false)
@@ -38,6 +39,7 @@ struct MailMessage final
std::string title;
std::string sender;
+ std::string strTime;
int id;
int time;
bool unread;
diff --git a/src/net/eathena/mailhandler.cpp b/src/net/eathena/mailhandler.cpp
index 840f53e27..1a24fcc86 100644
--- a/src/net/eathena/mailhandler.cpp
+++ b/src/net/eathena/mailhandler.cpp
@@ -34,6 +34,8 @@
#include "resources/notifytypes.h"
+#include "utils/stringutils.h"
+
#include "debug.h"
extern Net::MailHandler *mailHandler;
@@ -139,6 +141,7 @@ void MailHandler::processMailList(Net::MessageIn &msg)
mail->unread = msg.readUInt8("unread flag") ? true : false;
mail->sender = msg.readString(24, "sender name");
mail->time = msg.readInt32("time stamp");
+ mail->strTime = timeToStr(mail->time);
mailWindow->addMail(mail);
}
}
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index cde03d1b1..13d6501da 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -771,3 +771,14 @@ std::string removeToken(std::string &str, const std::string &token)
str.clear();
return str;
}
+
+std::string timeToStr(const int time)
+{
+ char buf[101];
+ const long tempTime = static_cast<long>(time);
+ tm *const timeInfo = localtime(&tempTime);
+ if (strftime(&buf[0], 100, "%Y-%m-%d_%H-%M-%S", timeInfo))
+ return std::string(buf);
+ else
+ return "unknown";
+}
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 1d04e4afa..3cca7c0f8 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -244,4 +244,6 @@ uint32_t parseNumber(const std::string &str);
std::string removeToken(std::string &str, const std::string &token);
+std::string timeToStr(const int time);
+
#endif // UTILS_STRINGUTILS_H