I have the following:
(12:00 - 9:00) = 3.00 but when (12:00 - 9:15) = 2.85 should be 2.45
How to you convert from 100 to 60 in javascript so that the time results are correct?
My Product Information:
Acrobat Pro 8.1.2, Windows
I would compute the difference using minutes because of the way JavaScirpt and computers divide in binary.
But since you have the difference in hours, your result field must have no formatting as the script will provide the formatted result.
// diffHrs = the difference in hours
// some debugging tracing console.println("Difference in hours: " + diffHrs); // full decimal hours console.println("Difference hours: " + Math.floor(diffHrs)); // hours truncated from difference console.println("Difference minutes: " + diffHrs * 60); // computed minutes from full decimal hours console.println("Difference minutes of hour: " + (diffHrs * 60) % 60); // minutes remainder (modulo) of full decimal hours console.println("Difference minutes of hour rounded: " + Math.round((diffHrs * 60) % 60)); // rounded remainder minutes // end debugging trace
// convert difference in hours into whole hours and minutes - minutes formatted with leading zero event.value = Math.floor(diffHrs) + ":" + util.printf("%,002d", Math.round(diffHrs * 60) % 60);
But since you have the difference in hours, your result field must have no formatting as the script will provide the formatted result.
// diffHrs = the difference in hours
// some debugging tracing
console.println("Difference in hours: " + diffHrs); // full decimal hours
console.println("Difference hours: " + Math.floor(diffHrs)); // hours truncated from difference
console.println("Difference minutes: " + diffHrs * 60); // computed minutes from full decimal hours
console.println("Difference minutes of hour: " + (diffHrs * 60) % 60); // minutes remainder (modulo) of full decimal hours
console.println("Difference minutes of hour rounded: " + Math.round((diffHrs * 60) % 60)); // rounded remainder minutes
// end debugging trace
// convert difference in hours into whole hours and minutes - minutes formatted with leading zero
event.value = Math.floor(diffHrs) + ":" + util.printf("%,002d", Math.round(diffHrs * 60) % 60);
George Kaiser