--- template-functions-general.php.bak 2004-05-22 14:27:51.123716000 +0300
+++ template-functions-general.php 2004-05-22 15:48:48.163716000 +0300
@@ -306,6 +306,12 @@
}
}

+// this one is used in get_calendar
+function mod($num, $base) {
+ 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, $tableposts, $posts;

@@ -320,6 +326,8 @@
$w = ''.intval($_GET['w']);
}

+ // 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));

@@ -372,7 +380,13 @@
$day_abbrev = $weekday_abbrev;
}

- foreach ($weekday as $wd) {
+ $myweek = array();
+
+ for ($wdcount=0; $wdcount<=6; $wdcount++) {
+ $myweek[]=$weekday[($wdcount+$week_begins)%7];
+ }
+
+ foreach ($myweek as $wd) {
echo "&amp;#92;n&amp;#92;t&amp;#92;t<th abbr=&amp;#92;"$wd&amp;#92;" scope=&amp;#92;"col&amp;#92;" title=&amp;#92;"$wd&amp;#92;">" . $day_abbrev[$wd] . '</th>';
}

@@ -454,7 +468,7 @@


// See how much we should pad in the beginning
- $pad = intval(date('w', $unixmonth));
+ $pad = mod(date('w', $unixmonth)-$week_begins, 7);
if (0 != $pad) echo "&amp;#92;n&amp;#92;t&amp;#92;t".'<td colspan="'.$pad.'" class="pad">&amp;nbsp;</td>';

$daysinmonth = intval(date('t', $unixmonth));
@@ -475,11 +489,11 @@
}
echo '</td>';

- if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))
+ if (6 == mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins, 7))
$newrow = true;
}

- $pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear));
+ $pad = 7 - mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins, 7);
if ($pad != 0 &amp;&amp; $pad != 7)
echo "&amp;#92;n&amp;#92;t&amp;#92;t".'<td class="pad" colspan="'.$pad.'">&amp;nbsp;</td>';

@@ -565,4 +579,4 @@
echo $the_weekday_date;
}

-?>
&amp;#92; No newline at end of file
+?>