Skip to content
Snippets Groups Projects

Ptps controller 5

Merged Адлан Шамавов requested to merge PTPS_Controller_5 into main
Files
4
+ 16
0
@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace App\Action;
use Exception;
use DateTimeImmutable;
class Functions
{
/**
@@ -84,4 +87,17 @@ class Functions
}
return $result;
}
/**
* Функция рассчитывает кол-во дней до нового года
* @param DateTimeImmutable $date дата от которой, необходимо рассчитать кол-во дней
* @return int
* @throws Exception
*/
public function howDaysToNy(DateTimeImmutable $date): int
{
$endYear = date("Y-12-31", date_timestamp_get($date));
$dateInterval = date_diff(new DateTimeImmutable($endYear), $date);
return (int)$dateInterval->format("%a") + 1;
}
}
\ No newline at end of file
Loading