Thread Tools Display Modes
Prev Previous Post   Next Post Next
04/26/24, 04:37 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,016
Code:
--- @param timestamp integer53
--- @return year integer, month integer, day integer
function GetDateElementsFromTimestamp(timestamp) end

Rough example
Lua Code:
  1. local oldYear, oldMonth, oldDay = GetDateElementsFromTimestamp(timeStampFromSavedVariables)
  2. local year, month, day = GetDateElementsFromTimestamp(GetTimeStamp())
  3. if year == oldYear and month == oldMonth then
  4.   if day ~= oldDay then
  5.      --changed
  6.   end
  7. else
  8.   if year ~= oldYear or month ~= oldMonth or day ~= oldDay then
  9.     --changed
  10.   end
  11. end


Add event_add_on_loaded you need to save the current timestamp to your SavedVariables then.
Remember that event is called each time for all addons so only update if YOUR addon is found, and also remember that event is called on each reloadui too!
So only update once per same year, month and day e.g. or you will overwrite it on each reloadui/login with current date.

Your check "old vs. current" needs to be done before updating the SavedVariables too or you will always comapre current with current.

Last edited by Baertram : 04/26/24 at 04:48 AM.
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » How to use GetDateElementsFromTimestamp?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off