From 59f57d69b63be1297e4d0648ad268e0512bf3ddf Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 24 May 2013 07:07:04 +0000 Subject: [PATCH] * Timesheet: allow to add timesheets starting yesterday and end today (no warning end-time before start-time) --- timesheet/inc/class.timesheet_ui.inc.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/timesheet/inc/class.timesheet_ui.inc.php b/timesheet/inc/class.timesheet_ui.inc.php index d71abb40ca..df1cacad54 100644 --- a/timesheet/inc/class.timesheet_ui.inc.php +++ b/timesheet/inc/class.timesheet_ui.inc.php @@ -126,6 +126,16 @@ class timesheet_ui extends timesheet_bo if ($end && $start) // start- & end-time --> calculate the duration { $content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60; + // check if negative duration is caused by wrap over midnight + if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60) + { + $yesterday = new egw_time(); + $yesterday->modify('-1day'); + if ($start->format('Y-m-d') == $yesterday->format('Y-m-d')) + { + $content['ts_duration'] += 24*60; + } + } //echo "

end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]

\n"; } elseif ($content['ts_duration'] && $end) // no start, calculate from end and duration