Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Get diff in seconds from now to date time by
- Laurea
- Foereaper
- Rochet2
- ]]
- local d = os.date("*t")
- -- Set desired time here
- d.sec = 0
- d.min = 30
- d.hour = 15
- -- 1 = mon, 2 = tue ..
- local weekday = 2
- local ddiff = weekday-d.wday+1
- d.day = d.day+ddiff
- local now = os.date("*t")
- if (ddiff < 0) then
- -- Take into consideration that it is tuesday and we want monday
- d.day = d.day+7
- elseif (ddiff == 0 and d.hour*60*60+d.min*60+d.sec < now.hour*60*60+now.min*60+now.sec) then
- -- Take into consideration that it is the same date, but its already past the wanted time
- d.day = d.day+7
- end
- -- get final times
- local e = os.time(d)
- local diff = e-os.time() -- this is the time in seconds until the wanted date is achieved
- -- test print
- print(os.date("%c", os.time()+diff))
- print(os.date("%c"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement