From b24191f9f93f3707d4d41448824b611bedbc8d4c Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Sat, 10 Oct 2015 00:11:54 +0200 Subject: [PATCH 1/2] convert activity stream RFC3339 dates to mysql datetime format when saving remote event dates to db --- plugins/Event/EventPlugin.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 4e9d153b16..1cd574086a 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -157,6 +157,14 @@ class EventPlugin extends MicroAppPlugin throw new Exception(_m('No end date for event.')); } + // dates are saved as UTC in database + $start_time = new DateTime($dtstart->item(0)->nodeValue); + $start_time->setTimezone(new DateTimeZone('UTC')); + $start_time = $start_time->format('Y-m-d H:i:s'); + $end_time = new DateTime($dtend->item(0)->nodeValue); + $end_time->setTimezone(new DateTimeZone('UTC')); + $end_time = $end_time->format('Y-m-d H:i:s'); + // location is optional $location = null; $location_object = $happeningObj->element->getElementsByTagName('location'); @@ -177,8 +185,8 @@ class EventPlugin extends MicroAppPlugin case ActivityVerb::POST: // FIXME: get startTime, endTime, location and URL $notice = Happening::saveNew($actor, - $dtstart->item(0)->nodeValue, - $dtend->item(0)->nodeValue, + $start_time, + $end_time, $happeningObj->title, $location, $happeningObj->summary, From a9f879c2bab0171f8fdc395cdcd4f7f36414c781 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Sat, 10 Oct 2015 00:20:32 +0200 Subject: [PATCH 2/2] better explanation --- plugins/Event/EventPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 1cd574086a..7f2712b148 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -157,7 +157,7 @@ class EventPlugin extends MicroAppPlugin throw new Exception(_m('No end date for event.')); } - // dates are saved as UTC in database + // convert RFC3339 dates delivered in Activity Stream to MySQL DATETIME date format $start_time = new DateTime($dtstart->item(0)->nodeValue); $start_time->setTimezone(new DateTimeZone('UTC')); $start_time = $start_time->format('Y-m-d H:i:s');