Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Subtract Timecodes in Arrays

  • Subtract Timecodes in Arrays

  • Till Wittmer

    February 28, 2021 at 6:15 pm

    So I have two text fields (Athlete Time & Leader Time) which contain multiple (but the same amount) Timecodes each that have the following format:

    00:00.00 + 00:00.00 + 00:00.00

    The timecodes are used to trigger some animations and two other text fields (Athlete Time Disp & Leader Time Disp) display the individual time codes with the following expression:

    tcs_original = thisComp.layer("Time").text.sourceText .split("+");
    tcs=tcs_original .map( el => parseInt(el.trim().slice(0,2))*60.0 + parseFloat(el.trim().slice(3,8)));
    if (tcs.length) { i=0; while(i<tcs.length-1 && tcs[i+1]<time) { i++ } output = tcs_original[i].trim(); } else { output = ""; } output;

    Now I have a fifth text field that should display the time difference in the following format:

    +/-00:00.00 (- if Athlete Time < Leader Time; + if Athlete Time > Leader Time)

    I tried it by converting the time codes into seconds (similar to the way shown in the expression above) and then reassembling it. But my method doesn’t work for multiple values and I was struggling with implementing the +/- thing.

    My google search was unsuccessful (maybe I was looking for the wrong thing). So I am hoping that one of you might be able to help me out.

    Thanks already in advance for your answers 🙂

Viewing 1 of 1 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy