From ac675acf508eaa3662ba7fa02fd3cbfd25ddf53f Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Sat, 14 May 2016 22:02:33 +0200 Subject: [PATCH] Fixed ColledgeDeFrance timezone and a small time parsing issue --- bridges/CollegeDeFranceBridge.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bridges/CollegeDeFranceBridge.php b/bridges/CollegeDeFranceBridge.php index f7a086e6..da77a461 100644 --- a/bridges/CollegeDeFranceBridge.php +++ b/bridges/CollegeDeFranceBridge.php @@ -39,9 +39,14 @@ class CollegeDeFranceBridge extends BridgeAbstract{ $item->title = $element->find('.title', 0)->plaintext; // Most relative URLs contains an hour in addition to the date, so let's use it // - // But unfortunately some don't + // + // Sometimes there's an __1, perhaps it signifies an update "/site/patrick-boucheron/seminar-2016-05-03-18h00__1.htm" + // + // But unfortunately some don't have any hours info // - $d = DateTime::createFromFormat('!Y-m-d-H\hi', substr($element->href, -20, -4)) ?: DateTime::createFromFormat('!H m Y', str_replace(array_values($months), array_keys($months), $element->find('.date', 0)->innertext)); + $timezone = new DateTimeZone('Europe/Paris'); + // strpos($element->href, '201') will break in 2020 but it'll probably break prior to then due to site changes anyway + $d = DateTime::createFromFormat('!Y-m-d-H\hi', substr($element->href, strpos($element->href, '201'), 16), $timezone) or DateTime::createFromFormat('!H m Y', trim(str_replace(array_values($months), array_keys($months), $element->find('.date', 0)->plaintext)), $timezone); $item->timestamp = $d->format('U'); $item->content = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext; $item->uri = 'http://www.college-de-france.fr' . $element->href; @@ -58,6 +63,6 @@ class CollegeDeFranceBridge extends BridgeAbstract{ } public function getCacheDuration(){ - return 3600*3; // 3 hour + return 3600*3; // 3 hours } }