Compare commits
8 Commits
the-format
...
main
Author | SHA1 | Date | |
---|---|---|---|
20bab54235 | |||
c3d8ce017d | |||
02cfe9feaa | |||
4d4ec78ea3 | |||
a74ea31356 | |||
0653672a17 | |||
8a1ff1a265 | |||
c1802e7cf2 |
1
.envrc
Normal file
1
.envrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
use flake
|
@ -51,7 +51,6 @@ return (new PhpCsFixer\Config())
|
|||||||
|
|
||||||
// TODO: fix these
|
// TODO: fix these
|
||||||
'psr_autoloading' => false,
|
'psr_autoloading' => false,
|
||||||
'strict_comparison' => false,
|
|
||||||
])
|
])
|
||||||
->setFinder($finder)
|
->setFinder($finder)
|
||||||
->setIndent(" ")
|
->setIndent(" ")
|
||||||
|
50
dist/pvv.sql
vendored
50
dist/pvv.sql
vendored
@ -1,50 +0,0 @@
|
|||||||
CREATE TABLE "events" (
|
|
||||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"name" TEXT,
|
|
||||||
"start" TEXT,
|
|
||||||
"stop" TEXT,
|
|
||||||
"organiser" TEXT,
|
|
||||||
"location" TEXT,
|
|
||||||
"description" TEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "projects" (
|
|
||||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"name" TEXT,
|
|
||||||
"description" TEXT,
|
|
||||||
"active" BOOLEAN
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "projectmembers" (
|
|
||||||
"projectid" INTEGER,
|
|
||||||
"name" TEXT,
|
|
||||||
"uname" TEXT,
|
|
||||||
"mail" TEXT,
|
|
||||||
"role" TEXT,
|
|
||||||
"lead" BOOLEAN DEFAULT 0,
|
|
||||||
"owner" BOOLEAN DEFAULT 0
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "users" (
|
|
||||||
"uname" TEXT,
|
|
||||||
"groups" INT DEFAULT 0
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "motd" (
|
|
||||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"title" TEXT,
|
|
||||||
"content" TEXT
|
|
||||||
);
|
|
||||||
INSERT INTO motd (title, content)
|
|
||||||
VALUES ('MOTD ./dev.sh', 'du kan endre motd i admin panelet');
|
|
||||||
|
|
||||||
CREATE TABLE "door" (
|
|
||||||
"time" INTEGER PRIMARY KEY,
|
|
||||||
"open" BOOLEAN
|
|
||||||
);
|
|
||||||
INSERT INTO door (time, open)
|
|
||||||
VALUES (0, FALSE);
|
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO users (uname, groups)
|
|
||||||
VALUES ('min_test_bruker', 1);
|
|
60
dist/pvv_mysql.sql
vendored
60
dist/pvv_mysql.sql
vendored
@ -1,47 +1,45 @@
|
|||||||
CREATE TABLE events (
|
CREATE TABLE events (
|
||||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||||
`name` TEXT,
|
`name` TEXT,
|
||||||
`start` TEXT,
|
`start` TEXT,
|
||||||
`stop` TEXT,
|
`stop` TEXT,
|
||||||
`organiser` TEXT,
|
`organiser` TEXT,
|
||||||
`location` TEXT,
|
`location` TEXT,
|
||||||
`description` TEXT
|
`description` TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE projects (
|
CREATE TABLE projects (
|
||||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||||
`name` TEXT,
|
`name` TEXT,
|
||||||
`description` TEXT,
|
`description` TEXT,
|
||||||
`active` BOOLEAN
|
`active` BOOLEAN
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE projectmembers (
|
CREATE TABLE projectmembers (
|
||||||
`projectid` INTEGER,
|
`projectid` INTEGER,
|
||||||
`name` TEXT,
|
`name` TEXT,
|
||||||
`uname` TEXT,
|
`uname` TEXT,
|
||||||
`mail` TEXT,
|
`mail` TEXT,
|
||||||
`role` TEXT,
|
`role` TEXT,
|
||||||
`lead` BOOLEAN DEFAULT 0,
|
`lead` BOOLEAN DEFAULT 0,
|
||||||
`owner` BOOLEAN DEFAULT 0
|
`owner` BOOLEAN DEFAULT 0
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE users (
|
CREATE TABLE users (`uname` TEXT, `groups` INT DEFAULT 0);
|
||||||
`uname` TEXT,
|
|
||||||
`groups` INT DEFAULT 0
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE motd (
|
CREATE TABLE motd (
|
||||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||||
`title` TEXT,
|
`title` TEXT,
|
||||||
`content` TEXT
|
`content` TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
INSERT INTO motd (title, content)
|
INSERT INTO motd (title, content)
|
||||||
VALUES ("MOTD ./dev.sh", "du kan endre motd i admin panelet");
|
VALUES ("MOTD ./dev.sh", "du kan endre motd i admin panelet");
|
||||||
*/
|
*/
|
||||||
|
CREATE TABLE door (`time` INTEGER PRIMARY KEY, `open` BOOLEAN);
|
||||||
|
|
||||||
CREATE TABLE door (
|
INSERT INTO
|
||||||
`time` INTEGER PRIMARY KEY,
|
door (time, open)
|
||||||
`open` BOOLEAN
|
VALUES
|
||||||
);
|
(0, FALSE);
|
||||||
INSERT INTO door(time, open) VALUES (0, FALSE);
|
|
||||||
|
54
dist/pvv_sqlite.sql
vendored
Normal file
54
dist/pvv_sqlite.sql
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
CREATE TABLE "events" (
|
||||||
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"name" TEXT,
|
||||||
|
"start" TEXT,
|
||||||
|
"stop" TEXT,
|
||||||
|
"organiser" TEXT,
|
||||||
|
"location" TEXT,
|
||||||
|
"description" TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "projects" (
|
||||||
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"name" TEXT,
|
||||||
|
"description" TEXT,
|
||||||
|
"active" BOOLEAN
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "projectmembers" (
|
||||||
|
"projectid" INTEGER,
|
||||||
|
"name" TEXT,
|
||||||
|
"uname" TEXT,
|
||||||
|
"mail" TEXT,
|
||||||
|
"role" TEXT,
|
||||||
|
"lead" BOOLEAN DEFAULT 0,
|
||||||
|
"owner" BOOLEAN DEFAULT 0
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "users" ("uname" TEXT, "groups" INT DEFAULT 0);
|
||||||
|
|
||||||
|
CREATE TABLE "motd" (
|
||||||
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"title" TEXT,
|
||||||
|
"content" TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO
|
||||||
|
motd (title, content)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
'MOTD ./dev.sh',
|
||||||
|
'du kan endre motd i admin panelet'
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "door" ("time" INTEGER PRIMARY KEY, "open" BOOLEAN);
|
||||||
|
|
||||||
|
INSERT INTO
|
||||||
|
door (time, open)
|
||||||
|
VALUES
|
||||||
|
(0, FALSE);
|
||||||
|
|
||||||
|
INSERT INTO
|
||||||
|
users (uname, groups)
|
||||||
|
VALUES
|
||||||
|
('min_test_bruker', 1);
|
1
dist/simplesamlphp-authsources.php
vendored
1
dist/simplesamlphp-authsources.php
vendored
@ -6,6 +6,7 @@ $config = [
|
|||||||
/* This is the name of this authentication source, and will be used to access it later. */
|
/* This is the name of this authentication source, and will be used to access it later. */
|
||||||
'default-sp' => [
|
'default-sp' => [
|
||||||
'saml:SP',
|
'saml:SP',
|
||||||
|
'entityID' => 'https://www.pvv.ntnu.no/simplesaml/',
|
||||||
'idp' => 'https://idp.pvv.ntnu.no/',
|
'idp' => 'https://idp.pvv.ntnu.no/',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -18,7 +18,7 @@ function navbar($depth, $active = null) {
|
|||||||
];
|
];
|
||||||
foreach ($menuItems as $caption => $link) {
|
foreach ($menuItems as $caption => $link) {
|
||||||
$isActive = $active === $link;
|
$isActive = $active === $link;
|
||||||
if (substr($link, 0, 4) != 'http') {
|
if (substr($link, 0, 4) !== 'http') {
|
||||||
$link = rtrim(str_repeat('../', $depth) . $link, '/') . '/';
|
$link = rtrim(str_repeat('../', $depth) . $link, '/') . '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ pkgs }:
|
{ pkgs, lib }:
|
||||||
let
|
let
|
||||||
phpEnv = pkgs.php84.buildEnv {
|
phpEnv = pkgs.php84.buildEnv {
|
||||||
extensions = { enabled, all }: enabled ++ (with all; [ iconv mbstring pdo_mysql pdo_sqlite ]);
|
extensions = { enabled, all }: enabled ++ (with all; [ iconv mbstring pdo_mysql pdo_sqlite ]);
|
||||||
@ -11,20 +11,21 @@ pkgs.mkShellNoCC {
|
|||||||
php84Packages.php-parallel-lint
|
php84Packages.php-parallel-lint
|
||||||
php84Packages.php-cs-fixer
|
php84Packages.php-cs-fixer
|
||||||
sqlite-interactive
|
sqlite-interactive
|
||||||
|
sql-formatter
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Prepare dev environment with sqlite and config files
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
alias runDev='php -S localhost:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/'
|
alias runDev='php -S localhost:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/'
|
||||||
|
|
||||||
# Prepare dev environment with sqlite and config files
|
declare -a PROJECT_ROOT="$("${lib.getExe pkgs.git}" rev-parse --show-toplevel)"
|
||||||
test -e pvv.sqlite || sqlite3 pvv.sqlite < dist/pvv.sql
|
|
||||||
test -e config.php || cp -v dist/config.local.php config.php
|
|
||||||
|
|
||||||
|
mkdir -p "$PROJECT_ROOT/www/galleri/bilder/slideshow"
|
||||||
|
test -e "$PROJECT_ROOT/pvv.sqlite" || sqlite3 "$PROJECT_ROOT/pvv.sqlite" < "$PROJECT_ROOT/dist/pvv_sqlite.sql"
|
||||||
|
test -e "$PROJECT_ROOT/config.php" || cp -v "$PROJECT_ROOT/dist/config.local.php" "$PROJECT_ROOT/config.php"
|
||||||
|
|
||||||
if [ ! -d www/galleri/bilder/slideshow ] ; then
|
if [ ! -d "$PROJECT_ROOT/vendor" ] ; then
|
||||||
mkdir -p www/galleri/bilder/slideshow
|
pushd "$PROJECT_ROOT"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d vendor ] ; then
|
|
||||||
composer install || exit $?
|
composer install || exit $?
|
||||||
|
|
||||||
cp dist/simplesamlphp-authsources.php vendor/simplesamlphp/simplesamlphp/config/authsources.php
|
cp dist/simplesamlphp-authsources.php vendor/simplesamlphp/simplesamlphp/config/authsources.php
|
||||||
@ -34,6 +35,7 @@ pkgs.mkShellNoCC {
|
|||||||
cp dist/config.local.php config.php
|
cp dist/config.local.php config.php
|
||||||
|
|
||||||
ln -s ../vendor/simplesamlphp/simplesamlphp/public/ www/simplesaml
|
ln -s ../vendor/simplesamlphp/simplesamlphp/public/ www/simplesaml
|
||||||
|
popd "$PROJECT_ROOT"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ class UserManager {
|
|||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$row = $statement->fetch();
|
$row = $statement->fetch();
|
||||||
if ($row == false) {
|
if ($row === false) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ use pvv\side\Activity;
|
|||||||
|
|
||||||
class AnimekveldActivity implements Activity {
|
class AnimekveldActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date) {
|
public function nextDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') > 20 || $date->format('H') == 19 && $date->format('i') > 30) {
|
if (intval($date->format('H')) > 20 || intval($date->format('H')) === 19 && intval($date->format('i')) > 30) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 30, 0));
|
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 30, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(19, 30, 0);
|
$date = $date->setTime(19, 30, 0);
|
||||||
if ($date->format('N') != 5) {
|
if (intval($date->format('N')) !== 5) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,11 +20,11 @@ class AnimekveldActivity implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 19 || $date->format('H') == 20 && $date->format('i') < 30) {
|
if (intval($date->format('H')) < 19 || intval($date->format('H')) === 20 && intval($date->format('i')) < 30) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 30, 0));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 30, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(19, 30, 0);
|
$date = $date->setTime(19, 30, 0);
|
||||||
if ($date->format('N') != 5) {
|
if (intval($date->format('N')) !== 5) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@ use pvv\side\Activity;
|
|||||||
|
|
||||||
class BrettspillActivity implements Activity {
|
class BrettspillActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date) {
|
public function nextDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') > 17 || $date->format('H') == 16 && $date->format('i') > 15) {
|
if (intval($date->format('H')) > 17 || intval($date->format('H')) === 16 && intval($date->format('i')) > 15) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(16, 15, 0));
|
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(16, 15, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(16, 15, 0);
|
$date = $date->setTime(16, 15, 0);
|
||||||
if ($date->format('N') != 7) {
|
if (intval($date->format('N')) !== 7) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ($date->format('W') % 2 - 1) {
|
if (intval($date->format('W')) % 2 - 1) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,14 +23,14 @@ class BrettspillActivity implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 16 || $date->format('H') == 17 && $date->format('i') < 15) {
|
if (intval($date->format('H')) < 16 || intval($date->format('H')) === 17 && intval($date->format('i')) < 15) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(16, 15, 0));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(16, 15, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(16, 15, 0);
|
$date = $date->setTime(16, 15, 0);
|
||||||
if ($date->format('N') != 7) {
|
if (intval($date->format('N')) !== 7) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ($date->format('W') % 2 - 1) {
|
if (intval($date->format('W')) % 2 - 1) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@ use pvv\side\Activity;
|
|||||||
|
|
||||||
class DriftkveldActivity implements Activity {
|
class DriftkveldActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date) {
|
public function nextDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') > 18 || $date->format('H') == 17 && $date->format('i') > 30) {
|
if (intval($date->format('H')) > 18 || intval($date->format('H')) === 17 && intval($date->format('i')) > 30) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(18, 15, 0);
|
$date = $date->setTime(18, 15, 0);
|
||||||
if ($date->format('N') != 6) {
|
if (intval($date->format('N')) !== 6) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ($date->format('W') % 2 - 1) {
|
if (intval($date->format('W')) % 2 - 1) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,14 +23,14 @@ class DriftkveldActivity implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30) {
|
if (intval($date->format('H')) < 17 || intval($date->format('H')) === 18 && intval($date->format('i')) < 30) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(18, 15, 0);
|
$date = $date->setTime(18, 15, 0);
|
||||||
if ($date->format('N') != 6) {
|
if (intval($date->format('N')) !== 6) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ($date->format('W') % 2 - 1) {
|
if (intval($date->format('W')) % 2 - 1) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@ use pvv\side\Activity;
|
|||||||
|
|
||||||
class HackekveldActivity implements Activity {
|
class HackekveldActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date) {
|
public function nextDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') > 18 || $date->format('H') == 17 && $date->format('i') > 30) {
|
if (intval($date->format('H')) > 18 || intval($date->format('H')) === 17 && intval($date->format('i')) > 30) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(16, 15, 0);
|
$date = $date->setTime(16, 15, 0);
|
||||||
if ($date->format('N') != 6) {
|
if (intval($date->format('N')) !== 6) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ($date->format('W') % 2) {
|
if (intval($date->format('W')) % 2) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,14 +23,14 @@ class HackekveldActivity implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30) {
|
if (intval($date->format('H')) < 17 || intval($date->format('H')) === 18 && intval($date->format('i')) < 30) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(18, 15, 0);
|
$date = $date->setTime(18, 15, 0);
|
||||||
if ($date->format('N') != 6) {
|
if (intval($date->format('N')) !== 6) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ($date->format('W') % 2) {
|
if (intval($date->format('W')) % 2) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@ use pvv\side\Activity;
|
|||||||
|
|
||||||
class NerdepitsaActivity implements Activity {
|
class NerdepitsaActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date) {
|
public function nextDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') > 19) {
|
if (intval($date->format('H')) > 19) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(19, 0, 0);
|
$date = $date->setTime(19, 0, 0);
|
||||||
if ($date->format('N') != 5) {
|
if (intval($date->format('N')) !== 5) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ($date->format('W') % 2) {
|
if (intval($date->format('W')) % 2) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,14 +23,14 @@ class NerdepitsaActivity implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 19) {
|
if (intval($date->format('H')) < 19) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(19, 0, 0);
|
$date = $date->setTime(19, 0, 0);
|
||||||
if ($date->format('N') != 5) {
|
if (intval($date->format('N')) !== 5) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ($date->format('W') % 2) {
|
if (intval($date->format('W')) % 2) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user