There's a problem with writing the calendar control, using JavaScript to get the last month, there's no way to bring it back, it's too backward to write, it's tiring.
Date.getdayofmonth = function (y, Mm) {///<summary>///calculates the total number of days of the current month///create by the Yangtze River 20121225///
t;/summary>///<returns type= "number"/>///<param name= "y" type= "number" >///year, if NULL is the current time </param>///<param name= "Mm" type= "number" >///month, starting at 0, if NULL is the current time///</param> if (typeof y = = ' undefined ')
{y = (new Date ()). getFullYear ();
if (typeof mm = n ' undefined ') {mm = (new Date ()). GetMonth (); var Feb = (y% 4 = 0)?
29:28;
var AM = new Array (Feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
return AM[MM];
}; Date.getdateofpremonth = function (dt) {///<summary>///returns the date of January///create by Yangtze River 20121225///
;/summary>///<returns type= "date"/>///<param name= "DT" type= "date" >///reference date, if NULL is current time
</param> if (typeof dt = = ' undefined ') {dt = (new Date ());} var y = (dt.getmonth () = = 0)? (Dt.getfullYear ()-1): Dt.getfullyear (); var m = (dt.getmonth () = = 0)?
11:dt.getmonth ()-1; var PreM = Date.getdayofmonth<span style= "font-family:arial, Helvetica, Sans-serif;" > (y, m);</span> var d = (PreM < Dt.getdate ())?
PreM:dt.getDate ();
return new Date (Y, M, d); };
Date.getdateofnextmonth = function (dt) { ///<span style= "White-space:pre" > </span>< summary> ///<span style= "White-space:pre" > </span> back to January date ///create by Yangtze River 201 21225 ///<span style= "White-space:pre" > </span></summary> ///<span style= "White-space:pre" > </span><returns type= "Date"/> ///<span style= "White-space: Pre "> </span><param name=" dt "type=" Date "> ///<span style=" White-space:pre "> </
Span> reference date, if NULL is current time ///<span style= "White-space:pre" > </span></param> if (typeof dt = = ' undefined ') {dt = (new Date ());} var y = (dt.getmonth () = 11)?
(Dt.getfullyear () + 1): Dt.getfullyear (); var m = (dt.getmonth () = = 11)?
0:dt.getmonth () + 1;
var PreM = Date.getdayofmonth (y, M); var d = (PreM &Lt Dt.getdate ())?
PreM:dt.getDate ();
return new Date (Y, M, d);
};
Suppose the current time is July 24, 2014 morning 12:00:00
//Output Result:
d.tolocalestring ()
"June 24, 2014 morning 12:00:00"
D2.tolocalestring ()
"December 28, 2013 morning 12:00:00"
DD
31
A few of the bugs have been measured, just changed
Guys, help with the test, thanks.