View Single Post
07-17-21, 11:50 AM   #1
darhanger
A Fallenroot Satyr
 
darhanger's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2017
Posts: 20
Exclamation Help to compare date

Make function for block addon when when the date doesn't match. The problem is, if the time on the computer is not correct, the function will fail. The idea is to also simultaneously check the day / month / year on the server. But duno how make it.

Lua Code:
  1. GetKeyDate = function()
  2. local KeyExpiration = { year = 2022, month = 08, day = 08, hour = 00, min = 00, sec = 00 }
  3. local KeyDate = time(KeyExpiration)
  4.     return KeyDate
  5. end;
  6. GetRealDate = function()
  7.     local OSDate = time()
  8.         return OSDate
  9. end;
  10. GetLicenseTime = function()
  11.     local function Calculate(time)
  12.         local day = floor(time/86400)
  13.         local hour = floor(mod(time,86400)/3600)
  14.         local minutes = floor(mod(time,3600)/60)
  15.         local seconds = floor(mod(time,60))
  16.             return format("%dd : %02dh : %02dm : %02ds", day, hour, minutes, seconds)
  17.     end;
  18.         local TimesLeft = GetKeyDate() - GetRealDate()
  19.         local date3 = Calculate(TimesLeft)
  20.     return date3
  21. end;
  Reply With Quote