Module:Birth date and age

Revision as of 09:07, 27 October 2025 by Wikigence (talk | contribs) (Created page with "local p = {} function p.main(frame) local args = frame.args local year = tonumber(args[1]) local month = tonumber(args[2]) local day = tonumber(args[3]) if not (year and month and day) then return "Invalid date" end local birth_date = os.time{year=year, month=month, day=day} local now = os.time() local age = os.date("*t", now).year - year -- বয়স ঠিক করা local this_year_birthday = os.time{year=os...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Birth date and age/doc

local p = {}

function p.main(frame)
    local args = frame.args
    local year = tonumber(args[1])
    local month = tonumber(args[2])
    local day = tonumber(args[3])

    if not (year and month and day) then
        return "Invalid date"
    end

    local birth_date = os.time{year=year, month=month, day=day}
    local now = os.time()
    local age = os.date("*t", now).year - year

    -- বয়স ঠিক করা
    local this_year_birthday = os.time{year=os.date("*t", now).year, month=month, day=day}
    if now < this_year_birthday then
        age = age - 1
    end

    local months = {
        "January","February","March","April","May","June",
        "July","August","September","October","November","December"
    }

    return string.format("%s %d, %d (age %d)", months[month], day, year, age)
end

return p