Browse Source

Tried to fix bug with dates and calendar (http://github.com/andreev-artem/mod_attforblock/issues#issue/1)

MOODLE_23_STABLE
Artem Andreev 15 years ago
parent
commit
7d93b29ecc
  1. 27
      locallib.php

27
locallib.php

@ -339,31 +339,36 @@ function print_filter_controls($url, $id, $sort=NULL, $printgroupselector=false)
global $current, $view, $cm; global $current, $view, $cm;
list(,,,$mday, $wday, $month, $year) = array_values(usergetdate($current)); $date = usergetdate($current);
$mday = $date['mday'];
$wday = $date['wday'];
$mon = $date['mon'];
$year = $date['year'];
$currentdatecontrols = ''; $currentdatecontrols = '';
switch ($view) { switch ($view) {
case 'days': case 'days':
$format = get_string('strftimedm', 'attforblock'); $format = get_string('strftimedm', 'attforblock');
$startdate = make_timestamp($year, $month, $mday); $startdate = make_timestamp($year, $mon, $mday);
$enddate = make_timestamp($year, $month, $mday + 1); $enddate = make_timestamp($year, $mon, $mday + 1);
$prevcur = make_timestamp($year, $month, $mday - 1); $prevcur = make_timestamp($year, $mon, $mday - 1);
$nextcur = make_timestamp($year, $month, $mday + 1); $nextcur = make_timestamp($year, $mon, $mday + 1);
$curdatetxt = userdate($startdate, $format); $curdatetxt = userdate($startdate, $format);
break; break;
case 'weeks': case 'weeks':
$format = get_string('strftimedm', 'attforblock'); $format = get_string('strftimedm', 'attforblock');
$startdate = make_timestamp($year, $month, $mday - $wday + 1); $startdate = make_timestamp($year, $mon, $mday - $wday + 1);
$enddate = make_timestamp($year, $month, $mday + 7 - $wday); $enddate = make_timestamp($year, $mon, $mday + 7 - $wday);
$prevcur = $startdate - WEEKSECS; $prevcur = $startdate - WEEKSECS;
$nextcur = $startdate + WEEKSECS; $nextcur = $startdate + WEEKSECS;
$curdatetxt = userdate($startdate, $format)." - ".userdate($enddate, $format); $curdatetxt = userdate($startdate, $format)." - ".userdate($enddate, $format);
break; break;
case 'months': case 'months':
$format = '%B'; $format = '%B';
$startdate = make_timestamp($year, $month); $startdate = make_timestamp($year, $mon);
$enddate = make_timestamp($year, $month + 1); $enddate = make_timestamp($year, $mon + 1);
$prevcur = make_timestamp($year, $month - 1); $prevcur = make_timestamp($year, $mon - 1);
$nextcur = make_timestamp($year, $month + 1); $nextcur = make_timestamp($year, $mon + 1);
$curdatetxt = userdate($startdate, $format); $curdatetxt = userdate($startdate, $format);
break; break;
case 'alltaken': case 'alltaken':

Loading…
Cancel
Save