diff --git a/civicrm-ux.php b/civicrm-ux.php index cb1e8ad..ad130f2 100755 --- a/civicrm-ux.php +++ b/civicrm-ux.php @@ -9,7 +9,7 @@ * Plugin Name: WP CiviCRM UX * Plugin URI: https://github.com/agileware/wp-civicrm-ux * Description: A better user experience for integrating WordPress and CiviCRM - * Version: 1.3.0 + * Version: 1.3.1 * Author: Agileware * Author URI: https://agileware.com.au/ * License: GPL-2.0+ @@ -24,7 +24,7 @@ * Start at version 1.0.0 and use SemVer - https://semver.org * Rename this for your plugin and update it as you release new versions. */ -define( 'CIVICRM_UXVERSION', '1.3.0' ); +define( 'CIVICRM_UXVERSION', '1.3.1' ); // If this file is called directly, abort. if ( ! defined( 'WPINC' ) ) { diff --git a/shortcodes/event/event-listing.php b/shortcodes/event/event-listing.php index 8ef7983..018f2de 100644 --- a/shortcodes/event/event-listing.php +++ b/shortcodes/event/event-listing.php @@ -71,19 +71,28 @@ public function shortcode_callback($atts = [], $content = NULL, $tag = '') { private function get_event_item_html(array $event) { $config = CRM_Core_Config::singleton(); - $start_date = new DateTime($event['start_date']); - $end_date = new DateTime($event['end_date']); - $start_date_text = CRM_Utils_Date::customFormat($event['start_date'], $config->dateformatDatetime); + $local_tz = new DateTimeZone(CRM_Core_Config::singleton()->userSystem->getTimeZoneString()); + + $start_date = new DateTime($event['start_date'], $local_tz); + $end_date = new DateTime($event['end_date'], $local_tz); + + if(!empty($event['event_tz'])) { + $time_zone = new DateTimeZone($event['event_tz']); + $start_date->setTimeZone($time_zone); + $end_date->setTimeZone($time_zone); + } + + $start_date_text = CRM_Utils_Date::customFormat($start_date->format('Y-m-d H:i:s'), $config->dateformatDatetime); $end_date_text = ''; // Check if end date has been set - if (!empty($event['end_date'])) { + if (!empty($event['end_date']) && ($start_date != $end_date)) { // Check if end date is the same day as start date if ($end_date->format('j F Y') == $start_date->format('j F Y')) { - $end_date_text = ' to ' . CRM_Utils_Date::customFormat($event['end_date'], $config->dateformatTime); + $end_date_text = ' to ' . CRM_Utils_Date::customFormat($end_date->format('Y-m-d H:i:s'), $config->dateformatTime); } else { - $end_date_text = ' to ' . CRM_Utils_Date::customFormat($event['end_date'], $config->dateformatDatetime); + $end_date_text = ' to ' . CRM_Utils_Date::customFormat($end_date->format('Y-m-d H:i:s'), $config->dateformatDatetime); } $end_date_text .= (!empty($event['event_tz']) ? ' ' . $event['event_tz'] : '');