This commit is contained in:
Corey D 2025-11-25 23:21:49 +00:00 committed by GitHub
commit 8344e22a97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View File

@ -263,9 +263,18 @@ static cell_t FormatTime(IPluginContext *pContext, const cell_t *params)
#ifdef PLATFORM_WINDOWS
InvalidParameterHandler p;
#endif
// Older plugins dont have param[5]
if (params[0] < 5 || params[5])
{
t = (params[4] == -1) ? g_pSM->GetAdjustedTime() : (time_t)params[4];
written = strftime(buffer, params[2], format, localtime(&t));
}
else
{
t = (params[4] == -1) ? time(NULL) : (time_t)params[4];
written = strftime(buffer, params[2], format, gmtime(&t));
}
}
if (params[2] && format[0] != '\0' && !written)
{

View File

@ -408,9 +408,11 @@ 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 adjust If true, formatting will adjust for the local timezone and sm_time_adjustment value.
* If false, the time will be formatted for UTC/GMT.
* @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 adjust=true);
/**
* Parses a string representing a date and/or time into a unix timestamp.