mIRC Home    About    Download    Register    News    Help

Print Thread
#119716 09/05/05 02:29 PM
Joined: Apr 2005
Posts: 53
A
aDevil Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2005
Posts: 53
Code:
 
alias f12 {
  %i = $duration($ctime($fulldate))
  %t = $duration($ctime(April 14 2005 00:00:00),2)
  %u = $duration(%i) - $duration(%t)
  %k = $duration(%u)
  %h = 7 * $mid(%k,1,1)
  %h =  %h + $mid(%k,6,1)
  echo $active %h
}
 


This alias is working well if %k is giving back this
3wks 4days 17hrs 16mins 20secs
but if is giving back this
21wks 4days 17hrs 16mins 20secs
Not working so well frown what can I do about it?

#119717 09/05/05 02:48 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
What specifically isn't working well when giving the 21 weeks? If you mean that it isn't showing months, then that is normal. $duration will not display months or years because there is not a set number of days in a month or a year. You'd have to make your own script/identifier to do that for you if you wanted it.


Invision Support
#Invision on irc.irchighway.net
#119718 17/05/05 01:21 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Sorry to bring up the past, but I'd use Token Identifiers, and not $mid() because you're only getting the first number.

I used:
Code:
[color:red]$duration($calc($duration($duration($ctime($fulldate))) - $duration($duration($ctime(March 22 1987 00:00:00),2)))))[/color]


to calculate the number of days since my birthdate.

It returns 947wks 2days 13hrs 12mins 47secs for me. We want to get the 947, so we use:

Code:
[color:blue]$gettok([/color]$duration($calc($duration($duration($ctime($fulldate))) - $duration($duration($ctime(March 22 1987 00:00:00),2))))[color:blue],1,119)[/color]


the same goes for the number of days:
Code:
[color:blue]$gettok($gettok([/color]$duration($calc($duration($duration($ctime($fulldate))) - $duration($duration($ctime(March 22 1987 00:00:00),2))))[color:blue],1,100),2,32)[/color]
which returns 2.

Which is a bit more efficient if you have more than 1 number. smile

Code:
alias f12 {
  var %time = $duration($calc($duration($duration($ctime($fulldate))) - $duration($duration($ctime(March 22 1987 00:00:00),2)))))
  echo -a $calc(7 * $gettok(%time,1,119) + $gettok($gettok(%time,1,$asc(100)),2,32))
}


Link Copied to Clipboard