diff --git a/src/pvv/side/agenda.php b/src/pvv/side/agenda.php index b37e00b..607c0e5 100644 --- a/src/pvv/side/agenda.php +++ b/src/pvv/side/agenda.php @@ -12,8 +12,9 @@ class Agenda { const TODAY = 0; const TOMORROW = 1; const THIS_WEEK = 2; - const THIS_MONTH = 3; - const NEXT_MONTH = 4; + const NEXT_WEEK = 3; + const THIS_MONTH = 4; + const NEXT_MONTH = 5; public function __construct($activities) { $this->activities = $activities; @@ -47,7 +48,7 @@ class Agenda { } public function getNextDays() { - $result = [[], [], [], [], []]; + $result = [[], [], [], [], [], []]; $events = $this->getEventsBetween( (new DateTimeImmutable)->sub(new DateInterval('PT1H')), (new DateTimeImmutable)->add(new DateInterval('P1M')) @@ -57,6 +58,7 @@ class Agenda { if (self::isToday($event->getStart())) $index = self::TODAY; elseif (self::isTomorrow($event->getStart())) $index = self::TOMORROW; elseif (self::isThisWeek($event->getStart())) $index = self::THIS_WEEK; + elseif (self::isNextWeek($event->getStart())) $index = self::NEXT_WEEK; elseif (self::isThisMonth($event->getStart())) $index = self::THIS_MONTH; $result[$index][] = $event; } @@ -75,6 +77,10 @@ class Agenda { return $date->format('WY') == date('WY'); } + public static function isNextWeek(DateTimeImmutable $date) { + return $date->sub(new DateInterval('P7D'))->format('WY') == date('WY'); + } + public static function isThisMonth(DateTimeImmutable $date) { return $date->format('mY') == date('mY'); } diff --git a/www/index.php b/www/index.php index 1fb5d2f..24acd2a 100644 --- a/www/index.php +++ b/www/index.php @@ -2,6 +2,7 @@ require '../src/_autoload.php'; date_default_timezone_set('Europe/Oslo'); require __DIR__ . '/../sql_config.php'; +setlocale(LC_ALL, 'no_NO'); $pdo = new \PDO($dbDsn, $dbUser, $dbPass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $agenda = new \pvv\side\Agenda([ @@ -48,17 +49,25 @@ $agenda = new \pvv\side\Agenda([

Kommende arrangement