alias ymdhns {
if ($int($1) > $ctime) {
echo $color(ctcp) -ati2 * Duration out of range
halt
}
var %: = 00:00:00:00:00:00
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
; Work out how many days to "borrow"
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 ($2 == 4) return %:
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 (($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 $ifmatch $iif($ifmatch == 1,second,seconds)
}
return %s
}