This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Creating a script that use a database or array
#10
Hello Admin
is there a chance that the schedule script miss the table time so the execution occurs before or after the desired time?

another question, I am trying to compare real time with the table time e.g. if nowTime (>,<,=) tableTime[Y] (+-) X then do something
Edit: This is what I did, any advice admin?
Code:
dtbl = os.date('*t')
date = string.format('%d/%d', dtbl.day, dtbl.month)
time = string.format('%d:%02d', dtbl.hour, dtbl.min)

timeNum = (dtbl.hour-y)*60 + (dtbl.min-x) -- current time in minutes

c = 0 -- to know active table time (active pray)

schedtimes = schedule[ date ] or {}
for _, schedtime in ipairs(schedtimes) do
 
  c=c+1
 
prayTimeAry = string.split(schedtime, ':')
prayNum = tonumber(prayTimeAry[1]*60) + tonumber(prayTimeAry[2])

if (prayNum - timeNum ) == 1 then ----edit
   log ("amplifier CMD")
  elseif schedtime == time then
    log ('Azan CMD')
   -- grp.write('1/0/37',true)
    elseif (timeNum - prayNum) == 6 then
    log("Turn OFF System")
  end
end
Best Regards,
Reply


Messages In This Thread
RE: Creating a script that use a database or array - by khalil - 13.11.2021, 11:23

Forum Jump: