* Fix variance of time in project, bug#43671.
This commit is contained in:
@@ -170,6 +170,22 @@ class baseCalc
|
||||
return !empty($filteredRows) ? $filteredRows : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为日期。
|
||||
* Check if a string is a date.
|
||||
*
|
||||
* @param string $dateString
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function isDate($dateString)
|
||||
{
|
||||
$format = 'Y-m-d';
|
||||
$dateTime = DateTime::createFromFormat($format, $dateString);
|
||||
|
||||
return $dateTime && $dateTime->format($format) === $dateString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩展选项。
|
||||
* Expand options.
|
||||
|
||||
@@ -33,8 +33,18 @@ class count_of_actual_time_in_project extends baseCalc
|
||||
$realEnd = $row->realEnd;
|
||||
$status = $row->status;
|
||||
|
||||
if($status == 'closed') $actual = (strtotime($realEnd) - strtotime($realBegan)) / 86400;
|
||||
if($status != 'closed') $actual = (strtotime(date('Y-m-d')) - strtotime($realBegan)) / 86400;
|
||||
if($status != 'doing' and $status != 'closed') return false;
|
||||
|
||||
if($status == 'doing')
|
||||
{
|
||||
if(!$this->isDate($realBegan)) return false;
|
||||
|
||||
$realEnd = date('Y-m-d');
|
||||
}
|
||||
|
||||
if($status == 'closed' && (!$this->isDate($realBegan) || !$this->isDate($realEnd))) return false;
|
||||
|
||||
$actual = (strtotime($realEnd) - strtotime($realBegan)) / 86400;
|
||||
|
||||
$this->result[$project] = $actual;
|
||||
}
|
||||
|
||||
@@ -35,10 +35,20 @@ class variance_of_time_in_project extends baseCalc
|
||||
$realEnd = $row->realEnd;
|
||||
$status = $row->status;
|
||||
|
||||
if($status != 'doing' and $status != 'closed') return false;
|
||||
|
||||
$plan = (strtotime($end) - strtotime($begin)) / 86400;
|
||||
|
||||
if($status == 'closed') $actual = (strtotime($realEnd) - strtotime($realBegan)) / 86400;
|
||||
if($status != 'closed') $actual = (strtotime(date('Y-m-d')) - strtotime($realBegan)) / 86400;
|
||||
if($status == 'doing')
|
||||
{
|
||||
if(!$this->isDate($realBegan)) return false;
|
||||
|
||||
$realEnd = date('Y-m-d');
|
||||
}
|
||||
|
||||
if($status == 'closed' && (!$this->isDate($realBegan) || !$this->isDate($realEnd))) return false;
|
||||
|
||||
$actual = (strtotime($realEnd) - strtotime($realBegan)) / 86400;
|
||||
|
||||
$this->result[$project] = $actual - $plan;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user