1 | --- template-functions-general.php.bak 2004-05-22 14:27:51.123716000 +0300 |
---|
2 | +++ template-functions-general.php 2004-05-22 15:48:48.163716000 +0300 |
---|
3 | @@ -306,6 +306,12 @@ |
---|
4 | } |
---|
5 | } |
---|
6 | |
---|
7 | +// this one is used in get_calendar |
---|
8 | +function mod($num, $base) { |
---|
9 | + return ($num - $base*floor($num/$base)); |
---|
10 | +} |
---|
11 | + |
---|
12 | + |
---|
13 | function get_calendar($daylength = 1) { |
---|
14 | global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $tableposts, $posts; |
---|
15 | |
---|
16 | @@ -320,6 +326,8 @@ |
---|
17 | $w = ''.intval($_GET['w']); |
---|
18 | } |
---|
19 | |
---|
20 | + // week_begins = 0 stands for sunday |
---|
21 | + $week_begins = intval(get_settings('start_of_week')); |
---|
22 | $add_hours = intval(get_settings('gmt_offset')); |
---|
23 | $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); |
---|
24 | |
---|
25 | @@ -372,7 +380,13 @@ |
---|
26 | $day_abbrev = $weekday_abbrev; |
---|
27 | } |
---|
28 | |
---|
29 | - foreach ($weekday as $wd) { |
---|
30 | + $myweek = array(); |
---|
31 | + |
---|
32 | + for ($wdcount=0; $wdcount<=6; $wdcount++) { |
---|
33 | + $myweek[]=$weekday[($wdcount+$week_begins)%7]; |
---|
34 | + } |
---|
35 | + |
---|
36 | + foreach ($myweek as $wd) { |
---|
37 | echo "&#92;n&#92;t&#92;t<th abbr=&#92;"$wd&#92;" scope=&#92;"col&#92;" title=&#92;"$wd&#92;">" . $day_abbrev[$wd] . '</th>'; |
---|
38 | } |
---|
39 | |
---|
40 | @@ -454,7 +468,7 @@ |
---|
41 | |
---|
42 | |
---|
43 | // See how much we should pad in the beginning |
---|
44 | - $pad = intval(date('w', $unixmonth)); |
---|
45 | + $pad = mod(date('w', $unixmonth)-$week_begins, 7); |
---|
46 | if (0 != $pad) echo "&#92;n&#92;t&#92;t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>'; |
---|
47 | |
---|
48 | $daysinmonth = intval(date('t', $unixmonth)); |
---|
49 | @@ -475,11 +489,11 @@ |
---|
50 | } |
---|
51 | echo '</td>'; |
---|
52 | |
---|
53 | - if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))) |
---|
54 | + if (6 == mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins, 7)) |
---|
55 | $newrow = true; |
---|
56 | } |
---|
57 | |
---|
58 | - $pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)); |
---|
59 | + $pad = 7 - mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins, 7); |
---|
60 | if ($pad != 0 && $pad != 7) |
---|
61 | echo "&#92;n&#92;t&#92;t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>'; |
---|
62 | |
---|
63 | @@ -565,4 +579,4 @@ |
---|
64 | echo $the_weekday_date; |
---|
65 | } |
---|
66 | |
---|
67 | -?> |
---|
68 | &#92; No newline at end of file |
---|
69 | +?> |
---|