This allows people to set a date & time in the future, then be able to track how long until that date & time.
Required parameter got missed. Code has been repaired, and messages have been added/updated to make the code more flexible and understandable. Option to delete a tracking has been added. Note: The person using the !del command must have ops in at least one common channel.
on *:text:!setdate*:*:{
if !$ctime($2-) {
.msg $nick Sorry, but I don't recognize the format used.
.msg $nick Examples of recognized formats are:
.msg $nick January 1 1970 00:00:00
.msg $nick 3rd August 1987 3:46pm
.msg $nick 21/4/72 1:30:37
.msg $nick Wed 1998-3-27 21:16
}
elseif $ctime($2-) < $ctime {
.msg $iif($chan,$v1,$nick) Sorry, but $2- has already passed
}
else {
.hadd -m setdate $ctime($2-) $2-
.msg $iif($chan,$v1,$nick) Countdown timer $hget(setdate,0).item has been initiated.
}
}
on *:text:!timeleft*:*:{
if $2 == $null {
.msg $iif($chan,$v1,$nick) There are $hget(setdate,0).item countdown timings in progress.
.msg $iif($chan,$v1,$nick) Please specify which timing you wish, or use 0 (zero) for all
}
elseif $2 == 0 {
var %a = 1, %b = $hget(setdate,0).item
while %a <= %b {
var %setdate = $hget(setdate,%a).data, %settime = $hget(setdate,%a).item
.timer 1 %a .msg $iif($chan,$v1,$nick) $iif(%settime < $ctime,%setdate passed $duration($calc($ctime - %settime)),Time left to %setdate is $duration($calc(%settime - $ctime)))
inc %a
}
}
else {
if !$hget(setdate,$2).item {
.msg $iif($chan,$v1,$nick) Sorry, no entry found for $2
}
elseif $hget(setdate,$2).item < $ctime {
.msg $iif($chan,$v1,$nick) $hget(setdate,$2).data passed $duration($calc($ctime - $hget(setdate,$2).item))
}
else {
.msg $iif($chan,$v1,$nick) Time left to $hget(setdate,$2).data is $duration($calc($hget(setdate,$2).item - $ctime))
}
}
}
on *:start:{
if !$hget(setdate) { .hmake setdate 100 }
if $exists(setdate.hsh) { .hload setdate setdate.hsh }
}
on *:exit:{
.hsave -o setdate setdate.hsh
}
on *:disconnect:{
.hsave -o setdate setdate.hsh
}
on *:text:!del*:*:{
var %op = 0, %a = 1, %b = $comchan($nick,0)
while %a <= %b {
if $nick isop $comchan($nick,%a) {
inc %op
}
inc %a
}
if %op {
.msg $iif($chan,$v1,$nick) Time Left tracking for $hget(setdate,$2).data has been deleted.
.hdel setdate $hget(setdate,$2).item
}
else {
.notice $nick Insufficient Access
}
}
1) Alternative languages could be implemented, but if I do implement them, then the code will not be as a snippet, but as a Add-On, due to the complexity of trying to allocate for an unknown number of languages,
2) A memo field is in my current plans.
3) I suggest you check your calendar, as leap year specifications indicate that February 2012 will have 29 days as the year is evenly divisible by 4, and I just checked 4 different perpetuual calendars, and they all show Feb. 2012 as having 29 days.
3a) If your calendar still indicates that Feb. 2012 only has 28 days, please let me know where you are checking.
Any way to translate the time left (wk, days, ...) to another language? I don't know if it is possible, if it can be done could anyone tell me where to modify that?
By the way, it would be great to be able to add some text to the countdown timer, like:
Someone's Birthday and the time left
Another one, what about checking that february has 28 or 29 days? If you write !setdate 29/02/2012 it is accepted although february in 2012 only has 28 days