* @brief Convert unix time to string to show in the GUI. * @param [in] tim Time in seconds since 1.1.1970. * @return Time as a string, proper to show in the GUI. */
| 119 | * @return Time as a string, proper to show in the GUI. |
| 120 | */ |
| 121 | String TimeString(const int64_t * tim) |
| 122 | { |
| 123 | if (tim == nullptr) return _T("---"); |
| 124 | |
| 125 | SYSTEMTIME sysTimeGlobal, sysTime; |
| 126 | FILETIME ft{}; |
| 127 | Timestamp t(*tim * Timestamp::resolution()); |
| 128 | |
| 129 | if (*tim == Poco::Timestamp::TIMEVAL_MIN / 1000 / 1000) |
| 130 | return String(); |
| 131 | t.toFileTimeNP((unsigned int&)ft.dwLowDateTime, (unsigned int&)ft.dwHighDateTime); |
| 132 | if (!FileTimeToSystemTime(&ft, &sysTimeGlobal) || |
| 133 | !SystemTimeToTzSpecificLocalTime(nullptr, &sysTimeGlobal, &sysTime)) |
| 134 | return _T("---"); |
| 135 | |
| 136 | tchar_t buff[128]; |
| 137 | int len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysTime, nullptr, buff, sizeof(buff)/sizeof(buff[0])); |
| 138 | buff[len - 1] = ' '; |
| 139 | GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, nullptr, buff + len, sizeof(buff)/sizeof(buff[0]) - len - 1); |
| 140 | return buff; |
| 141 | } |
| 142 | |
| 143 | }; // namespace locality |
no test coverage detected