512mb-bot/libraries/unixToString.lua

10 lines
426 B
Lua
Raw Permalink Normal View History

2021-11-26 16:38:17 +00:00
return function(sec)
2022-05-20 18:20:49 +00:00
local hours = math.floor(sec/3600)
local minutes = math.floor((sec - hours*3600)/60)
local seconds = sec - (hours*3600) - (minutes*60)
hours = ((hours < 10) and ("0"..hours)) or hours
minutes = ((minutes < 10) and ("0"..minutes)) or minutes
seconds = ((seconds < 10) and ("0"..seconds)) or seconds
return ((tonumber(hours) > 0 and hours..":") or "")..minutes..":"..seconds
2021-11-26 16:38:17 +00:00
end