mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Add parameter to InspIRCd::TimeString for UTC time formats.
Missing doc added by @attilamolnar
This commit is contained in:
parent
da9adf9e29
commit
1cf8590816
@ -664,9 +664,10 @@ class CoreExport InspIRCd
|
||||
/** Return a time_t as a human-readable string.
|
||||
* @param format The format to retrieve the date/time in. See `man 3 strftime`
|
||||
* for more information. If NULL, "%a %b %d %T %Y" is assumed.
|
||||
* @param utc True to convert the time to string as-is, false to convert it to local time first.
|
||||
* @return A string representing the given date/time.
|
||||
*/
|
||||
static std::string TimeString(time_t curtime, const char* format = NULL);
|
||||
static std::string TimeString(time_t curtime, const char* format = NULL, bool utc = false);
|
||||
|
||||
/** Begin execution of the server.
|
||||
* NOTE: this function NEVER returns. Internally,
|
||||
|
@ -403,14 +403,14 @@ const char* InspIRCd::Format(const char* formatString, ...)
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string InspIRCd::TimeString(time_t curtime, const char* format)
|
||||
std::string InspIRCd::TimeString(time_t curtime, const char* format, bool utc)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (curtime < 0)
|
||||
curtime = 0;
|
||||
#endif
|
||||
|
||||
struct tm* timeinfo = localtime(&curtime);
|
||||
struct tm* timeinfo = utc ? gmtime(&curtime) : localtime(&curtime);
|
||||
if (!timeinfo)
|
||||
{
|
||||
curtime = 0;
|
||||
|
@ -31,7 +31,7 @@ class CommandAlltime : public Command
|
||||
|
||||
CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
|
||||
{
|
||||
const std::string fmtdate = InspIRCd::TimeString(ServerInstance->Time(), "%Y-%m-%d %H:%M:%S");
|
||||
const std::string fmtdate = InspIRCd::TimeString(ServerInstance->Time(), "%Y-%m-%d %H:%M:%S", true);
|
||||
|
||||
std::string msg = ":" + ServerInstance->Config->ServerName + " NOTICE " + user->nick + " :System time is " + fmtdate + " (" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName;
|
||||
|
||||
|
@ -185,7 +185,7 @@ class HttpServerSocket : public BufferedSocket
|
||||
|
||||
WriteData(http_version + " "+ConvToStr(response)+" "+Response(response)+"\r\n");
|
||||
|
||||
rheaders.CreateHeader("Date", InspIRCd::TimeString(ServerInstance->Time(), "%a, %d %b %Y %H:%M:%S GMT"));
|
||||
rheaders.CreateHeader("Date", InspIRCd::TimeString(ServerInstance->Time(), "%a, %d %b %Y %H:%M:%S GMT", true));
|
||||
rheaders.CreateHeader("Server", INSPIRCD_BRANCH);
|
||||
rheaders.SetHeader("Content-Length", ConvToStr(size));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user