Countdown expression help

Moderators: Disciple, zlovatt

Post Reply
zirnozz
Posts: 2
Joined: February 17th, 2008, 10:59 pm

I'm using Dan Ebbert's script:

Code: Select all

rate = -2;
clockStart = 3604.999;
 
function padZero(n){
  if (n < 10) return "0" + n else return "" + n
}
 
clockTime = clockStart + rate*(time - inPoint);
 
if (clockTime < 0){
  sign = "-";
  clockTime = -clockTime;
}else{
  sign = "";
}
 
t = Math.floor(clockTime);
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
sign + padZero(hr) + ":" + padZero(min) + ":" + padZero(sec)
What I'd like to do is add days and make the hours cycle at 24. My desired output is:
18 : 23 : 59 : 59
(days hours minutes seconds)

I can't figure this out at all. Any help or pointers will be appreciated.
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Play around with this:

Code: Select all

rate = -2;
clockStart = 86404.999;

function padZero(n){
  if (n < 10) return "0" + n else return "" + n
}

clockTime = clockStart + rate*(time - inPoint);

if (clockTime < 0){
  sign = "-";
  clockTime = -clockTime;
}else{
  sign = "";
}

t = Math.floor(clockTime);
day = Math.floor(t/(86400))
hr = Math.floor((t%86400)/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
sign + day + ":" + padZero(hr) + ":" + padZero(min) + ":" + padZero(sec)

Dan
zirnozz
Posts: 2
Joined: February 17th, 2008, 10:59 pm

Thanks Dan, this worked great. I linked the rate to a slider and was able to control the speed just as I liked too.
Post Reply