From 1d16cadc7bdbc5da676dc0efca1ac1c9068f43eb Mon Sep 17 00:00:00 2001 From: Ryan Prather Date: Tue, 31 Dec 2024 23:03:19 +0000 Subject: [PATCH] fix close calculations --- src/Entity/CommunityResource.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Entity/CommunityResource.php b/src/Entity/CommunityResource.php index d854309..ca14bac 100644 --- a/src/Entity/CommunityResource.php +++ b/src/Entity/CommunityResource.php @@ -110,7 +110,7 @@ class CommunityResource private ?float $lon = null; public function __construct( - private DateTime $today = new DateTime('now', new DateTimeZone('America/New_York')) + private DateTime $today = new DateTime('now', new DateTimeZone('America/Indiana/Indianapolis')) ) { } @@ -309,7 +309,7 @@ class CommunityResource return 'C'; } - $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->monClose->format('H:i:s')); + $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->monClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis')); if ($closeAt <= new DateTime()) { return 'C'; } @@ -347,7 +347,7 @@ class CommunityResource return 'C'; } - $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->tueClose->format('H:i:s')); + $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->tueClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis')); if ($closeAt <= new DateTime()) { return 'C'; } @@ -385,8 +385,9 @@ class CommunityResource return 'C'; } - $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->wedClose->format('H:i:s')); - if ($closeAt <= new DateTime()) { + $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->wedClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis')); + + if ($closeAt <= new DateTime("now", new DateTimeZone('America/Indiana/Indianapolis'))) { return 'C'; } @@ -423,7 +424,7 @@ class CommunityResource return 'C'; } - $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->thuClose->format('H:i:s')); + $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->thuClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis')); if ($closeAt <= new DateTime()) { return 'C'; } @@ -461,7 +462,7 @@ class CommunityResource return 'C'; } - $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->friClose->format('H:i:s')); + $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->friClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis')); if ($closeAt <= new DateTime()) { return 'C'; } @@ -499,7 +500,7 @@ class CommunityResource return 'C'; } - $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->satClose->format('H:i:s')); + $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->satClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis')); if ($closeAt <= new DateTime()) { return 'C'; } @@ -537,7 +538,7 @@ class CommunityResource return 'C'; } - $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->sunClose->format('H:i:s')); + $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->sunClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis')); if ($closeAt <= new DateTime()) { return 'C'; } @@ -547,7 +548,7 @@ class CommunityResource public function getHours(): ?string { - $this->today = new DateTime('now', new DateTimeZone('America/New_York')); + $this->today = new DateTime('now', new DateTimeZone('America/Indiana/Indianapolis')); switch ($this->today->format('w')) { case 0: return $this->sun();