Timelines - How to control it through math calculations

Hi
I would like to get some info about how to, via java functions I suppose,
1 Get local time info (from my computer)
2 Input a new time value
3 Do the calculation from the above time values
4 Receive a new value
5 Trigger a Timeline animation based on the new value

// Looking forward for some input

Here’s number 1…

var x = new Date().toLocaleTimeString();

console.log(x)  // the result will be formatted like 11:55:32 PM

@2001pangeah

2 Input a new time value

You do not specify how #2 is accomplished.

3 Do the calculation from the above time values

What's the calculation - what are You trying to do?

Here is a link to info about JavaScript & dates (not Java - an entirely different language)
that will be useful in making date calculations.

4 Receive a new value
5 Trigger a Timeline animation based on the new value

Without knowing what You are trying to accomplish #5 could be anything...

 if(newValue >= 5) {
hypeDocument.continueTimelineNamed('timelineName', hypeDocument.kDirectionForward);
    } else if (newValue < 5) {
hypeDocument.continueTimelineNamed('timelineName', hypeDocument.kDirectionReverse);
   }
1 Like

Moment.JS library might be helpful too.

http://momentjs.com

Hi Jim thank´s for your reply

I will try to clarify a bit . . .

Input of a “new time value” will be done through a java “input time value” function (if that´s possible in java)

Then time value 1 and 2 will be processed through an other java “math” function ( it could be +,-, *, or / if that´s possible).
(Perhaps date, time values must be converted into millisecond´s be fore calculations will be possible, I don´t know)

The result would then be a - “new date”, “new time” value

Then this new value will be used to trigger a time line animation.

Symbolically speaking,
I have a 360° circle that will simulate a orbit of “pearl image” running within a 1 year cycle.
By calculating the date,time of the present day + (let´s say) 93 day´s into the future and receive
a new date,time value - it will be possible to determine how far the animation of the orbit of the pearl will
move in the 1 year cycle.
The calculations above is done with “real time values” but the animation will be a simulation of these values, a scaled down version, just to visually make a point, so to say

// Joran

Hi Greg thank´s for your reply

I will try the suggested
var x = new Date().toLocaleTimeString();
console.log(x) // the result will be formatted like 11:55:32 PM

can you also give me function to dig up the date value, ex. 02-05-2017, because I will both

// Joran

var d = new Date();
var n = d.toLocaleString();
console.log(n)  // 2/5/2017, 10:13:20 PM

Straight from JavaScript Date toLocaleString() Method Check 'em out they are a great help :slight_smile:

1 Like

@2001pangeah

As I am understanding your set-up You need a basic “daysBetween” function; start date - end date; the number derived is then used in an animation. So using your example of 93 days that could be used to orbit (rotate) the “pearl” 93 degrees around a center point in an animation.

Seems like You have enough information at this point - is this accurate?

Yes, thank you very much

1 Like