Fixes for ical feed from google icals.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 25 Jul 2017 17:58:35 +0000 (13:58 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 25 Jul 2017 17:58:35 +0000 (13:58 -0400)
Fix end date if midnight.
Fix for finding the Z but only if found at the end.

classes/icalReader.php
models/front/events/icalFeedImport.php

index 661c12f..45e07cf 100644 (file)
@@ -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);
index 279ec1f..719ddbc 100644 (file)
@@ -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 .= '<pre>$recur_data: ' . print_r( $recur_data, true ) . '</pre>';
+                }
                 $this->wpdb->insert(
                     GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'recurrences',
                     $recur_data,