Compile a simple calendar. Enter the date to be searched in the text box. The program can calculate the week number of the day in the year and determine the day number of the week. For more information, see
For interaction, we should select Js for implementation, which is also the first test of Pair programming. I will write the display part in html, and click the button to trigger the event function. The Code is as follows: function onCheck () {var Year = document. getElementById ("year "). value; // obtain the "Year" var theYear = Year * 1 of the text box; // convert it to the number type // alert (theYear); // obtain the monthly value var month = document. getElementById ("month"); var index1 = month. selectedIndex; var theMonth = month. options [index1]. value; // obtain the monthly value var day = document. getElementById ("day"); var index2 = day. selectedIndex; var theDay = Day. options [index2]. value; // input value judgment part... // call the core function days (theYear, theMonth, theDay);} the core function days is as follows: Code: function days (year, month, day) {var days = 0; // indicates the day of the year when the change date is set to the day of the current year. // the number of days of the accumulated month is for (var I = 1; I <month; I ++) {switch (I) {// 31 case 1: case 3: case 5: case 7: case 8: case 10: case 12: {days + = 31; break ;} // Add 30 case 4: case 6: case 9: case 11: {days + = 30; break;} in the case of a small month, add case 2: {if (isLe ApYear (year) {days + = 29; // leap year plus 29} else {days + = 28;} break ;}} day = day * 1; days + = day; // the number of days of the month and the number of days of the plus day var date0 = new Date (year ); // The first day of the current year is the day of the week. // alert (date0.getDay (); var date1 = new Date (year, month-1, day); // format the Date value, 0-11 represents January-December; // alert (days + date0.getDay () + 6)/7); var nthOfWeek = Math. floor (days + date0.getDay () + 6)/7); // rounded down // alert (nthOfWeek); var toDay = new Array ("Sunday ", "Monday", "Star Period 2 "," Wednesday "," Thursday "," Friday "," Saturday "); // day. getDay (); return one of the week's values based on Date. 0 is Sunday alert ("this Date is the day of the year" + days + "day \ n" + "is the day of the week" + nthOfWeek + ""+ toDay [date1.getDay ()]);} many unexpected errors were encountered during the debugging process, such as computing errors caused by Type mismatch, such as number rounding. With the assistance of his teammates, he was responsible for reviewing and assisting with catching bugs, I am responsible for implementation and coding. In the last step, during the testing of input values, we assisted each other and analyzed different input situations, covering various possible accidents, the function was completed quickly. The following Code determines whether the input value is allowed: the code is as follows: if (isNaN (theYear) | theYear <0) {alert ("incorrect input. Please enter it again"); return ;}if (theMonth = 2 & theDay> 29 & I SLeapYear (theYear) | (theMonth = 2 & theDay> 28 &&! IsLeapYear (theYear) {alert ("incorrect input, please enter"); return ;} if (theMonth = 4 | theMonth = 6 | theMonth = 9 | theMonth = 11) & theDay = 31) {alert ("incorrect input, enter "); return;} again ;}