GameTime:Get

This is an ultra-lite library for retrieving server time in second + millisecond precision. It will stay at hour+minute precision for the first minute played, but will be accurate after that.

hour, minute, second = &lt;PREFIX&gt;_GameTime:Get

Returns

 * hour, minute, second


 * hour : Integer number 0-59
 * minute : Integer number 0-59
 * second : Floating-point number with (theoretically) millisecond precision.

Note that the actual precision is limited by your framerate. With 50FPS, the precision will be 1/50=0,02.

Details

 * The code creates an invisible frame that measures when GetGameTime moves into a new minute in an &lt;OnUpdate&gt; handler, and uses GetTime to offset seconds/milliseconds from when it last happened. Obviously, it cannot return second precision until this has happened the first time.

Code
&lt;PREFIX&gt;_GameTime = { ---  -- function &lt;PREFIX&gt;_GameTime:Get --  -- Return game time as (h,m,s) where s has 3 decimals of   -- precision (though it's only likely to be precise down   -- to ~20th of seconds since we're dependent on frame   -- refreshrate). --  -- During the first minute of play, the seconds will -- consistenly be "00", since we haven't observed any -- minute changes yet. --  --   Get = function(self) if(self.LastMinuteTimer == nil) then local h,m = GetGameTime; return h,m,0; end local s = GetTime - self.LastMinuteTimer; if(s&gt;59.999) then s=59.999; end return self.LastGameHour, self.LastGameMinute, s;  end, ---  -- function &lt;PREFIX&gt;_GameTime:OnUpdate --  -- Called by: Private frame &lt;OnUpdate&gt; handler --  -- Construct high precision server time by polling for -- server minute changes and remembering GetTime when it  -- last did --  OnUpdate = function(self) local h,m = GetGameTime; if(self.LastGameMinute == nil) then self.LastGameHour = h;  		self.LastGameMinute = m;   		return; end if(self.LastGameMinute == m) then return; end self.LastGameHour = h;  	self.LastGameMinute = m;   	self.LastMinuteTimer = GetTime; end, ---  -- function &lt;PREFIX&gt;_GameTime:Initialize --  -- Create frame to pulse OnUpdate for us   -- Initialize = function(self) self.Frame = CreateFrame("Frame"); self.Frame:SetScript("OnUpdate", function self:OnUpdate; end); end } &lt;PREFIX&gt;_GameTime:Initialize;