Skip to content

Commit

Permalink
fix calc hours
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhem committed Dec 4, 2021
1 parent 44af5be commit 2371ec4
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/Service/AnalyticsServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,9 @@ public function analyzePerUsers(array $projects, array $tasks, array $users, arr

public function timeToHours(Time $time): float
{
$diff = $time->getEndTime()->diff($time->getStartTime());
$hours1 = $hours2 = $hours3 = 0;
if ($diff->format('%a') > 0) {
$hours1 = $diff->format('%a') * 24;
}
if ($diff->format('%h') > 0) {
$hours2 = $diff->format('%h');
}
if ($diff->format('%i') > 0) {
$hours3 = round($diff->format('%i') / 60, 2);
}
$diff = $time->getEndTime()->getTimestamp() - $time->getStartTime()->getTimestamp();

return $hours1 + $hours2 + $hours3;
return $diff / ( 60 * 60 );
}

private function getProjects(array $projects) : array
Expand Down

0 comments on commit 2371ec4

Please sign in to comment.