mIRC Home    About    Download    Register    News    Help

Print Thread
#113556 06/03/05 10:01 AM
Joined: Jul 2004
Posts: 14
B
Pikka bird
OP Offline
Pikka bird
B
Joined: Jul 2004
Posts: 14
Hi all,

How can i convert $idle to mins instead of showing seconds ?

Thanks in advance

#113557 06/03/05 10:09 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
$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.


Gone.
#113558 06/03/05 10:28 AM
Joined: Jul 2004
Posts: 14
B
Pikka bird
OP Offline
Pikka bird
B
Joined: Jul 2004
Posts: 14
Hi FiberOPtics,

As long it get rid of the seconds, i don't mind 1.5 (90 seconds) format

Thanks alot for your help smile

#113559 06/03/05 04:57 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
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:


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#113560 06/03/05 06:28 PM
Joined: Mar 2004
Posts: 175
Vogon poet
Offline
Vogon poet
Joined: Mar 2004
Posts: 175
For the third format, wouldn't this be a simplier way of returning the same message?

Code:
$replace($duration($idle),wks,w,days,d,hrs,h,mins,m)


- Relinsquish
#113561 06/03/05 06:34 PM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Quote:
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)
laugh

#113562 06/03/05 07:17 PM
Joined: Jul 2004
Posts: 14
B
Pikka bird
OP Offline
Pikka bird
B
Joined: Jul 2004
Posts: 14
Hi Hammer,

3rd format is one heap of codes.. laugh

Thanks alot to you and also everyone in here for the extra calculation methods smile

#113563 06/03/05 07:40 PM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
That'll still return the seconds, plus show 'wk' 'day' 'hr' 'min' if they are single. wink

//resetidle 12186078 | echo -a $replace($duration($idle),wks,w,days,d,hrs,h,mins,m)
20w 1day 1hr 1min 18secs

#113564 07/03/05 12:25 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
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.

Code:
alias ymdhns {
  
  if $int($1) &gt; $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 &lt; %ss {
    dec %nn
    inc %ns 60
  }
  %: = $puttok(%:,$right($+(00,$calc(%ns - %ss)),2),6,58)
  if %nn &lt; %sn {
    dec %nh
    inc %nn 60
  }
  %: = $puttok(%:,$right($+(00,$calc(%nn - %sn)),2),5,58)
  if %nh &lt; %sh {
    dec %nd
    inc %nh 24
  }
  %: = $puttok(%:,$right($+(00,$calc(%nh - %sh)),2),4,58)
  if %nd &lt; %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) || $&amp;
      (($calc(%sy % 4) == 0) &amp;&amp; ($calc(%sy % 100) != 0))) inc %nd 29
    else inc %nd 28
  
  }
  %: = $puttok(%:,$right($+(00,$calc(%nd - %sd)),2),3,58)
  if (%nm &lt; %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) &amp;&amp; $gettok(%:,1,58) &gt; 0 {
    %s = $calc($ifmatch + 0) $iif($ifmatch == 1,year,years)
  }
  if $gettok(%:,2,58) &amp;&amp; $gettok(%:,2,58) &gt; 0 {
    %s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,month,months)
  }
  if $prop == w {
    if $gettok(%:,3,58) &amp;&amp; $gettok(%:,3,58) &gt; 0 {
      %s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,week,weeks)
    }
    %: = $deltok(%:,3,58)
  }
  if $gettok(%:,3,58) &amp;&amp; $gettok(%:,3,58) &gt; 0 {
    %s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,day,days)
  }
  if $gettok(%:,4,58) &amp;&amp; $gettok(%:,4,58) &gt; 0 {
    %s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,hour,hours)
  }
  if $gettok(%:,5,58) &amp;&amp; $gettok(%:,5,58) &gt; 0 {
    %s = %s $calc($ifmatch + 0) $iif($ifmatch == 1,minute,minutes)
  }
  if $2 == 2 { return %s }
  if $gettok(%:,6,58) &amp;&amp; $gettok(%:,6,58) &gt; 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:


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#113565 07/03/05 02:47 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
You have way to much time on your hands dude!

#113566 07/03/05 03:23 AM
Joined: Mar 2004
Posts: 175
Vogon poet
Offline
Vogon poet
Joined: Mar 2004
Posts: 175
*dies*


- Relinsquish

Link Copied to Clipboard