コード例 #1
0
ファイル: DateRange.php プロジェクト: Konafets/seminars
 /**
  * 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);
 }
コード例 #2
0
ファイル: TimeRange.php プロジェクト: Konafets/seminars
 /**
  * Checks whether there's an end time set (end time !== 00:00).
  * If there's no end date/time set, the result will be FALSE.
  *
  * @return bool TRUE if we have an end time, FALSE otherwise
  */
 protected function hasEndTime(tx_seminars_Model_AbstractTimeSpan $timeSpan)
 {
     if (!$timeSpan->hasEndDate()) {
         return FALSE;
     }
     return $this->getTimeFromTimestamp($timeSpan->getEndDateAsUnixTimeStamp()) !== '00:00';
 }