2016-08-15 18:48:02 +02:00
|
|
|
<?php //declare(strict_types=1);
|
2016-08-15 18:47:07 +02:00
|
|
|
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-15 18:47:07 +02:00
|
|
|
|
2016-08-26 17:04:20 +02:00
|
|
|
abstract class Event {
|
2016-08-15 18:47:07 +02:00
|
|
|
|
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 */
|
2016-08-15 18:47:07 +02:00
|
|
|
|
2016-08-26 23:16:51 +02:00
|
|
|
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 */
|
|
|
|
|
2016-08-26 23:16:51 +02:00
|
|
|
public abstract function getImageURL(); /* : string */
|
|
|
|
|
|
|
|
public abstract function getDescription(); /* : string */
|
|
|
|
|
2016-08-15 18:47:07 +02:00
|
|
|
}
|