Модуль:Age: различия между версиями
Перейти к навигации
Перейти к поиску
Palkiviad (обсуждение | вклад) (Новая страница: «local utils = {} function getAge(frame) currentTime = os.date("*t") currentYear = currentTime.year if frame.args[4] then currentYear = frame.arg[4] end currentMonth = currentTime.month if frame.args[5] then currentMonth = frame.args[5] end currentDay = currentTime.day if frame.args[6] then currentDay = frame.args[6] end birthYear = frame.args[1] birthMonth = 0 if frame.args[2] then...») |
Palkiviad (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
local utils = {} | local utils = {} | ||
function getAge(frame) | function utils.getAge(frame) | ||
currentTime = os.date("*t") | currentTime = os.date("*t") | ||
currentYear = currentTime.year | currentYear = currentTime.year | ||
Строка 33: | Строка 33: | ||
return age | return age | ||
end | end | ||
return utils |
Версия от 12:27, 21 октября 2023
Для документации этого модуля может быть создана страница Модуль:Age/doc
local utils = {} function utils.getAge(frame) currentTime = os.date("*t") currentYear = currentTime.year if frame.args[4] then currentYear = frame.arg[4] end currentMonth = currentTime.month if frame.args[5] then currentMonth = frame.args[5] end currentDay = currentTime.day if frame.args[6] then currentDay = frame.args[6] end birthYear = frame.args[1] birthMonth = 0 if frame.args[2] then birthMonth = frame.args[2] end birthDay = 0 if frame.args[3] then birthDay = frame.args[3] end age = currentYear - birthYear if birthMonth > 0 and currentMonth < birthMonth then age = age - 1 else if birthDay > 0 and currentMonth == birthMonth and currentDay < birthDay then age = age - 1 end end return age end return utils