Module:TimeGreeting
Jump to navigation
Jump to search
Good evening
-- Module:TimeGreeting
local p = {}
function p.getGreeting()
-- Use local time (server's time zone)
local now = mw.getCurrentFrame():callParserFunction("#time", "Y-m-d H:i:s")
local offsetHours = tonumber(mw.getCurrentFrame():callParserFunction("#time", "-12")) / 100
-- Alternatively, use UTC+1
-- local now = mw.getCurrentFrame():callParserFunction("#time", "Y-m-d H:i:s", "1")
-- local offsetHours = 1
local hours = tonumber(now:match("(%d%d)"))
if hours then
-- Adjust for local time zone
hours = hours + offsetHours
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
else
return "Error: Unable to determine the time"
end
end
function p.displayGreeting(frame)
return p.getGreeting()
end
return p