X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/ae21e8d6ad32d0bf3517127aef5cd8129b7507aa..669bf62b01b121a3c9fc5092cd9d2ab3392fd92c:/stglibs/common.lib/common.cpp diff --git a/stglibs/common.lib/common.cpp b/stglibs/common.lib/common.cpp index 15547b49..622f64f7 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]; @@ -840,6 +856,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;