Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 08/09/2015
- --Last update: 16/05/2016
- --[[ Notes:
- Does:
- Retorna a idade exata de acordo com a data inserida.
- Args:
- day --> Caso seja número, deverá ser DD do dia de nascimento, caso seja string, deverá ser "DD/MM/AAAA"
- month --> Caso day seja número, deverá ser MM do mês de nascimento.
- year --> Caso day seja número, deverá ser AAAA do ano de nascimento.
- ]]--
- age = function(day,month,year)
- if type(day) == "string" then
- day,month,year = day:match("(%d+)/(%d+)/(%d+)")
- end
- day,month,year = tonumber(day),tonumber(month),tonumber(year)
- local cDay,cMonth,cYear = tonumber(os.date("%d")),tonumber(os.date("%m")),tonumber(os.date("%Y"))
- return year<=cYear and (((month>cMonth or month==cMonth and day>cDay) and cYear-year-1 or (month==cMonth and day<=cDay or month<cMonth) and cYear-year)) or 0
- end
Advertisement
Add Comment
Please, Sign In to add comment