PHP Countup timer for MIRC (start from any date and time)

By bandbonjtv on Feb 03, 2013

Screenshots

PHP COUNTUP TIMER FOR MIRC

thanks really goes to this website http://www.mirc.net/projects.php?view_snippet=1161705144# for the example and all the hard work put into its code. but i needed an ON TEXT event rather than an echo, so im posting my edits.
all you need to do is just change this line to reflect any trigger, date and/or time you want. read the link for further instructions on everything else.

on *:text:!session:#: { describe $chan This Stream Session Went Live $datediff(02/01/2013 14:25:00,$date $+ $chr(32) $+ $time,mwdhn) Ago }

START DATE AND TIME: 02/01/2013 14:25:00
CURRENT DATE AND TIME WHEN TRIGGERED: $date $+ $chr(32) $+ $time

thanks to this website here for the example AND WORK.
http://www.mirc.net/projects.php?view_snippet=1161705144#

on *:text:!session:#: { describe $chan This Stream Session Went Live $datediff(02/01/2013 14:25:00,$date $+ $chr(32) $+ $time,mwdhn) Ago } 
alias datediff {
var %t,%result,%n = $crlf , %com = dd $+ $ticks, %s = $iif($3,$qt($1),Date) , %e = $qt($iif($3,$2,$1)), %values = $($+($,$0),2), $&
%error = $regex(%values,/[^yqmwadhns]/g), %values = $gettok($regsubex(%values,/([yqmwdhnsa])/g,$+(\t,$chr(44))),1-,44), $&
%right = y,q,m,w,d,h,n,s, %values = $iif(a !isin %values,$gettok($remove(%right, [ $remove(%right, [ %values ] ) ] ),1-,44),%right)
if ($istok(95 98,$os,32)) return E_OS
if (%error) return E_FORMAT
%t = Dim sd,ed,ret, $+ %values %n sd = %s %n ed = %e %n If isDate(sd) AND isDate(ed) Then %n
tokenize 44 %values
while ($0) {
%t = %t $1 = DateDiff( $qt($replace($upper($1),y,YYYY)) ,sd,ed) %n
if (e !isin $prop) %t = %t sd = DateAdd( $qt($replace($upper($1),y,YYYY,w,ww)) , $1 ,sd) %n
tokenize 32 $2-
}
%t = %t ret = $replace(%values,$chr(44),$+($chr(32),&,,$chr(32)," ",,$chr(32),&,$chr(32))) %n Else ret = "E_DATE" %n End If
.comopen %com MSScriptControl.ScriptControl
if ($comerr) return E_COM
noop $com(%com,language,4,bstr*,vbscript)
if ($com(%com,executestatement,1,bstr*,%t)) && ($com(%com,eval,3,bstr*,ret )) %result = $com(%com).result
else return = E_VB
:error
if ($com(%com)) .comclose %com $com(%com,reset,1)
if ((E_* iswm %result) || (s isin $prop)) return %result
else return $regsubex($replacex($regsubex(%result,/(\d+)/g,$+(\t,$gettok(%values,\n,44))),y,years,m,months,q,quarters,w,weeks,d,days,h,hours,n,minutes,s,seconds),/(?<!\d)(1[a-z]+?)s/g,\t)
}

Comments

Sign in to comment.
SReject   -  Feb 03, 2013

If im not mistaken you can just use

$duration($abs($calc($ctime(date) - $ctime(date))))
bandbonjtv  -  Feb 03, 2013

thanks sreject, it does work. this is what i used to test your simplified version

on *:text:!sessiontest:#: { describe $chan This Stream Session Went Live $duration($abs($calc($ctime(02/01/2013 14:25:00) - $ctime($date $+ $chr(32) $+ $time)))) } 

BUT..... i would like it to display 1mo, rather then 4wks. if there is a way, im down to learn and ditch this long math problem in my remote section. i included another screenshot for you to see what the result of your snippet looked like side by side the php long conversion snippet.

SReject  -  Feb 04, 2013

$dateDiff:

alias -l durationFix {
  if ($regex(datefix, $1, /^(\d+)wks? (.+)$/i)) {
    var %mo, %wks
    if ($iif($floor($calc($regml(datefix,1) / 4)), $v1,)) {
       var %mo = $v1 $+ mo
       var %wks = $iif($calc($v1 % 4), $v1 $+ wks,)
    }
    return %mo %wks $regml(datefix, 2)
  } 
  return $1
}
alias dateDiff {
  var %diff = $duration($abs($calc($ctime - $ctime($1))))
  return $durationFix(%diff)
}

;usage:
$dateDiff(<date>)

Please note, I did NOT test it. I just went off memory so it could be a bit sketchy :/

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.