日期:2014-05-17 浏览次数:20743 次
<script language=Javascript> String.prototype.Left = function(len){ if(isNaN(len)||len==null){ len = 0; } else { if(parseInt(len)<0||parseInt(len)>this.length) { len = 0; } } return this.substr(0,this.length-len)+'**'; } //日期自动补零程序 function appendZero(n) { return(("00"+ n).substr(("00"+ n).length-2)); } //获得当年当月最大天数 function GetMonthMaxDay(theYear,theMonth){ var theDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31); var theMonthDay = 0, tmpYear = this.formatYear(theYear); theMonthDay = theDays[theMonth]; if (theMonth == 1){ //theMonth is February if (((tmpYear % 4 == 0) && (tmpYear % 100 != 0)) || (tmpYear % 400 == 0)){ theMonthDay++; } } return(theMonthDay); } //把年份格式化成4位 function formatYear(theYear){ var tmpYear = parseInt(theYear,10); if (tmpYear < 100){ tmpYear += 1900; if (tmpYear < 1940){ tmpYear += 100; } } if (tmpYear < this.MinYear){ tmpYear = this.MinYear; } if (tmpYear > this.MaxYear){ tmpYear = this.MaxYear; } return(tmpYear); }