Fixed dates range for 0 week days
authorArtem Andreev <andreev.artem@gmail.com>
Fri, 14 Oct 2011 11:37:24 +0000 (15:37 +0400)
committerArtem Andreev <andreev.artem@gmail.com>
Fri, 14 Oct 2011 11:37:24 +0000 (15:37 +0400)
locallib.php

index e031a81..5aab43d 100644 (file)
@@ -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);