diff --git a/calendar/lib.php b/calendar/lib.php
index c1455c681c5..93c04f3a491 100644
--- a/calendar/lib.php
+++ b/calendar/lib.php
@@ -62,6 +62,8 @@ define ('CALENDAR_URL', $CFG->wwwroot.'/calendar/');
define ('CALENDAR_TF_24', '%H:%M');
define ('CALENDAR_TF_12', '%I:%M %p');
+$CALENDARDAYS = array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');
+
// Initialize the session variables here to be sure
calendar_session_vars();
@@ -536,7 +538,7 @@ function calendar_sql_where($tstart, $tend, $users, $groups, $courses, $withdura
}
function calendar_top_controls($type, $data) {
- global $CFG;
+ global $CFG, $CALENDARDAYS;
$content = '';
if(!isset($data['d'])) {
$data['d'] = 1;
@@ -595,11 +597,10 @@ function calendar_top_controls($type, $data) {
break;
case 'day':
$data['d'] = $date['mday']; // Just for convenience
- $dayname = calendar_wday_name($date['weekday']);
$prevdate = usergetdate(make_timestamp($data['y'], $data['m'], $data['d'] - 1));
$nextdate = usergetdate(make_timestamp($data['y'], $data['m'], $data['d'] + 1));
- $prevname = $prevdate['weekday'];
- $nextname = $nextdate['weekday'];
+ $prevname = calendar_wday_name($CALENDARDAYS[$prevdate['wday']]);
+ $nextname = calendar_wday_name($CALENDARDAYS[$nextdate['wday']]);
$content .= '
';
$content .= '| << '.$prevname." | \n";
diff --git a/calendar/view.php b/calendar/view.php
index 9841084281c..8281b07adf5 100644
--- a/calendar/view.php
+++ b/calendar/view.php
@@ -261,7 +261,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
}
function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
- global $CFG, $SESSION, $USER;
+ global $CFG, $SESSION, $USER, $CALENDARDAYS;
global $day, $mon, $yr;
$getvars = 'from=month&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering
@@ -343,11 +343,10 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
echo ''; // Begin table. First row: day names
// Print out the names of the weekdays
- $days = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
for($i = $display->minwday; $i <= $display->maxwday; ++$i) {
// This uses the % operator to get the correct weekday no matter what shift we have
// applied to the $display->minwday : $display->maxwday range from the default 0 : 6
- echo '| '.get_string($days[$i % 7], 'calendar').' | ';
+ echo ''.get_string($CALENDARDAYS[$i % 7], 'calendar').' | ';
}
echo '
'; // End of day names; prepare for day numbers