From 853ffe804eaa100a698ab53c4c873c1f2848d4d5 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:48:55 +0100 Subject: [PATCH] feat: improve duration calc --- app/controllers/api/functions.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 28512f0d5e..e5f5212058 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1550,11 +1550,10 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId/build') if (\in_array($build->getAttribute('status'), ['ready', 'failed'])) { throw new Exception(Exception::BUILD_ALREADY_COMPLETED); } - $startTime = $build->getAttribute('startTime'); - $endTime = DateTime::now(); - $startTime = strtotime($startTime); - $endTime = strtotime($endTime); - $duration = $endTime - $startTime; + + $startTime = new \DateTime($build->getAttribute('startTime')); + $endTime = new \DateTime('now'); + $duration = $endTime->getTimestamp() - $startTime->getTimestamp(); $build = $dbForProject->updateDocument('builds', $build->getId(), $build->setAttributes([ 'endTime' => DateTime::now(),