]> git.localhorst.tv Git - alttp.git/commitdiff
drunken date options
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 3 Jan 2026 18:31:58 +0000 (19:31 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 3 Jan 2026 18:31:58 +0000 (19:31 +0100)
app/Console/Commands/SyncBeerLeague.php

index f642e2aa5f655ac3174cf8e19e05a7fafe62f15d..98eb5b51431557b41b36d35ce4f1bc1f3eb7ec34 100644 (file)
@@ -89,7 +89,7 @@ class SyncBeerLeague extends Command {
                $episode->event()->associate($event);
                $episode->title = $row[0].' vs '.$row[1];
                $episode->comment = $row[4].' - '.$row[7];
-               $start = Carbon::createFromFormat('m/d/Y h:i A \E\S\T', $row[5].' '.$row[6], 'America/Detroit')->setTimezone('UTC');
+               $start = $this->guessDate($row[5].' '.$row[6]);
                if (!$episode->start || $start->ne($episode->start)) {
                        $episode->start = $start;
                }
@@ -104,6 +104,14 @@ class SyncBeerLeague extends Command {
                }
        }
 
+       private function guessDate($date) {
+               try {
+                       return Carbon::createFromFormat('m/d/Y h:i A \E\S\T', $date, 'America/Detroit')->setTimezone('UTC');
+               } catch (\Exception $e) {
+                       return Carbon::createFromFormat('Y-m-d H:i \E\S\T', $date, 'America/Detroit')->setTimezone('UTC');
+               }
+       }
+
        private function syncPlayer(Episode $episode, string $codename): EpisodePlayer|null {
                if (empty($codename)) {
                        return null;