Or this timesheet...but have user input times as 24-hour format, and automatically converted to 12-hour format.
Acrobat does not implement 24 military time so unless you are going to write the needed code for keystrokes, validation, and formatting, I would look at using the civilian 24 hour time format. Also there is 24:00 since that is really 00:00 the next day.
I would start out with computing the time for one in and out cycle, then see what the common repeated code is and develop a reusable function for those blocks of code. That will make the in and out cycle computation use less code and if an error is found in the common code there is only one place to correct it.
A sample script to get you started:
var cTimeIn = "9:00 am";
var cTimeOut = "5:01 pm";
var cTimeFormat = "h:MMtt";
var cDateString = "1-Jan-2000";
var cDateFormat = "d-mmm-yyyy";
// convert time strings to date object;
var oTimeIn = util.scand(cDateFormat + " " + cTimeFormat, cDateString + " " + cTimeIn);
var oTimeOut = util.scand(cDateFormat + " " + cTimeFormat, cDateString + " " + cTimeOut);
// compute difference in millisconds;
var nDiff = oTimeOut.getTime() - oTimeIn.getTime();
// convert milliseconds into hours;
var nHours = nDiff / (1000 * 60 * 60);
app.alert("Hours worked: " + nHours, 3, 0);
Thanks for the reply, GKaiseril!
It seems like the 24-hour military time is a pain. I've been trying a different approach.
Is this something that can reasonable coded in Acrobat? Or would I need to resort to another program?
Here's the .pdf file that I have been working on. I've been trying different ideas to get this to work. None have worked so far.