Projects/nettsiden-old
Projects
/
nettsiden-old
Archived
8
0
Fork 0

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
1 changed files with 19 additions and 0 deletions

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 */