Copy link to clipboard
Copied
Hi,
Have the following script to add up various time values.....is there any way to have a decimal value (e.g. 1:30 becoming 1.5) instead of the "HH:MM" as calculated?
var aFields = new Array("BlockTimeLine1", "BlockTimeLine2", "BlockTimeLine3", "BlockTimeLine4", "BlockTimeLine5", "BlockTimeLine6", "BlockTimeLine7", "BlockTimeLine8");
var nSum = 0;
var sTime;
for(i = 0; i < aFields.length; i++) {
sTime = this.getField(aFields[i]).valueAsString;
if(sTime == "") sTime = "00:00";
nSum += HHMM2Min(sTime);
}
event.value = Min2HHMM(nSum);
function Min2HHMM(nMinutes) {
var s = util.printf("%,001.0f:%,202.0f", Math.floor(nMinutes / 60), nMinutes % 60);
return s;
}
Copy link to clipboard
Copied
Define the function HHMM2Min.
Copy link to clipboard
Copied
Ah, sorry Bernd - this is just a script I used somewhere before, and not being a JS expert by any means - I couldn't tell you as time calcs. have always been a mystery to me!.
Copy link to clipboard
Copied
You can find the functions HHMM2Min and Min2HHMM on the Web.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now