Advertisement
Lancere

TimeLib MH

Aug 21st, 2022
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. local module = {}
  2.  
  3. function module.SortSeconds(total)
  4.     -- vals
  5.     local values = {}
  6.  
  7.     values[1] = {"Year",0}
  8.     local years = values[1]
  9.     values[2] = {"Month",0}
  10.     local months = values[2]
  11.     values[3] = {"Week",0}
  12.     local weeks = values[3]
  13.     values[4] = {"Day",0}
  14.     local days = values[4]
  15.     values[5] = {"Hour",0}
  16.     local hours = values[5]
  17.     values[6] = {"Minute",0}
  18.     local minutes = values[6]
  19.     values[7] = {"Second",0}
  20.     local seconds = values[7]
  21.  
  22.     -- the stuffs
  23.     local t = math.floor(total)
  24.     years[2] = math.floor(t/31540000)
  25.     t -= years[2]*31540000
  26.     months[2] = math.floor(t/2628000)
  27.     t -= months[2]*2628000
  28.     weeks[2] = math.floor(t/604876.71234816)
  29.     t -= weeks[2]*604876.71234816
  30.     days[2] = math.floor(t/86410.96)
  31.     t -= days[2]*86410.96
  32.     hours[2] = math.floor(t/3600)
  33.     t -= hours[2]*3600
  34.     minutes[2] = math.floor(t/60)
  35.     t -= minutes[2]*60
  36.     seconds[2] = math.floor(t)
  37.     t -= seconds[2]
  38.  
  39.     return values
  40. end
  41.  
  42. return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement