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
Views
Replies
Total Likes
Becky,
I have attached my version of a dynamic timesheet that uses Date/Time fields and FormCalc.
It is pretty basic so it can be tweaked to set the start day to the current day, calculate days forward, etcetera. You might want to change the way time is entered as well. The attached PNG highlights the fact that time has to be entered in a 24 hour format. For example, 1:30 PM must be entered as '13:30'.
Steve
Views
Replies
Total Likes
Thanks Steve. However, I am unable to open the attachments. Any idea why?
Becky
Views
Replies
Total Likes
Hi Becky,
I think we are experiencing growing pains with the new forum.
Please send an email requesting the attachments to stwalker.adobe@gmail.com.
Steve
Views
Replies
Total Likes
Thank you Steve! This works great. I appreciate your help!
Becky
Views
Replies
Total Likes
Steve,
Will your formcalc setup work with times past midnight as well? If they do can you send them to me tychis@esthesis.net. If they do not can you assist me in doing a time sheet that will calculate past midnight.
I use the following formcalc formula for a standard 8-5 day
Time2Num(t1,"h:MM A")
Time2Num(t2,"h:MM A")
Time2Num(t2,"h:MM A")-Time2Num(t1,"h:MM A")
var
StartInterval=0
if
(HasValue(t1) and HasValue(t2))then
StartInterval=Time2Num(t2.formattedValue,"h:MM A")-Time2Num(t1.formattedValue,"h:MM A")
endif
Time2Num(t3,"h:MM A")
Time2Num(t4,"h:MM A")
Time2Num(t4,"h:MM A")-Time2Num(t3,"h:MM A")
var
EndInterval=0
if
(HasValue(t3) and HasValue(t4))then
EndInterval=Time2Num(t4.formattedValue,"h:MM A")-Time2Num(t3.formattedValue,
"h:MM A")
endif
Sum(StartInterval+EndInterval)/3600000
thanks
Views
Replies
Total Likes
The form does not consider a work day to cross midnight. That completely changes the orientation and complexity of the form.
Given 24 hour time fomat and epoch time:
If time in < time out, time worked = time out - time in
If time in > time out, time wokred = (midnight - time in) + time out
Views
Replies
Total Likes