nettsiden/src/pvv/side/event.php

53 lines
1.2 KiB
PHP
Raw Normal View History

<?php //declare(strict_types=1);
namespace pvv\side;
2016-08-17 23:53:35 +02:00
use \DateTimeImmutable;
2016-08-26 22:47:20 +02:00
use \DateInterval;
2016-08-26 17:04:20 +02:00
abstract class Event {
2016-08-17 23:53:35 +02:00
private $start;
public function __construct(DateTimeImmutable $start) {
$this->start = $start;
}
public function getStart() {
return $this->start;
}
2016-08-26 22:16:54 +02:00
public function getRelativeDate() {
if (Agenda::isToday($this->getStart())) {
return 'i dag';
}
if (Agenda::isTomorrow($this->getStart())) {
return 'i morgen';
}
if (Agenda::isThisWeek($this->getStart()) || $this->getStart()->sub(new DateInterval('P4D'))->getTimestamp() < time()) {
return strftime('%A', $this->getStart()->getTimestamp());
}
if (Agenda::isNextWeek($this->getStart())) {
return 'neste uke';
}
if (Agenda::isThisMonth($this->getStart())) {
return 'denne måneden';
}
2016-08-26 23:17:59 +02:00
return trim(strftime('%e. %B', $this->getStart()->getTimestamp()));
2016-08-26 22:16:54 +02:00
}
2016-08-17 23:53:35 +02:00
public abstract function getStop(); /* : DateTimeImmutable */
public abstract function getName();
public abstract function getLocation();
public abstract function getOrganiser();
2016-08-26 17:22:11 +02:00
public abstract function getURL(); /* : string */
public abstract function getImageURL(); /* : string */
public abstract function getDescription(); /* : string */
}