Using computed field to calculate total hours for a datetime field but to exclude all weekend hours Please please if can anyone help I would really appreciate it!

I have managed to get total hours between value 1 and value 2 of my datetime field however I really want to exclude any hours which are in the weekend. I am creating a timesheet for a group of carers and some people will work from a friday night to a saturday morning etc.

this is my code I use atm for calculating the total hours:

$start_value = $entity-&gt;field_work_hour_date[LANGUAGE_NONE][0]['value'];
$end_value = $entity-&gt;field_work_hour_date[LANGUAGE_NONE][0]['value2'];
$timezone = $entity-&gt;field_work_hour_date[LANGUAGE_NONE][0]['timezone'];

$start_date = new DateObject($start_value, $timezone);
$end_date = new DateObject($end_value, $timezone);

$duration = $start_date-&gt;difference($end_date, 'hours');
$entity_field[0]['value'] = $duration;


I am still quite new to drupal and php so I would really appreciate any help.

Cheers
I would :

$duration = $start_date-&gt;difference($end_date, 'hours');
// Place this :
if($start_date-&gt;format('Y-W') != $end_date-&gt;format('Y-W')) {
  $difweeks = $start_date-&gt;difference($end_date, 'weeks');
  $duration = $duration - intval(48 * $difweeks);
}
$entity_field[0]['value'] = $duration;