From 9fe9e208b062421617ee029522db2a4c3834f2a4 Mon Sep 17 00:00:00 2001
From: ebremner <ebremner@uwaterloo.ca>
Date: Mon, 5 Jul 2021 11:02:23 -0400
Subject: [PATCH] ISTWCMS-4917: adding check for only upcoming dates

---
 src/Service/UWService.php | 45 ++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 24 deletions(-)

diff --git a/src/Service/UWService.php b/src/Service/UWService.php
index 29f37a47..8da5b01c 100644
--- a/src/Service/UWService.php
+++ b/src/Service/UWService.php
@@ -611,32 +611,29 @@ class UWService implements UWServiceInterface {
       // out correct values.
       foreach ($dates as $date) {
 
-        // The all day case, duration is always 1439.
-        if ($date['duration'] == '1439' && $date['end_value'] > strtotime("now")) {
-          $return_dates[] = date('l, F j, Y', $date['value']) . ' (all day)';
-        }
-        else {
-
-          // If the date is upcoming, meaning greater than right now.
-          // Taking this out for now, will be putting it back, if
-          // we figure out how to do this in the view.
-          // if ($date['end_value'] > strtotime("today")) {.
-          // If this is the same day, get the date and the start
-          // and end times.
-          if ($date['duration'] < '1439') {
-            $start_date = date('l, F j, Y g:i A', $date['value']);
-            $end_date = date('g:i A', $date['end_value']);
-          }
+        // Ensure that the dates are greater than now, before
+        // adding it to the dates array.
+        if ($date['end_value'] > strtotime("now")) {
+
+          // The all day case, duration is always 1439.
+          if ($date['duration'] == '1439') {
+            $return_dates[] = date('l, F j, Y', $date['value']) . ' (all day)';
+          } else {
+
+            // If this is the same day, get the date and the start
+            // and end times.
+            if ($date['duration'] < '1439') {
+              $start_date = date('l, F j, Y g:i A', $date['value']);
+              $end_date = date('g:i A', $date['end_value']);
+            } // This is not the day, get the start and end date with time.
+            else {
+              $start_date = date('l, F j, Y g:i A', $date['value']);
+              $end_date = date('l, F j, Y g:i A', $date['end_value']);
+            }
 
-          // This is not the day, get the start and end date with time.
-          else {
-            $start_date = date('l, F j, Y g:i A', $date['value']);
-            $end_date = date('l, F j, Y g:i A', $date['end_value']);
+            // Add the start and end date with timezone.
+            $return_dates[] = $start_date . ' - ' . $end_date . ' ' . date('T', $date['end_value']);
           }
-
-          // Add the start and end date with timezone.
-          $return_dates[] = $start_date . ' - ' . $end_date . ' ' . date('T', $date['end_value']);
-          // }
         }
       }
     }
-- 
GitLab