diff --git a/src/Service/UWService.php b/src/Service/UWService.php index f8216a8f6040707ab3cc87a68bd49e0585ff526f..f109234ab3733cc46682daffab174ec96d7ba85b 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -607,13 +607,27 @@ class UWService implements UWServiceInterface { // Get all the dates. $dates = $node->$field_name->getValue(); + // Get the date query parameter. + $date_parameter = \Drupal::request()->query->get('date'); + + // If there is a date query parameter, convert + // to timestamp so we can compare against dates + // in the event. If there is no parameter, set + // the timestamp todays date. + if ($date_parameter) { + $check_date = strtotime($date_parameter['value']); + } + else { + $check_date = strtotime("now"); + } + // Step through each of the dates and get // out correct values. foreach ($dates as $date) { - // Ensure that the dates are greater than now, before - // adding it to the dates array. - if ($date['end_value'] > strtotime("now")) { + // Ensure that the dates are greater than timestamp + // that we generated above. + if ($date['end_value'] > $check_date) { // The all day case, duration is always 1439. if ($date['duration'] == '1439') {