public function testConstruct() { $io = new IrregularOpening('Test', '2016-02-03', '12:15', '23:20'); $this->assertEquals('Test', $io->getName()); $this->assertEquals(new DateTime('2016-02-03 00:00:00'), $io->getDate()); $this->assertEquals(new DateTime('2016-02-03 12:15'), $io->getTimeStart()); $this->assertEquals(new DateTime('2016-02-03 23:20'), $io->getTimeEnd()); $this->assertFalse($io->isDummy()); }
/** * 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>'; }