mirror of
https://github.com/znc/znc.git
synced 2026-08-06 00:43:19 +02:00
Use and propagate microsecond-precision timestamps to FormatTime
This enables sub-second precision timestamp formatting for logs and clients without server-time.
This commit is contained in:
+11
-3
@@ -603,17 +603,25 @@ CString& CUser::ExpandString(const CString& sStr, CString& sRet) const {
|
||||
}
|
||||
|
||||
CString CUser::AddTimestamp(const CString& sStr) const {
|
||||
time_t tm;
|
||||
return AddTimestamp(time(&tm), sStr);
|
||||
timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
return AddTimestamp(tv, sStr);
|
||||
}
|
||||
|
||||
CString CUser::AddTimestamp(time_t tm, const CString& sStr) const {
|
||||
timeval tv;
|
||||
tv.tv_sec = tm;
|
||||
tv.tv_usec = 0;
|
||||
return AddTimestamp(tv, sStr);
|
||||
}
|
||||
|
||||
CString CUser::AddTimestamp(timeval tv, const CString& sStr) const {
|
||||
CString sRet = sStr;
|
||||
|
||||
if (!GetTimestampFormat().empty() &&
|
||||
(m_bAppendTimestamp || m_bPrependTimestamp)) {
|
||||
CString sTimestamp =
|
||||
CUtils::FormatTime(tm, GetTimestampFormat(), m_sTimezone);
|
||||
CUtils::FormatTime(tv, GetTimestampFormat(), m_sTimezone);
|
||||
if (sTimestamp.empty()) {
|
||||
return sRet;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user