Is this correct?
function UnixTime(sec, toreturn) local year = 1970 + math.floor(sec/31557600) local day = math.floor((sec/86400)%365.25) + 1 local month local months = { {31, 31}, {(year%4 == 0 and 29 or 28)}, {31}, {30}, {31}, {30}, {31}, {31}, {30}, {31}, {30}, {31} } for x = 1, 11 do months[x + 1][2] = months[x][2] + months[x + 1][1] if not month and months[x + 1][2] >= day then month = x + 1 end end if not month then month = 1 end local m = months[month] local day = (day+m[1]-m[2]) local second = math.floor((sec%60)) local minute = math.floor((sec/60)%60) local hour = math.floor((sec/3600)%24) return year, m, day, hour, minute, second end
