MDL-81195 core_course: allow for daylight savings
In timezones where daylight savings time is used, courses that start on a Monday at 00:00 would display the week headings incorrectly during the change forward. When the time changes backwards, courses that have a start time of Sunday at 23:00 also have a mislabeled week. This attempts to use the DateTime() library, along with the user's local timezone setting to display the correct day, rather than just subtracting 86400.
This commit is contained in:
@@ -93,8 +93,12 @@ class format_weeks extends core_courseformat\base {
|
||||
} else {
|
||||
$dates = $this->get_section_dates($section);
|
||||
|
||||
// We subtract 24 hours for display purposes.
|
||||
$dates->end = ($dates->end - 86400);
|
||||
// Find the prior day for display purposes.
|
||||
$enddate = new DateTime();
|
||||
$enddate->setTimezone(core_date::get_user_timezone_object());
|
||||
$enddate->setTimestamp(intval($dates->end));
|
||||
$enddate->modify('-1 day');
|
||||
$dates->end = $enddate->getTimestamp();
|
||||
|
||||
$dateformat = get_string('strftimedateshort');
|
||||
$weekday = userdate($dates->start, $dateformat);
|
||||
|
||||
Reference in New Issue
Block a user