Skip to content
Snippets Groups Projects
Commit 14e17ba0 authored by Eric Bremner's avatar Eric Bremner Committed by Igor Biki
Browse files

ISTWCMS-4917: adding common function to get a date format

parent 6ddd1289
No related branches found
No related tags found
1 merge request!118Feature/istwcms 4917 ebremner upcoming dates
...@@ -639,33 +639,41 @@ class UWService implements UWServiceInterface { ...@@ -639,33 +639,41 @@ class UWService implements UWServiceInterface {
// Ensure that the dates are greater than timestamp // Ensure that the dates are greater than timestamp
// that we generated above. // that we generated above.
if ($date['end_value'] > $check_date) { if ($date['end_value'] > $check_date) {
$return_dates[] = $this->UwGetDate($date, 'event');
}
}
}
// The all day case, duration is always 1439. return $return_dates;
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. * {@inheritDoc}
if ($date['duration'] < '1439') { */
$start_date = date('l, F j, Y g:i A', $date['value']); public function uwGetDate(array $date, string $type): string {
$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. // The all day case, duration is always 1439.
$return_dates[] = $start_date . ' - ' . $end_date . ' ' . date('T', $date['end_value']); if ($date['duration'] == '1439') {
} $return_date = 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']);
} }
// Add the start and end date with timezone.
$return_date = $start_date . ' - ' . $end_date . ' ' . date('T', $date['end_value']);
} }
return $return_dates; return $return_date;
} }
/** /**
......
...@@ -93,6 +93,19 @@ interface UWServiceInterface { ...@@ -93,6 +93,19 @@ interface UWServiceInterface {
*/ */
public function uwGetDates(Node $node, string $field_name): array; public function uwGetDates(Node $node, string $field_name): array;
/**
* Get a date in the proper format.
*
* @param array $date
* An array of date info.
* @param string $type
* The type of date.
*
* @return string
* A converted date to a string.
*/
public function uwGetDate(array $date, string $type): string;
/** /**
* Gets image from node. * Gets image from node.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment