diff options
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r-- | src/utils/stringutils.cpp | 22 |
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); +} |