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.

Calculate number of minutes until a future date/time
#1
I have this info from two group-adresses 3-byte time/day and three byte date
This is a date and time several days ahead for the start of a meeting
I want to calculate the number of minutes from "now" until the date/time in this two group-addresses, but I can't figure out how to do it...


Code:
Event for CUE Starttid (0/1/20) 29.03.2023 21:54:04
* arg: 1
  * string: startdate
* arg: 2
  * table:
   ["day"]
    * number: 2
   ["year"]
    * number: 2023
   ["month"]
    * number: 4
Event for CUE Starttid (0/1/20) 29.03.2023 21:54:04
* arg: 1
  * string: starttime
* arg: 2
  * table:
   ["day"]
    * number: 7
   ["minute"]
    * number: 0
   ["second"]
    * number: 0
   ["hour"]
    * number: 11
   ["min"]
    * number: 0
   ["sec"]
    * number: 0
Reply
#2
Try this:
Code:
time = grp.getvalue('0/0/1')
date = grp.getvalue('0/0/2')

-- merge tables
for k, v in pairs(date) do
  time[ k ] = v
end

seconds = os.time(time) - os.time()
minutes = math.round(seconds / 60)

log(minutes)
Reply
#3
Magic Shy
Thank you very much.
Reply


Forum Jump: