Add ParseTime (strptime) native (#1697)

* Add GetTimeStamp (strptime) native

* Fix description

* Fix typos

* Fix issues

* Rewrite ParseTime

* Fix docstrings

* Fix ParseTime

* Clarify docs
This commit is contained in:
Corey D
2023-07-04 13:42:45 +02:00
committed by GitHub
parent f40ae82df4
commit 5addaffa56
2 changed files with 64 additions and 0 deletions
+18
View File
@@ -412,6 +412,24 @@ native int GetTime(int bigStamp[2]={0,0});
*/
native void FormatTime(char[] buffer, int maxlength, const char[] format, int stamp=-1);
/**
* Parses a string representing a date and/or time into a unix timestamp.
* The timezone is always interpreted as UTC/GMT.
*
* See this URL for valid parameters:
* https://en.cppreference.com/w/cpp/io/manip/get_time
*
* Note that available parameters depends on support from your operating system.
* In particular, ones highlighted in yellow on that page are not currently
* available on Windows and should be avoided for portable plugins.
*
* @param dateTime Date and/or time string.
* @param format Formatting rules (passing NULL_STRING will use the rules defined in sm_datetime_format).
* @return 32bit timestamp (number of seconds since unix epoch).
* @error Invalid date/time string or time format.
*/
native int ParseTime(const char[] dateTime, const char[] format);
/**
* Loads a game config file.
*