Move TZ-related code to own place.

This commit is contained in:
Alexey Sokolov
2012-03-22 22:20:41 +07:00
parent eca0211bb8
commit 355d5feb7a
6 changed files with 68 additions and 50 deletions
+1 -14
View File
@@ -155,7 +155,7 @@ public:
CString GetCreatedTime(Csock* pSocket) {
unsigned long long iStartTime = pSocket->GetStartTime();
time_t iTime = iStartTime / 1000;
return FormatTime("%Y-%m-%d %H:%M:%S", iTime);
return CUtils::FormatTime(iTime, "%Y-%m-%d %H:%M:%S", m_pUser->GetTimezone());
}
CString GetLocalHost(Csock* pSocket, bool bShowHosts) {
@@ -241,19 +241,6 @@ public:
virtual ~CListSockets() {
}
CString FormatTime(const CString& sFormat, time_t tm = 0) const {
char szTimestamp[1024];
if (tm == 0) {
tm = time(NULL);
}
setenv("TZ", m_pUser->GetTimezone().c_str(), 1);
strftime(szTimestamp, sizeof(szTimestamp) / sizeof(char),
sFormat.c_str(), localtime(&tm));
return szTimestamp;
}
};
MODULEDEFS(CListSockets, "List active sockets")