Hi,
I'm developing our timesheet with 4 input fields and a 5th total field.
Using Adobe pro 9.
field names:
In1 Out1 In2 Out2 Total1
or (Out1 - In1) + (Out2 - In2) is in my simplified field notation for the Total1 field.
format is HH:MM for all in and out fields. Format is numeric, 2 decimal for total1.
my issue is that it will not calculate time correctly in small increments.
so calculating anything less than quarter hours doesnt represent time correctly.
for instance: 8:05 - 12:00 + 1:00 -4:00 gives 6.95. our payroll person cannot work with 6.95 and would prefer it be 6:55.
i do understand that im not formating the total1 field for time. thats because it doesnt do anything at all when i do.
any suggestions?
What are your scripts for this calculation?
I find that the following document level functions:
function Time2Min(cTime){
// convert time string h:MM tt or HH:MM to minutes
var min = 0
// civilian time
if (/(\d{0,2})[:](\d{2})[ ]([AaPp])/.test(cTime)) {
if (RegExp.$3.toLowerCase() == "p")
RegExp$1 += 12;
min = 60 * Number(RegExp.$1);
min += Number(RegExp.$2);
} else {
// military time
if (/(\d{0,2})[:](\d{2})/.test(cTime)) {
min = 60 * Number(RegExp.$1);
min += Number(RegExp.$2);
}
}
return min;
} // end Time2Min function
function Min2HHMM(nMinutes) {
// round to whole minutes
nMinutes = Math.round(nMinutes);
// compute whole hours
var nHrs = Math.floor(nMinutes / 60);
// compute remainder minutes
var nMins = Math.round(nMinutes % 60);
// return formatted string
return nHrs + ":" + util.printf("%,002.0f", nMins);
} // end Min2HHMM function
Along with this custom field calculation script:
// minutes worked
var nMinWorked = 0;
// interval 1
var In = this.getField('In1').valueAsString;
var Out = this.getField('Out1').valueAsString;
if(In != '' & Out != '')
nMinWorked += Time2Min(Out) - Time2Min(In);
// interval 2
var In = this.getField('In2').valueAsString;
var Out = this.getField('Out2').valueAsString;
if(In != '' & Out != '')
nMinWorked += Time2Min(Out) - Time2Min(In);
// format output
event.value = Min2HHMM(nMinWorked);
Work for me.
You might want to consider using the 24 hour format or include the am/pm indicator in your inputted time formats.
George Kaiser