mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Centralize logic to get current server time
A few different implementations of computing the current time were spread out through the code base, most of them using gettimeofday(). This centralizes the logic in CUtil::GetTime() for easier maintenance, and also allows all call sites to get the benefit of the clock_gettime() code path on systems that support it.
This commit is contained in:
committed by
Tor Arne Vestbø
parent
852c9832a0
commit
02bfb9eaf5
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <znc/ZNCDebug.h>
|
||||
#include <znc/Utils.h>
|
||||
#include <iostream>
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
@@ -29,8 +30,7 @@ bool CDebug::debug =
|
||||
#endif
|
||||
|
||||
CDebugStream::~CDebugStream() {
|
||||
timeval tTime;
|
||||
gettimeofday(&tTime, nullptr);
|
||||
timeval tTime = CUtils::GetTime();
|
||||
time_t tSec = (time_t)tTime.tv_sec; // some systems (e.g. openbsd) define
|
||||
// tv_sec as long int instead of time_t
|
||||
tm tM;
|
||||
|
||||
Reference in New Issue
Block a user