summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/stringutils.cpp11
-rw-r--r--src/utils/stringutils.h2
2 files changed, 13 insertions, 0 deletions
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