Avatar

Not applicable

I am new to LiveCycle Designer.  I've worked mostly with Acrobat javascripting in the past.  I need to automate the time calculations on a timesheet with 4 columns (AM In, AM Out, PM In, PM Out) for each day of the week.  How would the code below be used in a sample PDF?  I found this and believe it will work, but I'm not sure where it should go in the PDF.

function sTime2Min(sTime) {

     var aTime = sTime.split(":");

     if(aTime.length < 2) sTime[1] = 0;

     return (60 * Number(aTime[0])) + Number(aTime[1]);

}

function Min2HrsMin(fMins) {

     var fHrs = Math.floor(fMins / 60);

     var fMins = fMins % 60;

     var sHrs = util.printf("%,302d", fHrs);

     var sMins - util.printf("%,302d", fMins):

     return sHrs + ":" + sMins;

}

var fEtime = sTime2Min(EndTime.formattedValue) - sTime2Min(StartTime.formattedvalue);

$.rawvalue = Min2HrsMin(fEtime);

Here is the Acbrobat code that I know works, but it does not work in Designer.  Can this be converted to Designer?  If so, how?

var DayWorked =

this.getField("Date");

var aDayWorked =

DayWorked.getArray();

var TotalMinWorked=0;

{

TotalMinWorked + DayMinutes(i);

}

var MinWorked=TotalMinWorked % 60;

var HrsWorked = Math.floor(TotalMinWorked / 60);

event.value = HrsWorked + ":" + MinWorked;

Any help would be greatly appreciated.  Thanks!!

Becky