Timesheet Total Time Worked Calculations

Timesheet Total Time Worked Calculations

I have seen the below forum explanation of how to generate a timesheet where the start and end time are submitted in the following format, 08:30, 16:45 etc and a total is calculated for hours worked.
I don't understand how to use the script function yet, could someone provide an explanation on how to do this?
I would also like to add a field for Lunch Break which could have entries like 00:30 or 01:00 as in half and hour or an hour and for this time to be taken off the total.

a) you could use   Single-Line Text   field ... and in the   on User Input   section of the field do some verification ...
- is there a  :
- split on the :
- is part 1 a number between 8 and 16
- is part 2 a number between 0 and 59

b) Convert each of the text/string values (fields or variables) to number variables ...

startHH = input.startHour.toLong();
0r
startMM = textMinutes.toLong();


b) Assuming that number variables startHH, startMM, endHH and endMM contain the required numbers ...

minutesWorked = (endHH * 60) + endMM - (startHH * 60) - startMM;