function timeForHour(hour)
local time = (string.split(hour, ":")[1]*60) + string.split(hour, ":")[2]
local current = (os.date("%H")*60) + os.date("%M")
local diff = current < time and time - current or 1440 - (current - time)
local hr = math.floor(diff / 60)
local format =hr .. ":" .. math.floor(diff - (hr * 60))
return format
end
print("Current: " .. os.date("%H:%M"))
print(timeForHour("2:27") .. " hours left until its 2:27")
print(timeForHour("12:40") .. " hours left until its 12:40")
print(timeForHour("14:45") .. " hours left...
it does not matter, lua is same in every tfs wtf
function timeForHour(hour)
local time = (string.split(hour, ":")[1]*60) + string.split(hour, ":")[2]
local current = (os.date("%H")*60) + os.date("%M")
local diff = current < time and time - current or 1440 - (current - time)
local hr = math.floor(diff / 60)
local format =hr .. ":" .. math.floor(diff - (hr * 60))
return format
end
print("Current: " .. os.date("%H:%M"))
print(timeForHour("2:27") .. " hours left until its 2:27")
print(timeForHour("12:40") .. " hours left until its 12:40")
print(timeForHour("14:45") .. " hours left until its 14:45")
print(timeForHour("1:31") .. " hours left until its 1:31")
Current: 14:43
11:44 hours left until its 2:27
21:57 hours left until its 12:40
0:2 hours left until its 14:45
10:48 hours left until its 1:31
function timeForHour(hour)
local time = (string.split(hour, ":")[1] * 60 * 60) + (string.split(hour, ":")[2] * 60) + string.split(hour, ":")[3]
local current = (os.date("%H") * 60 * 60) + (os.date("%M")*60) + os.date("%S")
local diff = current < time and time - current or 86400 - (current - time)
local hr = math.floor((diff / 60) / 60)
local mi = math.floor(math.floor(diff - (hr * 60 * 60)) / 60)
local se = math.floor(diff - ((mi * 60) + (hr * 60 * 60)))
local format = hr .. ":" .. mi .. ":" .. se
return format
end