Permalink
Browse files

Update server-time to new specs with ISO 8601

  • Loading branch information...
1 parent 4036114 commit 1c8485cebeda41d71cac767b9f7ee770bd7820f2 @DarthGandalf DarthGandalf committed Nov 23, 2012
Showing with 11 additions and 5 deletions.
  1. +7 −1 src/Buffer.cpp
  2. +4 −4 src/Client.cpp
View
@@ -40,8 +40,14 @@ CString CBufLine::GetLine(const CClient& Client, const MCString& msParams) const
while (s_msec.length() < 3) {
s_msec = "0" + s_msec;
}
+ // TODO support leap seconds properly
// TODO support message-tags properly
- return "@time=" + CString(m_time.tv_sec) + "." + s_msec + " " + sStr;
+ struct tm stm;
+ memset(&stm, 0, sizeof(stm));
+ gmtime_r(&m_time.tv_sec, &stm);
+ char sTime[20] = {};
+ strftime(sTime, sizeof(sTime), "%Y-%m-%dT%H:%M:%S", &stm);
+ return "@time=" + CString(sTime) + "." + s_msec + "Z " + sStr;
} else {
msThisParams["text"] = Client.GetUser()->AddTimestamp(m_time.tv_sec, m_sText);
return CString::NamedFormat(m_sFormat, msThisParams);
View
@@ -822,7 +822,7 @@ void CClient::HandleCap(const CString& sLine)
for (SCString::iterator i = ssOfferCaps.begin(); i != ssOfferCaps.end(); ++i) {
sRes += *i + " ";
}
- RespondCap("LS :" + sRes + "userhost-in-names multi-prefix znc.in/server-time");
+ RespondCap("LS :" + sRes + "userhost-in-names multi-prefix znc.in/server-time-iso");
m_bInCap = true;
} else if (sSubCmd.Equals("END")) {
m_bInCap = false;
@@ -844,7 +844,7 @@ void CClient::HandleCap(const CString& sLine)
if (sCap.TrimPrefix("-"))
bVal = false;
- bool bAccepted = ("multi-prefix" == sCap) || ("userhost-in-names" == sCap) || ("znc.in/server-time" == sCap);
+ bool bAccepted = ("multi-prefix" == sCap) || ("userhost-in-names" == sCap) || ("znc.in/server-time-iso" == sCap);
GLOBALMODULECALL(IsClientCapSupported(this, sCap, bVal), &bAccepted);
if (!bAccepted) {
@@ -864,7 +864,7 @@ void CClient::HandleCap(const CString& sLine)
m_bNamesx = bVal;
} else if ("userhost-in-names" == *it) {
m_bUHNames = bVal;
- } else if ("znc.in/server-time" == *it) {
+ } else if ("znc.in/server-time-iso" == *it) {
m_bServerTime = bVal;
}
GLOBALMODULECALL(OnClientCapRequest(this, *it, bVal), NOTHING);
@@ -903,7 +903,7 @@ void CClient::HandleCap(const CString& sLine)
}
if (m_bServerTime) {
m_bServerTime = false;
- ssRemoved.insert("znc.in/server-time");
+ ssRemoved.insert("znc.in/server-time-iso");
}
CString sList = "";
for (SCString::iterator i = ssRemoved.begin(); i != ssRemoved.end(); ++i) {

1 comment on commit 1c8485c

FYI, it is now supported in WeeChat (devel), format is auto-detected (ISO 8601 or timestamp are OK): https://savannah.nongnu.org/task/index.php?12255

Please sign in to comment.