mIRC Homepage
Posted By: sparta $calc() / $duration() question - 02/03/13 12:30 PM
What would be the best way to calc time? If the clock was 12:33 and i want to grab how long tme it was if the clock are 14:56 .

I using the format: $time(hh:nn)
Posted By: Deega Re: $calc() / $duration() question - 02/03/13 01:18 PM
//echo -ag $duration($calc($duration(14:56) - $duration(12:33)),3)
Posted By: hixxy Re: $calc() / $duration() question - 02/03/13 04:08 PM
And from the current time to 16:30:

//echo -a $duration($calc($ctime($date 16:30) - $ctime),2)
Posted By: sparta Re: $calc() / $duration() question - 04/03/13 09:11 AM
Tested both ways, no go.
//set %clock 09:02

alias test {
  return $duration($calc($ctime($date %clock) - $ctime),2) 

Curent time: 10:08

And what i get in return is:

The other code does the same thing.

;-- Edit
Now i got the code given by Deega to return a value without the - sign, but it return 2 minutes instead of 2 houers.

And now i testing the user of $ctime instead.

//set %clock $ctime
//echo -a $duration($calc($ctime - %clock))
Posted By: Deega Re: $calc() / $duration() question - 04/03/13 02:56 PM
You have to work out which time is the greater, if you subtract $ctime($date 10:08) from $ctime($date 09:02) you will have a negative number, as $duration() correctly returned.

hh:nn is not good for this, 09:02 (am) looks identical to 09:02 (pm) yet they are 43200 seconds apart. Better to use HH:nn, but by far the best is to set %clock to $ctime.
Posted By: hixxy Re: $calc() / $duration() question - 04/03/13 06:14 PM
Try this:

alias timeuntil {
  var %date = $iif($ctime($date $1) > $ctime,$date,$date($calc($ctime + 86400)))
  return $duration($calc($ctime(%date $1) - $ctime),2) 

alias test { echo -a $timeuntil($1) }

/test 18:00
© mIRC Discussion Forums