Add getRelativeDate() in Event.

This commit is contained in:
Yorin Anne De Jong 2016-08-26 22:16:54 +02:00
parent 6d1bf247c5
commit 4cd3f90459

View File

@ -15,6 +15,25 @@ abstract class Event {
return $this->start;
}
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';
}
return strftime('%e. %b', $this->getStart()->getTimestamp());
}
public abstract function getStop(); /* : DateTimeImmutable */
public abstract function getURL(); /* : string */