Skip to content

Commit

Permalink
fix for timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
fiste788 committed Oct 28, 2024
1 parent 42722e7 commit 7885a51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/Command/GetMatchdayScheduleCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace App\Command;
Expand All @@ -11,6 +12,7 @@
use Cake\Console\CommandInterface;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\Core\Configure;
use Cake\Http\Client;
use Cake\I18n\DateTime;
use DateTimeInterface;
Expand Down Expand Up @@ -129,17 +131,19 @@ public function exec(Season $season, Matchday $matchday, ConsoleIo $io): DateTim
*/
$matchsResponse = $client->get(
'/api/match?extra_link&order=oldest&lang=it&season_id=' .
$seasonId .
'&match_day_id=' .
$matchdayItem['id_category']
$seasonId .
'&match_day_id=' .
$matchdayItem['id_category']
);
/** @var string $date */
$date = $matchsResponse->getJson()['data'][0]['date_time'];

if ($date != '') {
$io->success($date);
$out = DateTime::createFromFormat(DateTimeInterface::ATOM, $date);
$io->verbose($out->__toString());
$timezone = Configure::read('App.defaultTimezone');
$out = DateTime::createFromFormat(DateTimeInterface::RFC3339, $date, new \DateTimeZone('UTC'));
$out = $out->setTimezone($timezone);
$io->verbose(print_r($out, true));

return $out;
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/SelectionsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace App\Controller;
Expand Down Expand Up @@ -27,11 +28,11 @@ function (Event $event): void {
$selection->matchday_id = $this->currentMatchday->id;
$selection->active = true;

$this->Selections->updateQuery()->set(['active' => false])->where([
$this->Selections->updateQuery()->set(['active' => null])->where([
'team_id' => $selection->team_id,
'matchday_id' => $selection->matchday_id,
'active' => true,
]);
])->execute();
}
);

Expand Down

0 comments on commit 7885a51

Please sign in to comment.