Lore archive · Warcraft Wiki, 2023 dump
API date
Last wiki revision 2022-07-21
date is a reference to the os.date function. It is put in the global table as the os module is not available. date ([format [, time]])
It returns a string or a table containing the user's machine's current date and time (or the time represented by ), formatted according to the given string. If one wishes to supply your own format string, then it uses the same rules as strftime (Windows Mac). The special string tells the function to return a table.
This is a mirror of the Lua function os.date.
Note that the default format returned when calling the date function with no parameters will be different depending on whether the game is running on a Windows or a Macintosh computer. If you want your addon to be compatible with both systems, you should therefore not use date without parameters, instead, use
date("%m/%d/%y %H:%M:%S") to display the date in the default Windows format
-or-
date("%a %b %d %H:%M:%S %Y") to display the date in the default Macintosh format.
Be aware that if you use an incorrect format string, including any format specifiers not supported by the C library used in WoW, you will get the error message, "format too long". The error has nothing necessarily to do with the length of the format string; it is simply imprecise error wording in that version of Lua.
The Windows and Mac versions of strftime accept different format specifiers. Attempting to use one OS's exclusive specifiers on the other OS will throw the "format too long" error mentioned above.
There is, however, a common subset of specifiers that work on both Windows and Mac (those specified by the C89 standard). This subset consists of all of the Windows specifiers except %z and the # flag. The safest thing to do is refer to C89, or use a web-based tool like strftime.net.
Note that %z can be used on both OSes, but it will have a different meaning on each one (alias of %Z in Windows, time zone offset on Mac).
Source
https://warcraft.wiki.gg/wiki/API_date · retrieved 2023-11-13 · CC BY-SA 4.0
Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.
This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.