From 291f05683c62fd895a062fa2c0bd2435d2ce2b82 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Tue, 18 Nov 2014 14:54:10 +0000 Subject: [PATCH] New function: ormStopWatch::GetElapsedTime to compute the cumulated elapsed time on a stop watch still running -not used yet (but tested!) SVN:trunk[3420] --- core/ormstopwatch.class.inc.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/ormstopwatch.class.inc.php b/core/ormstopwatch.class.inc.php index 6160b7dc2..276a6b310 100644 --- a/core/ormstopwatch.class.inc.php +++ b/core/ormstopwatch.class.inc.php @@ -82,6 +82,25 @@ class ormStopWatch return $this->iTimeSpent; } + /** + * Get the working elapsed time since the start of the stop watch + * even if it is currently running + * @param oAttDef AttributeDefinition Attribute hosting the stop watch + */ + public function GetElapsedTime($oAttDef) + { + if (is_null($this->iLastStart)) + { + return $this->GetTimeSpent(); + } + else + { + $iElapsed = $this->ComputeDuration($this, $oAttDef, $this->iLastStart, time()); + return $this->iTimeSpent + $iElapsed; + } + } + + public function GetStartDate() { return $this->iStarted;