diff --git a/Client.cpp b/Client.cpp index d2ccb4ff..588c4937 100644 --- a/Client.cpp +++ b/Client.cpp @@ -1555,10 +1555,7 @@ void CClient::UserCommand(const CString& sLine) { } } } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("UPTIME") == 0) { - time_t started = CZNC::Get().TimeStarted(); - time_t now = time(NULL); - - PutStatus("Running for " + CString(now - started) + " seconds"); + PutStatus("Running for " + CZNC::Get().GetUptime()); } else { PutStatus("Unknown command [" + sCommand + "] try 'Help'"); } diff --git a/znc.cpp b/znc.cpp index b9095cdf..6b0dd587 100644 --- a/znc.cpp +++ b/znc.cpp @@ -94,6 +94,11 @@ CString CZNC::GetTag(bool bIncludeVersion) { return szBuf; } +CString CZNC::GetUptime() { + time_t now = time(NULL); + return CString(now - TimeStarted()) + " seconds"; +} + bool CZNC::OnBoot() { #ifdef _MODULES if (!GetModules().OnBoot()) { diff --git a/znc.h b/znc.h index 647c60aa..37e81aa4 100644 --- a/znc.h +++ b/znc.h @@ -110,6 +110,7 @@ public: bool RehashConfig(CString& sError); static CString GetVersion(); static CString GetTag(bool bIncludeVersion = true); + CString GetUptime(); // This returns the path to the .so and to the data dir // which is where static data (webadmin skins) are saved bool FindModPath(const CString& sModule, CString& sModPath,