From 9ac6316a8a2a1ee75b8e99d96cde2153a5cd2beb Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 25 Jul 2017 13:58:35 -0400 Subject: [PATCH] Fixes for ical feed from google icals. Fix end date if midnight. Fix for finding the Z but only if found at the end. --- classes/icalReader.php | 2 +- models/front/events/icalFeedImport.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/classes/icalReader.php b/classes/icalReader.php index 661c12f..45e07cf 100644 --- a/classes/icalReader.php +++ b/classes/icalReader.php @@ -187,7 +187,7 @@ class ICal public function iCalDateToUnixTimestamp($icalDate) { $zulu = false; - if ( strpos( $icalDate, 'Z' ) ) { + if ( strpos( $icalDate, 'Z' ) && preg_match( '%Z$%', $icalDate ) ) { $zulu = true; } $icalDate = str_replace('T', '', $icalDate); diff --git a/models/front/events/icalFeedImport.php b/models/front/events/icalFeedImport.php index 279ec1f..719ddbc 100644 --- a/models/front/events/icalFeedImport.php +++ b/models/front/events/icalFeedImport.php @@ -452,6 +452,13 @@ class GlmMembersFront_events_icalFeedImport } if ( $btime && $etime && $etime === '00:00' ) { $start_time_only = true; + // If the end time is 00:00 then take one away from the end + // date if needed. + if ( $to_date != $from_date ) { + $toDate = date_create( $to_date ); + $toDate = date_modify( $toDate, '-1 day' ); + $to_date = date_format( $toDate, 'Y-m-d' ); + } } // for the recurrences part $recur_data = array( @@ -472,6 +479,9 @@ class GlmMembersFront_events_icalFeedImport 'last_day_of_month' => $last_day_of_month, 'specific_dates' => $serialized_times ); + if ( $debug ) { + $out .= '
$recur_data: ' . print_r( $recur_data, true ) . '
'; + } $this->wpdb->insert( GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'recurrences', $recur_data, -- 2.17.1