diff --git a/src/Service/UWService.php b/src/Service/UWService.php index 1fc359f15d161234bf8533611eac1f1ca4df80b9..1fcc13db495e41497dc0312a0ac129f754e302ca 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -243,18 +243,48 @@ class UWService implements UWServiceInterface { break; case 'date': - if ($node->getType() !== 'events') { + + // If this is not and event, just get the date. + if ($node->getType() !== 'uw_ct_event') { $node_data['date'] = date('l, F j, Y', strtotime($node->$data->value)); } else { // Get all the dates. - // @todo figure out what date to display for events. $dates = $node->$data->getValue(); - $node_data['date'] = date('l, F j, Y', $dates[0]['value']); + // Step through each of the dates and get + // out correct values. + foreach ($dates as $date) { + + // The all day case, duration is always 1439. + if ($date['duration'] == '1439' && $date['end_value'] > strtotime("now")) { + $node_data['date'][] = date('l, F j, Y', $date['value']) . ' (all day)'; + } + else { + + // If the date is upcoming, meaning greater than right now. + if ($date['end_value'] > strtotime("now")) { + + // 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']); + } + + // Add the start and end date with timezone. + $node_data['date'][] = $start_date . ' - ' . $end_date . ' ' . date('T', $date['end_value']); + } + } + } } - break; case 'sources':