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
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.

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

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

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 http://www.w3schools.com/jsref/jsref_tolocalestring.asp Check 'em out they are a great help

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