/** * Gets the date. * Returns a localized string "will be announced" if there's no date set. * * Returns just one day if the timespan takes place on only one day. * Returns a date range if the timespan takes several days. * * @param tx_seminars_Model_AbstractTimeSpan $timeSpan the timespan to get the date for * @param string $dash the character or HTML entity used to separate start date and end date * * @return string the timespan date */ public function render(tx_seminars_Model_AbstractTimeSpan $timeSpan, $dash = '–') { if (!$timeSpan->hasBeginDate()) { return $this->translator->translate('message_willBeAnnounced'); } $beginDate = $timeSpan->getBeginDateAsUnixTimeStamp(); $endDate = $timeSpan->getEndDateAsUnixTimeStamp(); // Is the timespan open-ended or does it span one day only? if (!$timeSpan->hasEndDate() || $this->isSameDay($beginDate, $endDate)) { return $this->getAsDateFormatYmd($beginDate); } if ($this->configuration->getAsBoolean('abbreviateDateRanges')) { $formattedBeginDate = $this->getAsAbbreviatedDateRange($beginDate, $endDate, $dash); } else { $formattedBeginDate = $this->getAsDateFormatYmd($beginDate); } return $formattedBeginDate . $dash . $this->getAsDateFormatYmd($endDate); }
/** * Returns the formatted countdown message using $countdownValue and $countdownText. * * @param int $countdownValue * @param string $countdownText * * @return string the formatted countdown message */ protected function getFormattedMessage($countdownValue, $countdownText) { return sprintf($this->translator->translate('message_countdown'), $countdownValue, $countdownText); }
/** * @test */ public function renderWithBeginDateInTwoDaysReturnsTwoDaysLeft() { $offset = 2 * 86400; self::assertSame(sprintf($this->translator->translate('message_countdown'), $offset, $this->translator->translate('countdown_days_plural')), $this->fixture->render($GLOBALS['SIM_ACCESS_TIME'] + $offset)); }
/** * @test */ public function renderWithTimeSpanWithNoDatesReturnMessageWillBeAnnounced() { $timeSpan = new tx_seminars_tests_fixtures_TestingTimeSpan(); $timeSpan->setData(array()); self::assertSame($this->translator->translate('message_willBeAnnounced'), $this->fixture->render($timeSpan)); }