Skip to content

Commit

Permalink
WPCIVIUX-94: Actually set time zone for event listing output.
Browse files Browse the repository at this point in the history
  • Loading branch information
agileware-fj committed May 26, 2021
1 parent 9e930c0 commit 10ae0f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions civicrm-ux.php
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand All @@ -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' ) ) {
Expand Down
21 changes: 15 additions & 6 deletions shortcodes/event/event-listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] : '');
Expand Down

0 comments on commit 10ae0f8

Please sign in to comment.