首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

多年积累的js日期代码倾情奉献,该如何处理

2012-05-22 
多年积累的js日期代码倾情奉献JScript codescript languageJavascriptString.prototype.Left functio

多年积累的js日期代码倾情奉献

JScript code
<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);}


[解决办法]
感谢分享
[解决办法]
这次LZ没贴博客地址啊 LZ别的贴子都有贴的啊
[解决办法]
虽说有日期控件 可是这代码是可以用来提高的
[解决办法]
thanks for your work.

热点排行