Exemplo n.º 1
0
 /**
  * Renders an Irregular Opening Item for Overview table
  *
  * @param     IrregularOpening  $io           The Irregular Opening to show
  * @param     array             $attributes   The shortcode attributes
  */
 public static function renderIrregularOpening(IrregularOpening $io, array $attributes)
 {
     $name = $io->getName();
     $date = $io->getTimeStart()->format(Dates::getDateFormat());
     $heading = $attributes['hide_io_date'] ? $name : sprintf('%s (%s)', $name, $date);
     $now = Dates::getNow();
     $highlighted = ($attributes['highlight'] == 'period' and $io->getTimeStart() <= $now and $now <= $io->getTimeEnd()) ? $attributes['highlighted_period_class'] : null;
     echo '<span class="op-period-time irregular-opening ' . $highlighted . '">' . $heading . '</span>';
     $time_start = $io->getTimeStart()->format($attributes['time_format']);
     $time_end = $io->getTimeEnd()->format($attributes['time_format']);
     $period = sprintf('%s – %s', $time_start, $time_end);
     echo '<span class="op-period-time ' . $highlighted . ' ' . $attributes['span_period_classes'] . '">' . $period . '</span>';
 }
 public function testTimeEndNextDay()
 {
     $io = new IrregularOpening('Test', '2016-02-03', '13:00', '01:00');
     $this->assertEquals(new DateTime('2016-02-03 13:00'), $io->getTimeStart());
     $this->assertEquals(new DateTime('2016-02-04 01:00'), $io->getTimeEnd());
 }