소스 검색

New function: ormStopWatch::GetElapsedTime to compute the cumulated elapsed time on a stop watch still running -not used yet (but tested!)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3420 a333f486-631f-4898-b8df-5754b55c2be0
romainq 10 년 전
부모
커밋
7f166535e5
1개의 변경된 파일19개의 추가작업 그리고 0개의 파일을 삭제
  1. 19 0
      core/ormstopwatch.class.inc.php

+ 19 - 0
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;