MCPcopy Create free account
hub / github.com/WinMerge/winmerge / TimeString

Function TimeString

Src/locality.cpp:121–141  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

119 * @return Time as a string, proper to show in the GUI.
120 */
121String 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

Callers 4

ColTimeGetFunction · 0.85
GetLastModifiedFunction · 0.85
DoOpenClipboardMethod · 0.85
GetCurrentTimeStringFunction · 0.85

Calls 1

toFileTimeNPMethod · 0.80

Tested by

no test coverage detected