3 # Display a table of days in the current month
5 require './web-lib.pl';
6 require 'timelocal.pl';
10 @daysin = ( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
11 $daysin[1] = $in{'year'}%400 == 0 ? 29 :
12 $in{'year'}%100 == 0 ? 28 :
13 $in{'year'}%4 == 0 ? 29 : 28;
15 @tm = localtime(time());
16 if ($in{'day'} !~ /^\d+$/ || $in{'day'} < 1 || $in{'year'} !~ /^\d+$/) {
18 $in{'month'} = $tm[4];
19 $in{'year'} = $tm[5]+1900;
21 if ($in{'day'} > $daysin[$in{'month'}]) {
22 $in{'day'} = $daysin[$in{'month'}];
24 $tm = timelocal(0, 0, 12, $in{'day'}, $in{'month'}, $in{'year'});
26 &popup_header($text{'chooser_date'});
31 location = "date_chooser.cgi?day=$in{'day'}&month="+m.selectedIndex+"&year=$in{'year'}";
35 location = "date_chooser.cgi?day=$in{'day'}&month=$in{'month'}&year="+(y.selectedIndex+$in{'year'}-10);
39 opener.dfield.value = d;
40 opener.mfield.selectedIndex = $in{'month'};
41 opener.yfield.value = $in{'year'};
45 <form><table border width=100%>
46 <tr> <td colspan=7 align=center><select name=year onChange='newyear(this)'>
48 for($i=$in{'year'}-10; $i<=$in{'year'}+10; $i++) {
49 printf "<option %s>%s\n",
50 $i == $in{'year'} ? 'selected' : '', $i;
52 print "</select> <select name=month onChange='newmonth(this)'>\n";
53 for($i=0; $i<12; $i++) {
54 printf "<option value=%s %s>%s\n",
55 $i, $i == $in{'month'} ? 'selected' : '',
56 $text{"month_".($i+1)};
58 print "</select></td> </tr>\n";
61 for($i=0; $i<7; $i++) {
62 print "<td><b>",$text{"sday_$i"},"</b></td>\n";
66 @first = localtime($tm - ($in{'day'}-1)*24*60*60);
67 $count = -$first[6] + 1;
68 for($y=0; $y<6; $y++) {
70 for($x=0; $x<7; $x++) {
71 if ($count < 1 || $count > $daysin[$in{'month'}]) {
72 print "<td align=center></td>\n";
75 printf "<td align=center %s><a href='' onClick='newday($count)'>%s</a></td>\n", $in{'day'} == $count ? $cb : '', $count;
81 print "</table></form>\n";