X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0d3126b51031578f051af3f38ed73b8e4e6a18bf..8c6fa3fbaccc22127280bf77a48fab5a3ee0716e:/stglibs/common.lib/common.cpp?ds=inline diff --git a/stglibs/common.lib/common.cpp b/stglibs/common.lib/common.cpp index 7bf27397..fcea5ebc 100644 --- a/stglibs/common.lib/common.cpp +++ b/stglibs/common.lib/common.cpp @@ -515,6 +515,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]; @@ -785,11 +801,6 @@ if (errno == ERANGE) return 0; } -//--------------------------------------------------------------------------- -int str2x(const std::string & str, double & x) -{ -return strtodouble2(str.c_str(), x); -} #ifndef WIN32 //--------------------------------------------------------------------------- int str2x(const std::string & str, int64_t & x) @@ -860,6 +871,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(std::string value) { std::transform(value.begin(), value.end(), value.begin(), ::tolower);