pdf - How can I convert time to decimal number in Javascript? -


i'm lazy fill out time sheet @ work end @ end of every month, i've started adding functions our pdf form. acrobat pro offers making advanced calculations using javascript, i'm stuck problem.

i have 2 fields in enter time when start/end working. want calculate overtime , output result in third field. however, want output decimal, when make half hour overtime, result 0.5

example: worktime 8.5 hours, start 7.30 , finish @ 16.00 (4pm).

my code far:

var worktime = this.getfield ("work time").value; var starttime = this.getfield ("start time").value; var endtime = this.getfield ("end time").value;  event.value = worktime - (endtime - starttime); 

separate hours , minutes, divide minutes 60, add hours.

function timestringtofloat(time) {   var hoursminutes = time.split(/[.:]/);   var hours = parseint(hoursminutes[0], 10);   var minutes = hoursminutes[1] ? parseint(hoursminutes[1], 10) : 0;   return hours + minutes / 60; } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -