listsockets: Fix 1970s date bug.

Fixes #1910
This commit is contained in:
RealKindOne committed 2026-10-01 15:26:10 -04:00
1 parent 1158f3bf58
commit bc25a36972
2 files changed
+25 -3

No files matched your search

+13 -3
View File
@@ -153,9 +153,19 @@ class CListSockets : public CModule {
CString GetCreatedTime(const Csock* pSocket) {
unsigned long long iStartTime = pSocket->GetStartTime();
timeval tv;
tv.tv_sec = iStartTime / 1000;
tv.tv_usec = iStartTime % 1000 * 1000;
unsigned long long iNow = CUtils::GetMillTime();
timeval tv = CUtils::GetTime();
unsigned long long iAgeUs = (iNow - iStartTime) * 1000;
tv.tv_sec -= iAgeUs / 1000000;
long long usec = tv.tv_usec - (long long)(iAgeUs % 1000000);
if (usec < 0) {
tv.tv_sec--;
usec += 1000000;
}
tv.tv_usec = usec;
return CUtils::FormatTime(tv, "%Y-%m-%d %H:%M:%S.%f",
GetUser()->GetTimezone());
}