[wp-cvs] wordpress/wp-includes template-functions-general.php, 1.45, 1.46

Ryan Boren rboren at users.sourceforge.net
Thu Sep 9 23:07:48 UTC 2004


Update of /cvsroot/cafelog/wordpress/wp-includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3759/wp-includes

Modified Files:
	template-functions-general.php 
Log Message:
Allow the calendar start of week to be provisioned.  get_calendar() patch from rq. Bug 32.

Index: template-functions-general.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-general.php,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** template-functions-general.php	9 Sep 2004 03:45:51 -0000	1.45
--- template-functions-general.php	9 Sep 2004 23:07:46 -0000	1.46
***************
*** 330,333 ****
--- 330,339 ----
  }
  
+ // Used in get_calendar
+ function calendar_week_mod($num) {
+ 	$base = 7;
+ 	return ($num - $base*floor($num/$base));
+ }
+ 
  function get_calendar($daylength = 1) {
      global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
***************
*** 344,347 ****
--- 350,355 ----
      }
  
+     // week_begins = 0 stands for sunday
+     $week_begins = intval(get_settings('start_of_week'));
      $add_hours = intval(get_settings('gmt_offset'));
      $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
***************
*** 396,400 ****
      }
  
!     foreach ($weekday as $wd) {
          echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>';
      }
--- 404,414 ----
      }
  
!     $myweek = array();
! 	
!     for ($wdcount=0; $wdcount<=6; $wdcount++) {
!         $myweek[]=$weekday[($wdcount+$week_begins)%7];
!     }
! 	
!     foreach ($myweek as $wd) {
          echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>';
      }
***************
*** 478,482 ****
  
      // See how much we should pad in the beginning
!     $pad = intval(date('w', $unixmonth));
      if (0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
  
--- 492,496 ----
  
      // See how much we should pad in the beginning
!     $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
      if (0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
  
***************
*** 499,507 ****
          echo '</td>';
  
!         if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))
              $newrow = true;
      }
  
!     $pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear));
      if ($pad != 0 && $pad != 7)
          echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
--- 513,521 ----
          echo '</td>';
  
! 	if (6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins))
              $newrow = true;
      }
  
!     $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
      if ($pad != 0 && $pad != 7)
          echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';




More information about the cvs mailing list