Timed hub time/date
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Timed hub time/date

Started by Cêñoßy†ê, 09 May, 2021, 16:14:39

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Cêñoßy†ê

--[[
				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
Powered By Leviathan™ 2nd Generation v. 1.9

Cêñoßy†ê

Code  above updated with small fix

v2.1.1 by Cêñoßy†ê 10.05.2021
   -- fixed function check(what) to detect correct dates
Powered By Leviathan™ 2nd Generation v. 1.9

Cêñoßy†ê

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)
Powered By Leviathan™ 2nd Generation v. 1.9

SMF spam blocked by CleanTalk