mirror of
https://github.com/znc/znc.git
synced 2026-05-01 11:02:27 +02:00
Store and format time in CBufLine.
Buflines need to know which part of text to wrap with the timestamp. The second parameter to `AddLine` (and shorthands) is that text, which after wrapping is added as the `text` parameter to `NamedFormat`. Timestamps are formatted at the moment buffers are flushed to the client. The client parameter to `GetLine` provides access to the User and the new server-time capability.
This commit is contained in:
11
src/User.cpp
11
src/User.cpp
@@ -502,17 +502,15 @@ CString& CUser::ExpandString(const CString& sStr, CString& sRet) const {
|
||||
}
|
||||
|
||||
CString CUser::AddTimestamp(const CString& sStr) const {
|
||||
CString sRet;
|
||||
return AddTimestamp(sStr, sRet);
|
||||
time_t tm;
|
||||
return AddTimestamp(time(&tm), sStr);
|
||||
}
|
||||
|
||||
CString& CUser::AddTimestamp(const CString& sStr, CString& sRet) const {
|
||||
CString CUser::AddTimestamp(time_t tm, const CString& sStr) const {
|
||||
char szTimestamp[1024];
|
||||
time_t tm;
|
||||
sRet = sStr;
|
||||
CString sRet = sStr;
|
||||
|
||||
if (!GetTimestampFormat().empty() && (m_bAppendTimestamp || m_bPrependTimestamp)) {
|
||||
time(&tm);
|
||||
tm += (time_t)(m_fTimezoneOffset * 60 * 60); // offset is in hours
|
||||
size_t i = strftime(szTimestamp, sizeof(szTimestamp), GetTimestampFormat().c_str(), localtime(&tm));
|
||||
// If strftime returns 0, an error occured in format, or result is empty
|
||||
@@ -530,6 +528,7 @@ CString& CUser::AddTimestamp(const CString& sStr, CString& sRet) const {
|
||||
sRet += szTimestamp;
|
||||
}
|
||||
}
|
||||
|
||||
return sRet;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user