original_string: protected function get_weeks(renderer_base $output) {
          $weeks = [];
          $alldays = $this->get_days();
  
          $daysinweek = count($this->related['type']->get_weekdays());
  
          // Calculate which day number is the first, and last day of the week.
          $firstdayofweek = $this->firstdayofweek;
  
          // The first week is special as it may have padding at the beginning.
          $day = reset($alldays);
          $firstdayno = $day['wday'];
  
          $prepadding = ($firstdayno + $daysinweek - $firstdayofweek) % $daysinweek;
          $daysinfirstweek = $daysinweek - $prepadding;
          $days = array_slice($alldays, 0, $daysinfirstweek);
          $week = new week_exporter($this->calendar, $days, $prepadding, ($daysinweek - count($days) - $prepadding), $this->related);
          $weeks[] = $week->export($output);
  
          // Now chunk up the remaining day. and turn them into weeks.
          $daychunks = array_chunk(array_slice($alldays, $daysinfirstweek), $daysinweek);
          foreach ($daychunks as $days) {
              $week = new week_exporter($this->calendar, $days, 0, ($daysinweek - count($days)), $this->related);
              $weeks[] = $week->export($output);
          }
  
          return $weeks;
      }
code: protected function get_weeks(renderer_base $output) {
          $weeks = [];
          $alldays = $this->get_days();
  
          $daysinweek = count($this->related['type']->get_weekdays());
  
          // Calculate which day number is the first, and last day of the week.
          $firstdayofweek = $this->firstdayofweek;
  
          // The first week is special as it may have padding at the beginning.
          $day = reset($alldays);
          $firstdayno = $day['wday'];
  
          $prepadding = ($firstdayno + $daysinweek - $firstdayofweek) % $daysinweek;
          $daysinfirstweek = $daysinweek - $prepadding;
          $days = array_slice($alldays, 0, $daysinfirstweek);
          $week = new week_exporter($this->calendar, $days, $prepadding, ($daysinweek - count($days) - $prepadding), $this->related);
          $weeks[] = $week->export($output);
  
          // Now chunk up the remaining day. and turn them into weeks.
          $daychunks = array_chunk(array_slice($alldays, $daysinfirstweek), $daysinweek);
          foreach ($daychunks as $days) {
              $week = new week_exporter($this->calendar, $days, 0, ($daysinweek - count($days)), $this->related);
              $weeks[] = $week->export($output);
          }
  
          return $weeks;
      }
code_tokens: protected function get_weeks ( renderer_base $ output ) { $ weeks = [ ] ; $ alldays = $ this -> get_days ( ) ; $ daysinweek = count ( $ this -> related [ 'type' ] -> get_weekdays ( ) ) ; // Calculate which day number is the first, and last day of the week. $ firstdayofweek = $ this -> firstdayofweek ; // The first week is special as it may have padding at the beginning. $ day = reset ( $ alldays ) ; $ firstdayno = $ day [ 'wday' ] ; $ prepadding = ( $ firstdayno + $ daysinweek - $ firstdayofweek ) % $ daysinweek ; $ daysinfirstweek = $ daysinweek - $ prepadding ; $ days = array_slice ( $ alldays , 0 , $ daysinfirstweek ) ; $ week = new week_exporter ( $ this -> calendar , $ days , $ prepadding , ( $ daysinweek - count ( $ days ) - $ prepadding ) , $ this -> related ) ; $ weeks [ ] = $ week -> export ( $ output ) ; // Now chunk up the remaining day. and turn them into weeks. $ daychunks = array_chunk ( array_slice ( $ alldays , $ daysinfirstweek ) , $ daysinweek ) ; foreach ( $ daychunks as $ days ) { $ week = new week_exporter ( $ this -> calendar , $ days , 0 , ( $ daysinweek - count ( $ days ) ) , $ this -> related ) ; $ weeks [ ] = $ week -> export ( $ output ) ; } return $ weeks ; }
docstring: Get the list of week days, ordered into weeks and padded according
  to the value of the first day of the week.
  
  @param renderer_base $output
  @return array The list of weeks.
docstring_tokens: Get the list of week days ordered into weeks and padded according to the value of the first day of the week .