WoW:API time: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Use Lua/Libshortcut template. Change category from "LUA Functions" to "Lua functions".)
(Mentioned the deletion of os.*, linked to API_date, linked to Lua 5.1 manual)
Line 1: Line 1:
{{:Lua/Libshortcut|time|os.time}}
  time ([table])
  time ([table])
time() is a reference to the Lua [http://www.lua.org/manual/5.1/manual.html#pdf-os.time os.time] function. It is put in the global table as the os module is not available.


Returns the current time when called without arguments, or a time representing the date and time specified by the given table. This table must have the following fields: year (four digits), month (1--12), day (1--31), hour (0--23), min (0--59), sec (0--61), wday (weekday, Sunday is 1), yday (day of the year), and isdst (daylight saving flag, a boolean).
Returns the current time when called without arguments, or a time representing the date and time specified by the given table. This table must have the following fields: year (four digits), month (1--12), day (1--31), hour (0--23), min (0--59), sec (0--61), wday (weekday, Sunday is 1), yday (day of the year), and isdst (daylight saving flag, a boolean).


 
The returned value is a number, whose meaning depends on your system. In POSIX, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to [[API_date|date]] and difftime. (This point is currently moot, as World of Warcraft only runs under Windows or Mac OS X, both of which use the POSIX definition of this function.)
The returned value is a number, whose meaning depends on your system. In Posix, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to date and difftime.  
 


Note that time() works from the local clock, so it is not synchronized among clients. Very useful for seeding random numbers if you don't need millisecond precision, etc.
Note that time() works from the local clock, so it is not synchronized among clients. Very useful for seeding random numbers if you don't need millisecond precision, etc.

Revision as of 06:40, 28 September 2007

time ([table])

time() is a reference to the Lua os.time function. It is put in the global table as the os module is not available.

Returns the current time when called without arguments, or a time representing the date and time specified by the given table. This table must have the following fields: year (four digits), month (1--12), day (1--31), hour (0--23), min (0--59), sec (0--61), wday (weekday, Sunday is 1), yday (day of the year), and isdst (daylight saving flag, a boolean).

The returned value is a number, whose meaning depends on your system. In POSIX, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to date and difftime. (This point is currently moot, as World of Warcraft only runs under Windows or Mac OS X, both of which use the POSIX definition of this function.)

Note that time() works from the local clock, so it is not synchronized among clients. Very useful for seeding random numbers if you don't need millisecond precision, etc.


DEFAULT_CHAT_FRAME:AddMessage("Current Time: "..time())

Might produce:

Current Time: 1118722038

--Drena

Template:LUA