WoW:API GetTime: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(getTime() elaboration)
m (Move page script moved page API GetTime to API GetTime without leaving a redirect)
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<center>'''GetTime''' ''-Documentation by [[user:Zlixar|Zlixar]]- -Updated by [[user:RoQ|RoQ]]-''</center>
{{wowapi}}__NOTOC__
When called, returns the elapsed time in seconds from the "epoch" given by [[API GetDate|GetDate()]].
Returns the system uptime '''of your computer''' in seconds, with millisecond precision.
  elapsedSeconds = GetTime();
  seconds = GetTime();
----
 
;''Arguments''
==Parameters==
===Arguments===


:''None''
:''None''
----
===Returns===
;''Returns''
:;seconds : Floating Point Number - The current system uptime in seconds.


:;elapsedSeconds : Floating Point Number - The elapsed time in seconds from the "epoch" (or "zero-hour") which is determined by [[API GetDate|GetDate()]].
==Example==
----
;''Example''
  seconds = GetTime();
  seconds = GetTime();
  print("Current system uptime is: "..seconds.." seconds!");
  print("Current system uptime is: "..seconds.." seconds!");
;''Result''
  Current system uptime is: 60123 seconds!
  > Current system uptime is: 60123.558 seconds!
----
;''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 ^.^
 
:''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
==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 '''time since your own computer booted up'''.


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.
:In Windows, this is acquired through the Windows kernel function [http://msdn.microsoft.com/en-us/library/ms724408.aspx GetTickCount()], divided by 1000.
----
{{Template:WoW API}}

Latest revision as of 04:46, 15 August 2023

WoW API < GetTime

Returns the system uptime of your computer in seconds, with millisecond precision.

seconds = GetTime();

Parameters

Arguments

None

Returns

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

Example

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

> Current system uptime is: 60123.558 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 time since your own computer booted up.
In Windows, this is acquired through the Windows kernel function GetTickCount(), divided by 1000.