--[[
Just a simple one
Gives local date and time info in main, on a settable interval.
Name: Date_Time lua 5.1.3 for Px 0.4.0 and up.
Made by [NL]Daddy-Bear™ April 2-2008.
v2 by Cêñoßy†ê 28.07.2020
-- removed bot registration (uses now main bot name)
-- updated timer
-- small cosmetic changes
v2.1 by Cêñoßy†ê 09.05.2021
-- added option to choose how month is shown (txt/number)
-- added option to choose 24h or 12h clock
-- changed message to easyer to modify
more info about os.date --> https://www.lua.org/pil/22.1.html
v2.1.1 by Cêñoßy†ê 10.05.2021
-- fixed function check(what) to detect correct dates
v2.1.2 by Cêñoßy†ê 28.06.2021
-- fixed correct date and time (got stucked to script start time)
¨˜"°º•¨˜"°º• Lets enjoy our Hobby •º°"˜•º°"˜
--]]
clock_type = 24 -- Do we use 24h or 12h clock
show_month = "txt" -- How we show month (txt/number)
interval = 60 -- Interval Date and Time info is giffen in main in Min
main = "\n\t\t\t\t\tø¤*°'°*¤ø Date and Time ø¤*°'°*¤ø\n\n" -- Topic string
borders = "ø¤*°'°*¤ø" -- String as up/down borders
times = 13 -- How often we repeat the string borders
-- DONT TOUCH UNDER THIS LINE --
function check(what)-- we add data to month/date if number used
if what == (01 or 21 or 31) then
x = " st."
elseif what == (02 or 22) then
x = " nd."
elseif what == (03 or 23) then
x = " rd."
else
x = " th."
end
return x
end
function check_time()-- we check the time for 12/24 hour clock
if clock_type == 24 then
curtime = os.date("%X")
else
curtime = os.date("%I:%M:%S").." "..os.date("%p")
end
return curtime
end
function check_month()-- we check the month if number/txt used
if show_month == "txt" then
curmonth = os.date("%B")
else
curmonth = os.date("%m")..check(os.date("%m"))
end
return curmonth
end
function OnStartup()
tmr = TmrMan.AddTimer(interval*60000)
end
function OnTimer(tmr)
local msg = main
msg = msg.."\t"..string.rep(borders,times).."\n"
msg = msg.."\t\tThe Local Date and Time here: "..os.date("%A").." the "..os.date("%d")..check(os.date("%d")).." of "..check_month().." on the Year "..os.date("%Y").." Time is: "..check_time().."\n"
msg = msg.."\t"..string.rep(borders,times).."\n"
Core.SendToAll("<"..SetMan.GetString(SetMan.tStrings.HubBotNick).."> "..msg.."")
collectgarbage()
io.flush()
end
Code above updated with small fix
v2.1.1 by Cêñoßy†ê 10.05.2021
-- fixed function check(what) to detect correct dates
Code above updated with small fix
v2.1.2 by Cêñoßy†ê 28.06.2021
-- fixed correct date and time (got stucked to script start time)