These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

12:00am returning as Noon

sjsmith
Registered: Sep 2 2008
Posts: 28

I have a Time Sheet that I posted about yesterday. "Time In" and "Time Out" fields are converted from time entries to whole hours with 2 decimal places after. They are also rounded off to .25.

My problem is that If a user enters 12:00am in their times, the script recognizes it as noon. i.e. If a user comes in at 11:30am and signs out at 12:30am, it returns "1.00" hour instead of "13.00" hours.

Here's my Document level script:

function TimeDiff(cInName, cOutName) {
// Using a time format of 'h:MM tt' for the start and end times
// create JavaScript date time object for start time
var oStart = util.scand("yyyy/mm/dd h:MM tt", util.printd("yyyy/mm/dd ", new Date()) + this.getField(cInName).value);

// create JavaScript date time object for end time
var oEnd = util.scand("yyyy/mm/dd h:MM tt", util.printd("yyyy/mm/dd ", new Date()) + this.getField(cOutName).value);

// adjust date for start time if start time is later than the end time to the previous day
if (oEnd.valueOf() < oStart.valueOf()) {
oStart.setDate(oStart.getDate() - 1);
} // end adjust start date

// convert Times to minutes
var StartTime = (oStart.valueOf() / (1000 * 60));
var EndTime = (oEnd.valueOf() / (1000 * 60));
// round Times to nearest 15 min
StartTime = Round2Nearest(StartTime, 15);
EndTime = Round2Nearest(EndTime, 15);
// convert Times to hours
StartTime = StartTime / 60;
EndTime = EndTime / 60;
// round Times to 1/100 th of an hour
StartTime = Round2Nearest(StartTime, 0.01);
EndTime = Round2Nearest(EndTime, 0.01);
// compute difference in Times
Diff = (EndTime - StartTime)
// return computed difference in hours
return Diff
} // end TimeDiff
// end document level functions

In a previous incarnation of this form, I solved the problem with this:

var RegExp = /12/;
var RegExp2 = /am/;
var TOText = (this.getField("TimeOut1").value);
if(RegExp.test(TOText))
if(RegExp2.test(TOText))
WholeHours = (WholeHours + 12);
var TIText = (this.getField("TimeIn1").value);
if(RegExp.test(TIText))
if(RegExp2.test(TIText))
WholeHours = (WholeHours + 12);

But I haven't been able to make this work.

Any ideas?

Freelancer
Registered: May 26 2009
Posts: 71
Hi sjsmith,

if you use 12 jour clock system,
so 12:00 a.m. (midnight) is at 24 hour clock as 00:00 ,
12:01 a.m. -> 00:01 , 11:59 a.m. -> 11:59 ,
12:00 p.m. (noon) -> 12:00 , 12:01 p.m. ->12:01 ,
11:59 p.m. -> 23:59 and so on...consult http://en.wikipedia.org/wiki/12-hour_clock

Is it not clearer to use this advanced '24 hour clock' system
used widely in western civilizations?
If you use it, then there is no need to do any tricks
to get the real time. Only keep on track which day it is
to get proper time advance.

Was this for any help?

Freelancer

According to most IT HelpDesk people, the most common reason for user error (regardless of Operating System) is ID 10T.

sjsmith
Registered: Sep 2 2008
Posts: 28
Hi Freelancer,

I love your answer and I would TOTALLY prefer to do it that way. Alas, the Users who asked me to make this form are uncomfortable with 24-hour time.
Freelancer
Registered: May 26 2009
Posts: 71
Hello sjsmith,

check this Adobe forums post:
http://forums.adobe.com/thread/439885
there is (SimpleTimeSheet.pdf) somewhat close your calculations.
Only changed time format as h:MM tt and it still works

Freelancer

According to most IT HelpDesk people, the most common reason for user error (regardless of Operating System) is ID 10T.