X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/2a1f23881feba670f3bb614e19409b5f4e90b211..80270bc96f3fd1d1f14b3ef539b73ad2eb0017de:/stglibs/common.lib/common.cpp?ds=sidebyside

diff --git a/stglibs/common.lib/common.cpp b/stglibs/common.lib/common.cpp
index b871b36b..c27a387d 100644
--- a/stglibs/common.lib/common.cpp
+++ b/stglibs/common.lib/common.cpp
@@ -531,6 +531,22 @@ uint32_t inet_strington(const std::string & value)
     return result;
 }
 //-----------------------------------------------------------------------------
+std::string TimeToString(time_t time)
+{
+struct tm brokenTime;
+
+brokenTime.tm_wday = 0;
+brokenTime.tm_yday = 0;
+brokenTime.tm_isdst = 0;
+
+gmtime_r(&time, &brokenTime);
+
+char buf[32];
+strftime(buf, 32, "%Y-%m-%d %H:%M:%S", &brokenTime);
+
+return buf;
+}
+//-----------------------------------------------------------------------------
 int ParseTariffTimeStr(const char * str, int &h1, int &m1, int &h2, int &m2)
 {
 char hs1[10], ms1[10], hs2[10], ms2[10];
@@ -804,6 +820,14 @@ const std::string & x2str(uint64_t x, std::string & s)
 return unsigned2str(x, s);
 }
 //---------------------------------------------------------------------------
+const std::string & x2str(double x, std::string & s)
+{
+char buf[256];
+snprintf(buf, sizeof(buf), "%f", x);
+s = buf;
+return s;
+}
+//---------------------------------------------------------------------------
 std::string & TrimL(std::string & val)
 {
 size_t pos = val.find_first_not_of(" \t");
@@ -833,6 +857,12 @@ std::string & Trim(std::string & val)
 return TrimR(TrimL(val));
 }
 //---------------------------------------------------------------------------
+std::string Trim(const std::string & val)
+{
+std::string res(val);
+return TrimR(TrimL(res));
+}
+//---------------------------------------------------------------------------
 std::string ToLower(const std::string & value)
 {
     std::string res;