|
BlueFire
|
BlueFire
|
Hi all,
How can i convert $idle to mins instead of showing seconds ?
Thanks in advance
|
|
|
|
Joined: Feb 2004
Posts: 2,013
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,013 |
$calc($idle / 60)
Might also want to take a look at $duration in the help file, although that is not entirely what you want, it's close.
|
|
|
|
BlueFire
|
BlueFire
|
Hi FiberOPtics, As long it get rid of the seconds, i don't mind 1.5 (90 seconds) format Thanks alot for your help 
|
|
|
|
Joined: Dec 2002
Posts: 1,253
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,253 |
Assuming your $idle = 1814340 seconds:
30239 minutes $calc($idle / 60) minutes
503:59 $gettok($duration($idle, 3), 1-2, 58)
2w 6d 23h 59m $iif($idle < 60, < 1m, $iif($idle < 3600, $+($int($calc($idle / 60)), m), $iif($idle < 86400, $+($int($calc($idle / 3600)), h $int($calc(($idle % 3600) / 60)), m), $iif($idle < 604800, $+($int($calc($idle / 86400)), d $int($calc($idle % 86400 / 3600)), h $int($calc($idle % 86400 % 3600 / 60)), m), $+($int($calc($idle / 604800)),w $int($calc($idle % 604800 / 86400)), d $int($calc($idle % 604800 % 86400 / 3600)), h $int($calc($idle % 604800 % 86400 % 3600 / 60)), m)))))
:tongue:
|
|
|
|
Joined: Mar 2004
Posts: 175
Vogon poet
|
Vogon poet
Joined: Mar 2004
Posts: 175 |
For the third format, wouldn't this be a simplier way of returning the same message? $replace($duration($idle),wks,w,days,d,hrs,h,mins,m)
|
|
|
|
Iori
|
Iori
|
2w 6d 23h 59m $iif($idle < 60, < 1m, $iif($idle < 3600, $+($int($calc($idle / 60)), m), $iif($idle < 86400, $+($int($calc($idle / 3600)), h $int($calc(($idle % 3600) / 60)), m), $iif($idle < 604800, $+($int($calc($idle / 86400)), d $int($calc($idle % 86400 / 3600)), h $int($calc($idle % 86400 % 3600 / 60)), m), $+($int($calc($idle / 604800)),w $int($calc($idle % 604800 / 86400)), d $int($calc($idle % 604800 % 86400 / 3600)), h $int($calc($idle % 604800 % 86400 % 3600 / 60)), m)))))
:tongue: 2w 6d 23h 59m$remove($duration($idle,2),k,ay,r,in,s)
|
|
|
|
BlueFire
|
BlueFire
|
Hi Hammer, 3rd format is one heap of codes..  Thanks alot to you and also everyone in here for the extra calculation methods 
|
|
|
|
Iori
|
Iori
|
That'll still return the seconds, plus show 'wk' 'day' 'hr' 'min' if they are single.  //resetidle 12186078 | echo -a $replace($duration($idle),wks,w,days,d,hrs,h,mins,m) 20w 1day 1hr 1min 18secs
|
|
|
|
Joined: Dec 2002
Posts: 1,253
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,253 |
Come on, people! The long one was a joke. Did no one notice the :tongue: at the end? I mean, really, who'd type //echo -ati plus all that, really?? I suppose had I wanted to be truly humorous, I could have done something like this and then everyone would be falling off their chairs laughing. alias ymdhns {
if $int($1) > $calc($ctime * 2) {
echo $color(ctcp) -ati2 * Duration out of range
halt
}
var %: = 00:00:00:00:00:00
if $2 == ahead {
var %nt = $asctime($calc($ctime + $int($1)),yyyy mm dd HH nn ss)
var %st = $asctime($ctime,yyyy mm dd HH nn ss)
}
else {
var %nt = $asctime($ctime,yyyy mm dd HH nn ss)
var %st = $asctime($calc($ctime - $int($1)),yyyy mm dd HH nn ss)
}
var %ns = $gettok(%nt,6,32), %ss = $gettok(%st,6,32)
var %nn = $gettok(%nt,5,32), %sn = $gettok(%st,5,32)
var %nh = $gettok(%nt,4,32), %sh = $gettok(%st,4,32)
var %nd = $gettok(%nt,3,32), %sd = $gettok(%st,3,32)
var %nm = $gettok(%nt,2,32), %sm = $gettok(%st,2,32)
var %ny = $gettok(%nt,1,32), %sy = $gettok(%st,1,32)
if %ns < %ss {
dec %nn
inc %ns 60
}
%: = $puttok(%:,$right($+(00,$calc(%ns - %ss)),2),6,58)
if %nn < %sn {
dec %nh
inc %nn 60
}
%: = $puttok(%:,$right($+(00,$calc(%nn - %sn)),2),5,58)
if %nh < %sh {
dec %nd
inc %nh 24
}
%: = $puttok(%:,$right($+(00,$calc(%nh - %sh)),2),4,58)
if %nd < %sd {
dec %nm
[color:#008000]; Work out how many days to "borrow"[/color]
if $istok(1:3:5:7:8:10:12,%sm,58) { inc %nd 31 }
elseif $istok(4:6:9:11,%sm,58) { inc %nd 30 }
elseif (($calc(%sy % 400) == 0) || $&
(($calc(%sy % 4) == 0) && ($calc(%sy % 100) != 0))) inc %nd 29
else inc %nd 28
}
%: = $puttok(%:,$right($+(00,$calc(%nd - %sd)),2),3,58)
if (%nm < %sm) {
dec %ny
inc %nm 12
}
%: = $puttok(%:,$right($+(00,$calc(%nm - %sm)),2),2,58)
%: = $puttok(%:,$right($+(00,$calc(%ny - %sy)),2),1,58)
if $prop == w {
%: = $instok(%:,$right($+(00,$int($calc($gettok(%:,3,58) / 7))),2),3,58)
%: = $puttok(%:,$right($+(00,$calc($gettok(%:,4,58) % 7)),2),4,58)
}
if $2 == 3 {
; Trim off leading 00 tokens
while $gettok(%:,1,58) == 00 { %: = $deltok(%:,1,58) }
; Trim off any remaining leading 0's
if $left(%:,1) == 0 { return $right(%:,-1) }
return %:
}
var %s
if $gettok(%:,1,58) && $gettok(%:,1,58) > 0 {
%s = $calc($ifmatch + 0) $iif($ifmatch == 1,year,years)
}
if $gettok(%:,2,58) && $gettok(%:,2,58) > 0 {
%s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,month,months)
}
if $prop == w {
if $gettok(%:,3,58) && $gettok(%:,3,58) > 0 {
%s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,week,weeks)
}
%: = $deltok(%:,3,58)
}
if $gettok(%:,3,58) && $gettok(%:,3,58) > 0 {
%s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,day,days)
}
if $gettok(%:,4,58) && $gettok(%:,4,58) > 0 {
%s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,hour,hours)
}
if $gettok(%:,5,58) && $gettok(%:,5,58) > 0 {
%s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,minute,minutes)
}
if $2 == 2 { return %s }
if $gettok(%:,6,58) && $gettok(%:,6,58) > 0 {
%s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,second,seconds)
}
return %s
}
//echo -ties * $ymdhns(1814346,1) 6•[color:#6F5B65]19:05:53[/color] * 20 days 23 hours 59 minutes - //echo -ties * $ymdhns(1814346,2) 6•[color:#6F5B65]19:05:55[/color] * 20 days 23 hours 59 minutes 6 seconds - //echo -ties * $ymdhns(1814346,3) 6•[color:#6F5B65]19:05:57[/color] * 20:23:59:06 - //echo -ties * $ymdhns(1814346,1).w 6•[color:#6F5B65]19:06:04[/color] * 2 weeks 6 days 23 hours 59 minutes 6 seconds - //echo -ties * $ymdhns(1814346,2).w 6•[color:#6F5B65]19:06:07[/color] * 2 weeks 6 days 23 hours 59 minutes - //echo -ties * $ymdhns(1814346,3).w 6•[color:#6F5B65]19:06:11[/color] * 2:06:23:59:06 But, then again, not even I would go THAT far. :tongue:
|
|
|
|
DaveC
|
DaveC
|
You have way to much time on your hands dude!
|
|
|
|
Joined: Mar 2004
Posts: 175
Vogon poet
|
Vogon poet
Joined: Mar 2004
Posts: 175 |
|
|
|
|
|