Make WordPress Core

Ticket #32: 0000032-template-functions-general.diff

File 0000032-template-functions-general.diff, 2.1 KB (added by anonymousbugger, 20 years ago)
Line 
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+
13function get_calendar($daylength = 1) {
14global $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) {
37echo "&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>';
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);
46if (0 != $pad) echo "&amp;#92;n&amp;#92;t&amp;#92;t".'<td colspan="'.$pad.'" class="pad">&amp;nbsp;</td>';
47
48$daysinmonth = intval(date('t', $unixmonth));
49@@ -475,11 +489,11 @@
50}
51echo '</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);
60if ($pad != 0 &amp;&amp; $pad != 7)
61echo "&amp;#92;n&amp;#92;t&amp;#92;t".'<td class="pad" colspan="'.$pad.'">&amp;nbsp;</td>';
62
63@@ -565,4 +579,4 @@
64echo $the_weekday_date;
65}
66
67-?>
68&amp;#92; No newline at end of file
69+?>