diff --git a/core/logic/smn_core.cpp b/core/logic/smn_core.cpp index 611d026b24..0229b81a30 100644 --- a/core/logic/smn_core.cpp +++ b/core/logic/smn_core.cpp @@ -200,10 +200,31 @@ static cell_t FormatTime(IPluginContext *pContext, const cell_t *params) #if defined SUBPLATFORM_SECURECRT _invalid_parameter_handler handler = _set_invalid_parameter_handler(_ignore_invalid_parameter); #endif - - time_t t = (params[4] == -1) ? g_pSM->GetAdjustedTime() : (time_t)params[4]; - size_t written = strftime(buffer, params[2], format, localtime(&t)); - + + struct tm *tm_t; + time_t t = (time_t)params[4]; + + if(params[0] > 4 && params[5] == 0) + { + if(params[4] == -1) + { + t = time(NULL); + } + + tm_t = gmtime(&t); + } + else + { + if(params[4] == -1) + { + t = g_pSM->GetAdjustedTime(); + } + + tm_t = localtime(&t); + } + + size_t written = strftime(buffer, params[2], format, tm_t); + #if defined SUBPLATFORM_SECURECRT _set_invalid_parameter_handler(handler); #endif diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index ca5b993f4c..6d4a277743 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -375,9 +375,10 @@ native int GetTime(int bigStamp[2]={0,0}); * @param maxlength Maximum length of output string buffer. * @param format Formatting rules (passing NULL_STRING will use the rules defined in sm_datetime_format). * @param stamp Optional time stamp. + * @param localtime Use OS timezone. * @error Buffer too small or invalid time format. */ -native void FormatTime(char[] buffer, int maxlength, const char[] format, int stamp=-1); +native void FormatTime(char[] buffer, int maxlength, const char[] format, int stamp=-1, bool localtime = true); /** * Loads a game config file.