Module:TimeGreeting

From Empire of Dragons
Revision as of 08:52, 19 January 2024 by Oberoten (talk | contribs) (Created page with "-- Module:TimeGreeting local p = {} function p.getGreeting() local now = mw.getCurrentFrame():callParserFunction("#time", "U") local hours = tonumber(now:match("(%d%d)")) if hours >= 6 and hours < 12 then return "Good morning" elseif hours >= 12 and hours < 18 then return "Good afternoon" else return "Good evening" end end function p.displayGreeting(frame) return p.getGreeting() end return p")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Good afternoon


-- Module:TimeGreeting

local p = {}

function p.getGreeting()
    local now = mw.getCurrentFrame():callParserFunction("#time", "U")
    local hours = tonumber(now:match("(%d%d)"))

    if hours >= 6 and hours < 12 then
        return "Good morning"
    elseif hours >= 12 and hours < 18 then
        return "Good afternoon"
    else
        return "Good evening"
    end
end

function p.displayGreeting(frame)
    return p.getGreeting()
end

return p