|
Joined: Dec 2002
Posts: 1,541
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2002
Posts: 1,541 |
On the old board, somebody gave me this digital duration duration script. With the introduction of 6.1, mirc can handle digital durations. The only catch is that mine uses milliseconds as well and it's just not hitting me how to change it. The alias is (line format changed to not scroll the screen): /digdur {
var %t = $1
if ((%t < 0) || (!%t)) { return 0 }
var %wk = $base($int($calc(%t / 604800)),10,10,2), %t = %t % 604800
var %day = $base($int($calc(%t / 86400)),10,10,2), %t = %t % 86400
var %hr = $base($int($calc(%t / 3600)),10,10,2), %t = %t % 3600
var %min = $base($int($calc(%t / 60)),10,10,2)
var %sec = $base($calc(%t % 60),10,10,2)
var %digdur = $+(%yr,:,%wk,:,%day,:,%hr,:,%min,:,%sec)
while (($gettok(%digdur,1,58) == 0) && ($numtok(%digdur,58) > 2)) { %digdur = $deltok(%digdur,1,58) }
return %digdur
} If it would be better to totally rewrite the alias, fine, I dont need the above method so long as the new method works. Your help is appreciated
Those who fail history are doomed to repeat it
|
|
|
|
Joined: Aug 2003
Posts: 1,831
Hoopy frood
|
Hoopy frood
Joined: Aug 2003
Posts: 1,831 |
I would hold off on converting to $duration(N,3) as it is buggy at this point. See my post in Bug reports, $duration(N,3).
|
|
|
|
Joined: Dec 2002
Posts: 1,541
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2002
Posts: 1,541 |
6.11 then eh? Fortunately before I upgrade to new mircs I copy my whole old mirc to a backup dir so it's safe and I can copy anything back over as needed
Those who fail history are doomed to repeat it
|
|
|
|
Joined: Aug 2003
Posts: 1,831
Hoopy frood
|
Hoopy frood
Joined: Aug 2003
Posts: 1,831 |
Hm, your alias produces this result for me (XP pro sp1) //echo -s $digdur(1111111) -=- $digdur(1111111.11) :01:05:20:38:31 -=- :01:05:20:38:31.110000000000002
|
|
|
|
Joined: Dec 2002
Posts: 1,541
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2002
Posts: 1,541 |
It's not perfect, but it works Never had any real issue with it; if it's off by a bit (in your case a very small bit) so be it. Nothing's perfect with that whole digital duration system yet. ive tried a few diff methods and they all seemed to be a bit buggy so I just settled on the last one given to me
Those who fail history are doomed to repeat it
|
|
|
|
Joined: Aug 2003
Posts: 1,831
Hoopy frood
|
Hoopy frood
Joined: Aug 2003
Posts: 1,831 |
alias Idur {
if $1 !isnum 0- { return 0 }
var %a = $base($int($calc($1 /86400)),10,10,2),%z = $1 % 86400,%x,%f = $iif($1 < 3600,nn:ss,HH:nn:ss)
if %a > 6 { var %a = $+($base($int($calc(%a /7)),10,10,2),:,$base($calc(%a % 7),10,10,2)) }
if %a > 0 { %x = %a $+ : }
return $+(%x,$gmt(%z,%f),$iif($gettok($1,2,46),. $+ $ifmatch))
}
|
|
|
|
Joined: Dec 2002
Posts: 1,541
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2002
Posts: 1,541 |
long as I got ya here, how about rounding the ms to 3 digits only?
Those who fail history are doomed to repeat it
|
|
|
|
Joined: Aug 2003
Posts: 1,831
Hoopy frood
|
Hoopy frood
Joined: Aug 2003
Posts: 1,831 |
Change the last line to return $+(%x,$gmt(%z,%f),$iif($gettok($1,2,46),$round(. $+ $ifmatch,3)))
|
|
|
|
Joined: Dec 2002
Posts: 1,541
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2002
Posts: 1,541 |
Problem: //echo -a $idur(222.22222222) - $digdur(222.22222222) yeilds: 03:420.222 - 03:42.222 BTW, my current $digdur alias (another version which I just threw together while mucking round with the new duration system) is (a bit sloppy Im sure):
/digdur {
if (($numtok($1,46) == 0) || ($numtok($1,46) > 2)) { return $false }
if ($numtok($1,46) == 1) { return $duration($1,3) }
if ($numtok($1,46) == 2) {
if ($len($gettok($1,2,46)) <= 3) { return $remove($duration($gettok($1,1,46),3) $+ . $+ $gettok($1,2,46),00:) }
return $remove($duration($gettok($1,1,46),3) $+ $right($round(. $+ $gettok($1,2,46),3),-1),00:)
}
}
Those who fail history are doomed to repeat it
|
|
|
|
Joined: Aug 2003
Posts: 1,831
Hoopy frood
|
Hoopy frood
Joined: Aug 2003
Posts: 1,831 |
Woops sorry return $+(%x,$gmt(%z,%f),$iif($gettok($round($1,3),2,46),. $+ $ifmatch))
|
|
|
|
Joined: Dec 2002
Posts: 1,541
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2002
Posts: 1,541 |
Those who fail history are doomed to repeat it
|
|
|
|
|