Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Script Help

Avatar

Former Community Member
Let me start off with letting you all know I am a novice at scripting.

with some help I was able to acquire the following script:



function addTimes(t1,t2,mod)

{

/*

adds two times together

times in the form 08:30 or 8:30

mod=true for 12 hour clock, false for 24

example:

var t1 = '12:30';

var t2 = '01:45';

var res=addTimes(t1,t2,false);

alert(res);

*returns 14:15*

*/

var m = (t1.substring(0,t1.indexOf(':'))-0) * 60 +

(t1.substring(t1.indexOf(':')+1,t1.length)-0) +

(t2.substring(0,t2.indexOf(':'))-0) * 60 +

(t2.substring(t2.indexOf(':')+1,t2.length)-0);

var h = Math.floor(m / 60);

m=m - (h * 60);

if(mod==true)

h=h%12;

return h + ':' + m;



}



The function for this is to add to entered times together for a total time spent. In the form they are labeled:

Anj, Kld, and Fmr.

Anj and Kld would be added to get Fmr.

The script above is not working and when i do a simple math add the total comes up as a whole number and not rouning as time.

Please any help to get this to work will be appreciated
0 Replies