Jump to content

function getLastSaturday

Rate this topic


Recommended Posts

Uma função inútil que retorna o último sábado do mês...

 

 

function getLastSaturday(mes, ano)
    local date ={day=31, month= mes, year=ano}
    local saturday =os.date("*t",os.time(date)).wday
    return 31-(saturday%7)
end

exemplo de uso:

print(getLastSaturday(8, 2015)) -- 29
print(getLastSaturday(9, 2015)) -- 26
print(getLastSaturday(10, 2015)) -- 31
print(getLastSaturday(11, 2015)) -- 28
print(getLastSaturday(12, 2015)) -- 26
print(getLastSaturday(12, 2016)) -- 31

 

 

 

Edited by Vodkart
Link to comment
https://xtibia.com/forum/topic/236252-function-getlastsaturday/
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...