Newer
Older
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class HomeController extends AbstractController
{
#[Route('/{day}/{month}/{year}', name: 'home')]
public function home(int $day, int $month, int $year): Response
{
$dateAsString = $year . "-" . $month . "-" . $day;
try {
$result = $this->functions->howDaysToNy(new DateTimeImmutable($dateAsString));
} catch (\Exception $e) {
return new Response($e->getMessage());
}
return $this->json(["Days before NY:" => $result]);