From caf9f2a0163ce88cd3913fc6242a738236ae97f5 Mon Sep 17 00:00:00 2001 From: Sebastian Marcet Date: Sun, 2 Nov 2014 03:05:40 -0300 Subject: [PATCH] [smarcet] - #7691 * fix for borken dates on presentations. Conflicts: openstack/code/Presentation.php --- openstack/code/Presentation.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/openstack/code/Presentation.php b/openstack/code/Presentation.php index e5ccd83..400cec8 100644 --- a/openstack/code/Presentation.php +++ b/openstack/code/Presentation.php @@ -1,5 +1,4 @@ StartTime); - return $Date->format('l h:i a'); + $start_time = trim(str_replace("p.m.", "", trim($this->StartTime))); + $date = DateTime::createFromFormat('d/m/y H:i', $start_time); + if (!$date) + $date = DateTime::createFromFormat('Y-m-d H:i:s', $start_time); + if ($date) + return $date->format('l h:i a'); + return 'N/A'; } function PresentationDay() { - $Date = new DateTime($this->StartTime); - return $Date->format('M d'); + $start_time = trim(str_replace("p.m.", "", trim($this->StartTime))); + $date = DateTime::createFromFormat('d/m/y H:i', $start_time); + if (!$date) + $date = DateTime::createFromFormat('Y-m-d H:i:s', $start_time); + if ($date) + return $date->format('M d'); + return 'N/A'; } - function onBeforeWrite() { parent::onBeforeWrite(); @@ -214,4 +223,3 @@ class Presentation extends DataObject } } } -