diff --git a/configs/cfg/sourcemod.cfg b/configs/cfg/sourcemod.cfg index 591f8ed2..ba55b366 100644 --- a/configs/cfg/sourcemod.cfg +++ b/configs/cfg/sourcemod.cfg @@ -26,6 +26,13 @@ sm_menu_sounds 1 // Default: 30 sm_vote_delay 30 +// Default datetime formatting rules when displaying to clients. +// For full options, see: http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html +// -- +// Default: %m/%d/%Y - %H:%M:%S +// 12 hour format: %m/%d/%Y - %I:%M:%S %p +sm_datetime_format "%m/%d/%Y - %H:%M:%S" + // Specifies the amount of time that is allowed between chat messages. This // includes the say and say_team commands. If a client sends a message faster // than this time, they receive a flood token. When the client has accumulated diff --git a/core/smn_core.cpp b/core/smn_core.cpp index 6c912ba2..440a0de5 100644 --- a/core/smn_core.cpp +++ b/core/smn_core.cpp @@ -48,6 +48,7 @@ #endif HandleType_t g_PlIter; +ConVar sm_datetime_format("sm_datetime_format", "%m/%d/%Y - %H:%M:%S", 0, "Default formatting time rules"); class CoreNativeHelpers : public SMGlobalClass, @@ -118,7 +119,12 @@ static cell_t FormatTime(IPluginContext *pContext, const cell_t *params) { char *format, *buffer; pContext->LocalToString(params[1], &buffer); - pContext->LocalToString(params[3], &format); + pContext->LocalToStringNULL(params[3], &format); + + if (format == NULL) + { + format = const_cast(sm_datetime_format.GetString()); + } #if defined SUBPLATFORM_SECURECRT _invalid_parameter_handler handler = _set_invalid_parameter_handler(_ignore_invalid_parameter); diff --git a/plugins/basetriggers.sp b/plugins/basetriggers.sp index 35afcb40..d90fe38e 100644 --- a/plugins/basetriggers.sp +++ b/plugins/basetriggers.sp @@ -146,7 +146,7 @@ public Action:Command_Say(client, args) else if (strcmp(text[startidx], "thetime", false) == 0) { decl String:ctime[64]; - FormatTime(ctime, 64, "%m/%d/%Y - %H:%M:%S"); + FormatTime(ctime, 64, NULL_STRING); if(GetConVarInt(g_Cvar_TriggerShow)) { diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index c07ae657..5a8750d8 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -297,7 +297,7 @@ native GetTime(bigStamp[2]={0,0}); * * @param buffer Destination string buffer. * @param maxlength Maximum length of output string buffer. - * @param format Formatting rules. + * @param format Formatting rules (passing NULL_STRING will use the rules defined in sm_datetime_format). * @param stamp Optional time stamp. * @noreturn * @error Buffer too small or invalid time format.