mirror of
https://github.com/moodle/moodle.git
synced 2025-03-20 15:40:17 +01:00
Merge branch 'MDL-75928-401' of https://github.com/lameze/moodle into MOODLE_401_STABLE
This commit is contained in:
commit
ff0b12cfd3
@ -406,14 +406,25 @@ class format_weeks extends core_courseformat\base {
|
||||
} else {
|
||||
$sectionnum = $section;
|
||||
}
|
||||
$oneweekseconds = 604800;
|
||||
// Hack alert. We add 2 hours to avoid possible DST problems. (e.g. we go into daylight
|
||||
// savings and the date changes.
|
||||
$startdate = $startdate + 7200;
|
||||
|
||||
// Create a DateTime object for the start date.
|
||||
$startdateobj = new DateTime("@$startdate");
|
||||
|
||||
// Calculate the interval for one week.
|
||||
$oneweekinterval = new DateInterval('P7D');
|
||||
|
||||
// Calculate the interval for the specified number of sections.
|
||||
for ($i = 1; $i < $sectionnum; $i++) {
|
||||
$startdateobj->add($oneweekinterval);
|
||||
}
|
||||
|
||||
// Calculate the end date.
|
||||
$enddateobj = clone $startdateobj;
|
||||
$enddateobj->add($oneweekinterval);
|
||||
|
||||
$dates = new stdClass();
|
||||
$dates->start = $startdate + ($oneweekseconds * ($sectionnum - 1));
|
||||
$dates->end = $dates->start + $oneweekseconds;
|
||||
$dates->start = $startdateobj->getTimestamp();
|
||||
$dates->end = $enddateobj->getTimestamp();
|
||||
|
||||
return $dates;
|
||||
}
|
||||
|
@ -219,8 +219,8 @@ class format_weeks_test extends \advanced_testcase {
|
||||
$courseform = new \testable_course_edit_form(null, $args);
|
||||
$courseform->definition_after_data();
|
||||
|
||||
// format_weeks::get_section_dates is adding 2h to avoid DST problems, we need to replicate it here.
|
||||
$enddate = $params['startdate'] + (WEEKSECS * $params['numsections']) + 7200;
|
||||
// Calculate the expected end date.
|
||||
$enddate = $params['startdate'] + (WEEKSECS * $params['numsections']);
|
||||
|
||||
$weeksformat = course_get_format($course->id);
|
||||
$this->assertEquals($enddate, $weeksformat->get_default_course_enddate($courseform->get_quick_form()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user