This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

clock

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
abi
Voice
Posts: 8
Joined: Mon Feb 12, 2024 1:11 am
Location: Kota Makassar

clock

Post by abi »

########################
#      ShareTime       #     
# -------------------  #
#   Date: 25-01-2018   #
#   Version: v0.6      #
#   Author(s): wie     #
########################

set sharetime(format) "%A %B %d %Y -- %H:%M:%S"
bind time - "00 * * * *" sharetime
bind pubm - *jam* sharetime_pub

setudef flag sharetime

proc sharetime {nick uhost hand chan arg} {
	global sharetime waktu
	foreach chan [channels] {
		if {[channel get $chan sharetime]} {
			replacetime
			puthelp "PRIVMSG $chan :$waktu"
		}
	}
}

proc sharetime_pub {nick uhost hand chan arg} {
	global sharetime otime waktu 
	set rtime [unixtime]
	if { $rtime - $otime  > 15} {
		replacetime
		puthelp "PRIVMSG $chan :$waktu"
		set otime $rtime
	}
}
set otime 0

proc replacetime { } {
global sharetime waktu
set arguments [clock format [clock seconds] -timezone :Asia/Makassar -format $sharetime(format)]
	set day [lindex [split $arguments] 0]
	if {$day == "Monday"} { set hari "\00312Senin\003" }
	if {$day == "Tuesday"} { set hari "\00312Selasa\003" }
	if {$day == "Wednesday"} { set hari "\00312Rabu\003" }
	if {$day == "Thursday"} { set hari "\00312Kamis\003" }
	if {$day == "Friday"} { set hari "\00303Jum'at\003" }
	if {$day == "Saturday"} { set hari "\00304Sabtu\003" }
	if {$day == "Sunday"} { set hari "\00304Ahad\003" }
	set tanggal [lindex [split $arguments] 2]
	set month [lindex [split $arguments] 1]
	if {$month == "January"} { set bulan "\00312Januari\003" }
	if {$month == "February"} { set bulan "\00313Februari\003" }
	if {$month == "March"} { set bulan "\00331Maret\003" }
	if {$month == "April"} { set bulan "\00303April\003" }
	if {$month == "May"} { set bulan "\00320Mei\003" }
	if {$month == "June"} { set bulan "\00325Juni\003" }
	if {$month == "July"} { set bulan "\00337Juli\003" }
	if {$month == "August"} { set bulan "\00304Agustus\003" }
	if {$month == "September"} { set bulan "\00309September\003" }
	if {$month == "October"} { set bulan "\00310Oktober\003" }
	if {$month == "November"} { set bulan "\00322November\003" }
	if {$month == "December"} { set bulan "\00304Desember\003" }
	set tahun [lindex [split $arguments] 3]
	set jam [lindex [split $arguments] 5]

	set waktu "Hari $hari, Tanggal64 $tanggal $bulan55 $tahun, Jam12 $jam WITA"
}

putlog "\002SHARETIME:\002 ShareTime.tcl 0.6 by wie is loaded."
Can this script be made into AM or PM time?
Last edited by CrazyCat on Mon Feb 12, 2024 3:35 am, edited 1 time in total.
Reason: replace quote with tcl tags
User avatar
CrazyCat
Revered One
Posts: 1200
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: clock

Post by CrazyCat »

(Moderation : replaced quote tag with tcl tag)

Yes, you can easily by changing sharetime(format)
set sharetime(format) "%A %B %d %Y -- %I:%M:%S %p"
Reference: https://www.tcl.tk/man/tcl8.5/tutorial/Tcl41.html
User avatar
abi
Voice
Posts: 8
Joined: Mon Feb 12, 2024 1:11 am
Location: Kota Makassar

Re: clock

Post by abi »

CrazyCat wrote: Mon Feb 12, 2024 3:39 am (Moderation : replaced quote tag with tcl tag)

Yes, you can easily by changing sharetime(format)
set sharetime(format) "%A %B %d %Y -- %I:%M:%S %p"
Reference: https://www.tcl.tk/man/tcl8.5/tutorial/Tcl41.html
thanks @CrazyCat work fine
Post Reply