mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-06 18:08:36 +00:00
Add utc option to FormatTime
This commit is contained in:
parent
3100e23b87
commit
a0dff2c8ed
@ -260,8 +260,16 @@ static cell_t FormatTime(IPluginContext *pContext, const cell_t *params)
|
|||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
InvalidParameterHandler p;
|
InvalidParameterHandler p;
|
||||||
#endif
|
#endif
|
||||||
t = (params[4] == -1) ? g_pSM->GetAdjustedTime() : (time_t)params[4];
|
if (params[5])
|
||||||
written = strftime(buffer, params[2], format, localtime(&t));
|
{
|
||||||
|
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)
|
if (params[2] && format[0] != '\0' && !written)
|
||||||
|
|||||||
@ -407,9 +407,11 @@ native int GetTime(int bigStamp[2]={0,0});
|
|||||||
* @param maxlength Maximum length of output string buffer.
|
* @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 format Formatting rules (passing NULL_STRING will use the rules defined in sm_datetime_format).
|
||||||
* @param stamp Optional time stamp.
|
* @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.
|
* @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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a game config file.
|
* Loads a game config file.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user