Skip to content
Snippets Groups Projects
Commit 136d23c5 authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

start counting weeks from the current week of `vorles_beginn`, fixes #2608

Closes #2608

Merge request studip/studip!2151
parent f352a7d9
No related branches found
No related tags found
No related merge requests found
...@@ -412,20 +412,7 @@ class Semester extends SimpleORMap ...@@ -412,20 +412,7 @@ class Semester extends SimpleORMap
*/ */
public function getCorrectedLectureBegin() public function getCorrectedLectureBegin()
{ {
$dow = (int)date('w', $this->vorles_beginn); return strtotime('this week monday', $this->vorles_beginn);
// Date is already on a monday
if ($dow === 1) {
return $this->vorles_beginn;
}
// Saturday or sunday: return next monday
if ($dow === 0 || $dow === 6) {
return strtotime('next monday', $this->vorles_beginn);
}
// Otherwise return last monday
return strtotime('last monday', $this->vorles_beginn);
} }
......
...@@ -550,18 +550,7 @@ class MetaDate ...@@ -550,18 +550,7 @@ class MetaDate
$passed = true; $passed = true;
} }
if ($passed && ($sem_end >= $val['vorles_ende']) && ($startAfterTimeStamp <= $val['ende'])) { if ($passed && ($sem_end >= $val['vorles_ende']) && ($startAfterTimeStamp <= $val['ende'])) {
// correction calculation, if the semester does not start on monday $ret[$val['semester_id']] = $this->getVirtualSingleDatesForSemester($metadate_id, $val['vorles_beginn'], $val['vorles_ende'], $startAfterTimeStamp);
$dow = (int)date('w', $val['vorles_beginn']);
if ($dow === 0) {
$corr = 1;
} elseif ($dow <= 5) {
$corr = ($dow - 1) * -1;
} elseif ($dow == 6) {
$corr = 2;
} else {
$corr = 0;
}
$ret[$val['semester_id']] = $this->getVirtualSingleDatesForSemester($metadate_id, $val['vorles_beginn'], $val['vorles_ende'], $startAfterTimeStamp, $corr);
} }
} }
...@@ -575,10 +564,10 @@ class MetaDate ...@@ -575,10 +564,10 @@ class MetaDate
* @param int timestamp of semester start * @param int timestamp of semester start
* @param int timestamp of semester end * @param int timestamp of semester end
* @param int alternative timestamp to start from * @param int alternative timestamp to start from
* @param int correction calculation, if the semester does not start on monday (number of days?) * @param int correction calculation (obsolete)
* @return array returns an array of two arrays of SingleDate objects: 'dates' => all new and surviving dates, 'dates_to_delete' => obsolete dates * @return array returns an array of two arrays of SingleDate objects: 'dates' => all new and surviving dates, 'dates_to_delete' => obsolete dates
*/ */
function getVirtualSingleDatesForSemester($metadate_id, $sem_begin, $sem_end, $startAfterTimeStamp, $corr) function getVirtualSingleDatesForSemester($metadate_id, $sem_begin, $sem_end, $startAfterTimeStamp, $corr = 0)
{ {
$dates = []; $dates = [];
$dates_to_delete = []; $dates_to_delete = [];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment