added amb449

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401043
This commit is contained in:
Borja Ferrer 2007-07-04 11:09:48 +00:00
parent d5dbffc6ab
commit b80d04ba01
2 changed files with 23 additions and 0 deletions

View File

@ -83,6 +83,18 @@ static cell_t GetTime(IPluginContext *pContext, const cell_t *params)
return static_cast<cell_t>(t); return static_cast<cell_t>(t);
} }
static cell_t FormatTime(IPluginContext *pContext, const cell_t *params)
{
char *format, *buffer;
pContext->LocalToString(params[1], &buffer);
pContext->LocalToString(params[3], &format);
time_t t = time(NULL);
strftime(buffer, params[2], format, localtime(&t));
return 1;
}
static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params) static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params)
{ {
IPluginIterator *iter = g_PluginSys.GetPluginIterator(); IPluginIterator *iter = g_PluginSys.GetPluginIterator();
@ -332,5 +344,6 @@ REGISTER_NATIVES(coreNatives)
{"ReadPlugin", ReadPlugin}, {"ReadPlugin", ReadPlugin},
{"ThrowError", ThrowError}, {"ThrowError", ThrowError},
{"SetFailState", SetFailState}, {"SetFailState", SetFailState},
{"FormatTime", FormatTime},
{NULL, NULL}, {NULL, NULL},
}; };

View File

@ -264,6 +264,16 @@ native LogError(const String:format[], any:...);
*/ */
native GetTime(bigStamp[2]={0,0}); native GetTime(bigStamp[2]={0,0});
/**
* Format date and time.
*
* @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer.
* @param format Formatting rules.
* @noreturn
*/
native FormatTime(String:buffer[], maxlength, const String:format[]);
/** /**
* Loads a game config file. * Loads a game config file.
* *