From 7b22099f12aa941618b3cafb7b32a1a3f9f2f67c Mon Sep 17 00:00:00 2001 From: naomiaro Date: Thu, 9 Dec 2010 14:54:12 -0500 Subject: [PATCH] end dates for shows stored in database are non inclusive. --- application/models/Shows.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/application/models/Shows.php b/application/models/Shows.php index 8a517ed61..888e6ec0e 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -35,6 +35,7 @@ class Show { return $event; } + //end dates are non inclusive. public function addShow($data) { $con = Propel::getConnection("campcaster"); @@ -56,10 +57,14 @@ class Show { $data['repeats'] = 1; } else if($data['repeats']) { - $endDate = $data['end_date']; + $sql = "SELECT date '{$data['end_date']}' + INTERVAL '1 day' "; + $r = $con->query($sql); + $endDate = $r->fetchColumn(0); } else { - $endDate = $data['start_date']; + $sql = "SELECT date '{$data['start_date']}' + INTERVAL '1 day' "; + $r = $con->query($sql); + $endDate = $r->fetchColumn(0); } if($data['day_check'] === null) { @@ -112,7 +117,7 @@ class Show { $e_time = $show["end_time"]; foreach($res as $show) { - $days[] = $show["day"]; + $days[] = $show["day"] + $deltaDay; } $shows_overlap = $this->getShows($start, $end, $days, $s_time, $e_time); @@ -192,8 +197,7 @@ class Show { if($row["repeats"]) { if(!is_null($row["last_show"])) { - $time = $row["last_show"] ." ".$row["end_time"]; - $show_end_epoch = strtotime($time); + $show_end_epoch = strtotime($row["last_show"]); } while(true) { @@ -205,6 +209,7 @@ class Show { if (isset($show_end_epoch) && $repeat_epoch < $show_end_epoch && $repeat_epoch < $end_epoch) { $shows[] = $this->makeFullCalendarEvent($row, $repeatDate); } + //case for non-ending shows. else if(!isset($show_end_epoch) && $repeat_epoch < $end_epoch) { $shows[] = $this->makeFullCalendarEvent($row, $repeatDate); }