From 0f7ceac84fcab8c53f586684889e9b4b090107c0 Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Fri, 14 Oct 2011 15:37:24 +0400 Subject: [PATCH] Fixed dates range for 0 week days --- locallib.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/locallib.php b/locallib.php index e031a81..5aab43d 100644 --- a/locallib.php +++ b/locallib.php @@ -183,9 +183,12 @@ class att_page_with_filter_controls { } public function init_start_end_date() { + global $CFG; + $date = usergetdate($this->curdate); $mday = $date['mday']; - $wday = $date['wday']; + $wday = $date['wday'] - $CFG->calendar_startwday; + if ($wday < 0) $wday += 7; $mon = $date['mon']; $year = $date['year']; @@ -195,8 +198,8 @@ class att_page_with_filter_controls { $this->enddate = make_timestamp($year, $mon, $mday + 1); break; case VIEW_WEEKS: - $this->startdate = make_timestamp($year, $mon, $mday - $wday + 1); - $this->enddate = make_timestamp($year, $mon, $mday + 7 - $wday + 1) - 1; + $this->startdate = make_timestamp($year, $mon, $mday - $wday); + $this->enddate = make_timestamp($year, $mon, $mday + 7 - $wday) - 1; break; case VIEW_MONTHS: $this->startdate = make_timestamp($year, $mon);