Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local module = {}
- function module.SortSeconds(total)
- -- vals
- local values = {}
- values[1] = {"Year",0}
- local years = values[1]
- values[2] = {"Month",0}
- local months = values[2]
- values[3] = {"Week",0}
- local weeks = values[3]
- values[4] = {"Day",0}
- local days = values[4]
- values[5] = {"Hour",0}
- local hours = values[5]
- values[6] = {"Minute",0}
- local minutes = values[6]
- values[7] = {"Second",0}
- local seconds = values[7]
- -- the stuffs
- local t = math.floor(total)
- years[2] = math.floor(t/31540000)
- t -= years[2]*31540000
- months[2] = math.floor(t/2628000)
- t -= months[2]*2628000
- weeks[2] = math.floor(t/604876.71234816)
- t -= weeks[2]*604876.71234816
- days[2] = math.floor(t/86410.96)
- t -= days[2]*86410.96
- hours[2] = math.floor(t/3600)
- t -= hours[2]*3600
- minutes[2] = math.floor(t/60)
- t -= minutes[2]*60
- seconds[2] = math.floor(t)
- t -= seconds[2]
- return values
- end
- return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement