View Single Post
04/13/18, 11:02 AM   #7
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
Originally Posted by Dolgubon View Post
Those constants would all be the same, dailies all reset at the same time. GetNumSexondsBeforeReset is then quite easy to code.
UndauntedDaily does this for years already.

A simple function could look like this:

Lua Code:
  1. local SECONDS_PER_DAY = 24 * 3600
  2. local QUEST_RESET_TIME_UTC = 6 * 3600
  3.  
  4. local function GetSecondsBeforeDailyQuestReset(now)
  5.     now = now or GetTimeStamp()
  6.     local secondsSinceMidnightUtc = now % SECONDS_PER_DAY
  7.     local diff = GetDiffBetweenTimeStamps(QUEST_RESET_TIME_UTC, secondsSinceMidnightUtc)
  8.     if(diff < 0) then
  9.         diff = diff + SECONDS_PER_DAY
  10.     end
  11.     return diff
  12. end