summaryrefslogtreecommitdiff
path: root/src/utils/stringutils.cpp
diff options
context:
space:
mode:
authorReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
committerReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
commit490862919d79369112c75955a9c36ff8a081efd3 (patch)
tree6fe89466b9c53ba811f298174e6d787bbae71e09 /src/utils/stringutils.cpp
parentdff814619d63496acd3c4e8730b828b5d4d931fb (diff)
parentd873da3e8e57480016596f714845c1bc7e712e68 (diff)
downloadmv-490862919d79369112c75955a9c36ff8a081efd3.tar.gz
mv-490862919d79369112c75955a9c36ff8a081efd3.tar.bz2
mv-490862919d79369112c75955a9c36ff8a081efd3.tar.xz
mv-490862919d79369112c75955a9c36ff8a081efd3.zip
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r--src/utils/stringutils.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 9184ba79d..5a7ea87fd 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -28,6 +28,8 @@
#include <cstdio>
#include <list>
+#include <sys/time.h>
+
#include "debug.h"
static int UTF8_MAX_SIZE = 10;
@@ -520,9 +522,9 @@ std::string stringToHexPath(const std::string &str)
if (str.empty())
return "";
- std::string hex = strprintf("%%%2x/", (int)str[0]);
+ std::string hex = strprintf("%%%2x/", static_cast<int>(str[0]));
for (unsigned f = 1; f < str.size(); f ++)
- hex += strprintf("%%%2x", (int)str[f]);
+ hex += strprintf("%%%2x", static_cast<int>(str[f]));
return hex;
}
@@ -598,7 +600,7 @@ bool findCutFirst(std::string &str1, std::string str2)
std::string &removeProtocol(std::string &url)
{
int i = url.find("://");
- if (i != (int)std::string::npos)
+ if (i != static_cast<int>(std::string::npos))
url = url.substr(i + 3);
return url;
}
@@ -609,3 +611,17 @@ bool strStartWith(std::string str1, std::string str2)
return false;
return str1.substr(0, str2.size()) == str2;
}
+
+std::string getDateString()
+{
+ char buffer[80];
+
+ time_t rawtime;
+ struct tm *timeinfo;
+
+ time (&rawtime);
+ timeinfo = localtime(&rawtime);
+
+ strftime(buffer, 79, "%Y-%m-%d", timeinfo);
+ return std::string(buffer);
+}