I've found a TCL (Daystill v1.02 by David Proper (Dr. Nibble [DrN])), it's the script that does a countdown too but however, it only countdown for the day (example There are 47 days left to My Birthday). The TCL I wan is to check for the duration (exact timing as in day, hours, minutes, seconds).
This is the coding of the TCL:
Code: Select all
set daystill(ver) "v1.02.00"
proc cmdchar { } {global cmdchar_; return $cmdchar_}
bind join - ******* do_daystill_join
proc do_daystill_join {nick uhost hand chan} {
global daystill
if {![daystillchan $chan]} {return 0}
putserv "NOTICE $nick :[getdaystill $daystill(month) $daystill(day) $daystill(year) $daystill(name)]"
}
proc daystillchan {$chan} {
global daystill
if {$daystill(onjoinchan) == ""} {return 0}
set chans [string tolower $daystill(onjoinchan)]
if {$chans == "*"} {set chans [string tolower [channels]]}
if {[lsearch -glob $chans [string tolower "*$chan*"]] > -1 } {return 1}
return 0
}
proc getdaystill {month day year name} {
set timediff [daystill $month $day $year]
if {$timediff > 0} {return "There are [lindex [tdiff2 $timediff] 0] days until $name"}
if {$timediff == 0} {return "Today is $name!"}
if {$timediff < 0} {
set timediff [expr $timediff - ($timediff * 2)]
return "It's been [lindex [tdiff2 $timediff] 0] days Since last $name"
}
}
bind pub - [cmdchar]$daystill(trigger) pub_daystill
proc pub_daystill {nick uhost hand chan rest} {
global daystill
putserv "PRIVMSG $chan :[getdaystill $daystill(month) $daystill(day) $daystill(year) $daystill(name)]"
}
bind msg - $daystill(trigger) msg_daystill
proc msg_daystill {nick uhost handle args} {
global daystill
putserv "PRIVMSG $nick :[getdaystill $daystill(month) $daystill(day) $daystill(year) $daystill(name)]"
}
bind dcc - $daystill(trigger) dcc_daystill
proc dcc_daystill {handle idx args} {
global daystill
putdcc $idx "[getdaystill $daystill(month) $daystill(day) $daystill(year) $daystill(name)]"
}
bind dcc - daystill dcc_daystillm
proc dcc_daystillm {handle idx args} {
global daystill
foreach line $daystill(list) {
set month [lindex $line 0]
set day [lindex $line 1]
set year [lindex $line 2]
set name [lrange $line 3 end]
putdcc $idx "[getdaystill $month $day $year $name]"
}
}
bind msg - daystill msg_daystillm
proc msg_daystillm {nick uhost handle args} {
global daystill
foreach line $daystill(list) {
set month [lindex $line 0]
set day [lindex $line 1]
set year [lindex $line 2]
set name [lrange $line 3 end]
putserv "PRIVMSG $nick :[getdaystill $month $day $year $name]"
}
}
bind pub - [cmdchar]daystill pub_daystillm
proc pub_daystillm {nick uhost hand chan rest} {
global daystill
foreach line $daystill(list) {
set month [lindex $line 0]
set day [lindex $line 1]
set year [lindex $line 2]
set name [lrange $line 3 end]
putserv "PRIVMSG $chan :[getdaystill $month $day $year $name]"
}
}
proc daystill {targetmonth targetday targetyear} {
set rtime [ctime [unixtime]]
set amonth [string range $rtime 4 6]
switch $amonth {
Jan {set month "1"}
Feb {set month "2"}
Mar {set month "3"}
Apr {set month "4"}
May {set month "5"}
Jun {set month "6"}
Jul {set month "7"}
Aug {set month "8"}
Sep {set month "9"}
Oct {set month "10"}
Nov {set month "11"}
Dec {set month "12"}
}
set day [lindex $rtime 2]
set year [string range $rtime 20 23]
set date1 [clock scan $month/$day/$year]
if {$targetyear == 0} {set targetyear $year
set date2 [clock scan $targetmonth/$targetday/$targetyear]
if {$date2<$date1} {set targetyear [expr $year + 1]}
}
set date2 [clock scan $targetmonth/$targetday/$targetyear]
set date3 [expr $date2 - $date1]
return $date3
}
proc tdiff {t} {
return [dotdiff 1 $t]
}
proc tdiff2 {t} {
return [dotdiff 2 $t]
}
proc dotdiff {v ltime} {
if {$v == 1} {
set m_ "m"
set h_ "h"
set d_ "d"
set s_ "s"
} else {
set m_ " minute"
set h_ " hour"
set d_ " day"
set s_ " second"
}
set days 0
set hours 0
set minutes 0
set seconds 0
set after 0
set out ""
set seconds [expr $ltime % 60]
set ltime [expr ($ltime - $seconds) / 60]
set minutes [expr $ltime % 60]
set ltime [expr ($ltime - $minutes) / 60]
set hours [expr $ltime % 24]
set days [expr ($ltime - $hours) / 24]
if {$v == 1} {
if {$days > 0} {append out "${days}$d_ "}
if {$hours > 0} {append out "${hours}$h_ "}
if {$minutes > 0} {append out "${minutes}$m_ "}
if {$seconds > 0} {append out "${seconds}$s_ "}
} else {
if {$days > 0} {append out "${days}$d_[thes $days] "}
if {$hours > 0} {append out "${hours}$h_[thes $hours] "}
if {$minutes > 0} {append out "${minutes}$m_[thes $minutes] "}
if {$seconds > 0} {append out "${seconds}$s_[thes $seconds] "}
}
if {[string index $out [expr [string length $out] - 1]] == " "} {
set out [string range $out 0 [expr [string length $out] - 2]]}
return "$out"
}
proc thes {num} {
if {$num == 1} {return ""} else {return "s"}
}