diff --git a/library/ZendAfi/View/Helper/TagArticleEvent.php b/library/ZendAfi/View/Helper/TagArticleEvent.php index 7e8aa0833107ac4196327857d435e41dbb8e622b..7ec3735c19c16bf052d75d56cf0675d13f1c82a5 100644 --- a/library/ZendAfi/View/Helper/TagArticleEvent.php +++ b/library/ZendAfi/View/Helper/TagArticleEvent.php @@ -24,12 +24,12 @@ class ZendAfi_View_Helper_TagArticleEvent extends Zend_View_Helper_HtmlElement { * @return string */ public function tagArticleEvent($article) { - if (!$time_start = strtotime($article->getEventsDebut())) + if (!$time_start = strtotime(substr($article->getEventsDebut(), 0, 10))) return ''; - if (!$time_end = strtotime($article->getEventsFin())) + if (!$time_end = strtotime(substr($article->getEventsFin(), 0, 10))) $time_end = $time_start; - + $month_start = strftime('%B', $time_start); $month_end = strftime('%B', $time_end); if ($month_start == $month_end) diff --git a/tests/library/ZendAfi/View/Helper/TagArticleEventTest.php b/tests/library/ZendAfi/View/Helper/TagArticleEventTest.php index 1392a59927f5423fceafc2bb5ef6a00daa21b265..1f8d92e8ec5c2cf4539be6f53ca0f227bdf24c00 100644 --- a/tests/library/ZendAfi/View/Helper/TagArticleEventTest.php +++ b/tests/library/ZendAfi/View/Helper/TagArticleEventTest.php @@ -63,6 +63,16 @@ class TagArticleEventTest extends ViewHelperTestCase { } + /** @test */ + function withEventDebutAndFinSameDayShouldAnswerLe05() { + $this->article + ->setEventsDebut('2011-09-05 08:00') + ->setEventsFin('2011-09-05 10:00'); + $this->assertTagContains('Le 05 septembre 2011'); + } + + + protected function assertTagContains($expected) { $this->assertEquals(sprintf('<span class="calendar_event_date">%s</span>', $expected), $this->_helper->tagArticleEvent($this->article));