WoW:API GetTime: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(getTime() elaboration)
(Reversed previous two edits, since they contained incorrect information)
Line 1: Line 1:
<center>'''GetTime''' ''-Documentation by [[user:Zlixar|Zlixar]]- -Updated by [[user:RoQ|RoQ]]-''</center>
<center>'''GetTime''' ''-Documentation by [[user:Zlixar|Zlixar]]-''</center>
When called, returns the elapsed time in seconds from the "epoch" given by [[API GetDate|GetDate()]].
When called, returns the current system uptime in seconds.
  elapsedSeconds = GetTime();
  seconds = GetTime();
----
----
;''Arguments''
;''Arguments''
Line 9: Line 9:
;''Returns''
;''Returns''


:;elapsedSeconds : Floating Point Number - The elapsed time in seconds from the "epoch" (or "zero-hour") which is determined by [[API GetDate|GetDate()]].
:;seconds : Floating Point Number - The current system uptime in seconds.
----
----
;''Example''
;''Example''
Line 18: Line 18:
----
----
;''Details''
;''Details''
:This is relatively unconfirmed, though experimentation on my part has failed to find any fault in this correlation. It may, however, be possible that this tracks something such as current session uptime (as opposed to total system uptime). Any confirmation or corrections appreciated ^.^
:Contrary to what some believe, this does not return your current session time, time since launching the game, or time since the last patch. It returns the uptime as reported by the Windows kernel function [http://msdn.microsoft.com/library/en-us/sysinfo/base/gettickcount.asp GetTickCount()], divided by 1000.
 
:''Added by [[user:RoQ|RoQ]]:''
:It's plausible to use GetTime() as a timestamp, in those cases where you want to verify that one thing has happened before or after another. The only exception to this is when the value of [[API GetDate|GetDate()]] changes, then (obviously) the value of GetTime() has no relationship to the value before [[API GetDate|GetDate()]] changed.
----
=== Get Time ===
Like most functions in WoW I believe that getTime() returns the amount of time in milliseconds since either A) the game has started OR B) your session has begun. The function getDate() returns the date (day precision) of the last patch released by Blizzard, so using it to calculate the real time would be difficult.


local date = GetDate();
local time = GetTime();
scrollBox:AddMessage("test "..(time/60)..date);
Returns something like
test 80.16573333333 Feb 15 2005
Notice how I devided time by 60 to get approximate minutes. It's almost a month from Feb 15 2005 currently so I think getDate() and getTime() serve two very different purposes.
----
{{Template:WoW API}}
{{Template:WoW API}}

Revision as of 16:09, 23 September 2005

GetTime -Documentation by Zlixar-

When called, returns the current system uptime in seconds.

seconds = GetTime();

Arguments
None

Returns
seconds
Floating Point Number - The current system uptime in seconds.

Example
seconds = GetTime();
print("Current system uptime is: "..seconds.." seconds!");
Result
Current system uptime is: 60123 seconds!

Details
Contrary to what some believe, this does not return your current session time, time since launching the game, or time since the last patch. It returns the uptime as reported by the Windows kernel function GetTickCount(), divided by 1000.

Template:WoW API