mIRC Home    About    Download    Register    News    Help

Print Thread
#185133 05/09/07 01:47 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
Ok i have an alias which turns a duration format into..

04:11:59
hh:mm:ss

;; $formtime($uptime(server,3)) etc
Code:
alias formtime {
  var %a = $round($1,0)
  var %s = $calc(%a % 60)
  var %h = $int($calc(%a / 3600))
  var %m = $int($calc(((%a - (%h * 3600))) / 60))
  return $base(%h,10,10,2) $+ : $+ $base(%m,10,10,2) $+ : $+ $base(%s,10,10,2)
}


I was wondering how to get that to return a format of

01:04:11:59
dd:hh:mm:ss

thanks for any help.

Last edited by vexed2; 05/09/07 01:48 PM.
vexed2 #185135 05/09/07 02:12 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Originally Posted By: vexed2
Ok i have an alias which turns a duration format into..

04:11:59
hh:mm:ss

;; $formtime($uptime(server,3)) etc
Code:
alias formtime {
  var %a = $round($1,0)
  var %s = $calc(%a % 60)
  var %h = $int($calc(%a / 3600))
  var %m = $int($calc(((%a - (%h * 3600))) / 60))
  return $base(%h,10,10,2) $+ : $+ $base(%m,10,10,2) $+ : $+ $base(%s,10,10,2)
}


I was wondering how to get that to return a format of

01:04:11:59
dd:hh:mm:ss

thanks for any help.


hmph, 1 line... Im not sure why your using $int/$base functions when $duration is all you need you even put it as your subject for topic.

alias formtime return $duration($1,1)


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Lpfix5 #185137 05/09/07 02:26 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
That's not helped me 1 iota
I put Duration, not $duration in the subject.
What you suggested still counts up

10secs.. 11secs..
1min 10secs.. 1min 11secs..

That's why i said it does
04:11:59.. 04:12:00..

and i want it to look like.
00:04:11:59.. 00:04:12:00..




vexed2 #185140 05/09/07 04:56 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
Code:

alias formtime {
  var %a = $round($1,0)
  var %s = $calc(%a % 60)
  var %h = $int($calc(%a / 3600))
  var %m = $int($calc(((%a - (%h * 3600))) / 60))
  var %d = $int($calc(%h / 24))
  var %h = $calc(%h - (%d * 24))
  return $base(%d,10,10,2) $+ : $+ $base(%h,10,10,2) $+ : $+ $base(%m,10,10,2) $+ : $+ $base(%s,10,10,2)
}


RoCk #185142 05/09/07 05:14 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
ahh magic
thanks RoCk!


vexed2 #185144 05/09/07 07:06 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Alternatively, you could use $gmt and the known parameters of $asctime. The only pitfall is that "day" starts with one and not zero:

Code:
alias timeformat {
  ; more than one day: subtract one day and use "dd"
  if ($1 >= 86400) { return $gmt($calc($1 - $v2),dd:HH:nn:ss) }
  ; less then one day: fake "dd" with 00
  else { return 00: $+ $gmt($1,HH:nn:ss) }
}

Joined: Aug 2007
Posts: 72
P
Babel fish
Offline
Babel fish
P
Joined: Aug 2007
Posts: 72
Post deleted by PhireCoder


mIRC Scripting: So easy a caveman could do it.
PhireCoder #185153 05/09/07 08:49 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
None of those do what the OP requested, and even fail at some points.

Code:

alias _duration {
  ; days:hours:minutes:seconds
  var %d = $iif($int($calc($1 / 86400)),$v1,0),%s = $calc($1 - (%d * 86400))
  var %h = $iif($int($calc(%s / 3600)),$v1,0),%s = $calc(%s - (%h * 3600))
  var %m = $iif($int($calc(%s / 60)),$v1,0),%s = $calc(%s - (%m * 60))
  return $+($base(%d,10,10,2),:,$base(%h,10,10,2),:,$base(%m,10,10,2),:,$base(%s,10,10,2))
}



Code:

alias _duration {
  ; weeks:days:hours:minutes:seconds
  var %w = $iif($int($calc($1 / 604800)),$v1,0),%s = $calc($1 - (%w * 604800))
  var %d = $iif($int($calc(%s / 86400)),$v1,0),%s = $calc(%s - (%d * 86400))
  var %h = $iif($int($calc(%s / 3600)),$v1,0),%s = $calc(%s - (%h * 3600))
  var %m = $iif($int($calc(%s / 60)),$v1,0),%s = $calc(%s - (%m * 60))
  return $+($base(%w,10,10,2),:,$base(%d,10,10,2),:,$base(%h,10,10,2),:,$base(%m,10,10,2),:,$base(%s,10,10,2))
}


RoCk #185158 05/09/07 10:04 PM
Joined: Aug 2007
Posts: 72
P
Babel fish
Offline
Babel fish
P
Joined: Aug 2007
Posts: 72
Heh, Yeah wasn't thinkin...

OK, here's RoCk's examples Simplified:

Code:
;returns in dd:hh:mm:ss format
alias formtime return $gmt($1,$+($base($iif($int($calc($1 / 86400)),$v1,0),10,10,2),:HH:nn:ss))

Code:
;same as above with weeks added.. ww:dd:hh:mm format
alias formtime return $gmt($1,$+($base($iif($int($calc($1 / 604800)),$v1,0),10,10,4),:,$base($iif($int($calc(($1 - ($iif($int($calc($1 / 604800)),$v1,0) * 604800)) / 86400)),$v1,0),10,10,2),:HH:nn:ss))


Well not really simple but, ya know


mIRC Scripting: So easy a caveman could do it.
PhireCoder #185162 05/09/07 10:38 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
Those fail at 17753:04:03:14:08
or
10,737,418,240 seconds
or
approximately 340 years lol :p

Just messin' with ya .. well done.


Link Copied to Clipboard