goody9807  
避风的港湾-云之宇~~~寻找.Net的精华

一个不错的P2P软件,里面肯定有你要的资源
公告


  • 我的msn: goody9807#sina.com


    爱你网论坛全新上线,Asp.net技术讨论


日历
<2005年11月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
统计
  • 随笔 - 424
  • 文章 - 4
  • 评论 - 532
  • 引用 - 96

导航

与我联系

搜索

 

常用链接

我参与的团队

随笔分类(418)

我的空间

友情链接

积分与排名

  • 积分 - 274065
  • 排名 - 107

最新评论

60天内阅读排行

 
<script language="JavaScript">
<!--
function PowerDate(timeString){
this.date=null;
if(timeString!=""this.date=new Date(timeString);
else this.date=new Date();
this.isFmtZero=false;
this.weekArr=[["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],
  [
"SUN","MON","TUR","WED","THU","FRI","SAT"]];
this.monthArr=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"];
this.getFullYear=function(){
return this.date.getFullYear();
}
;
this.getYear=function(){
return this.date.getYear();
}
;
this.getMonth=function(){
var mm=this.date.getMonth()+1;
if(this.isFmtZero==true && mm<10)
return "0"+mm;
else return mm;
}
;
this.getDay=function(){
var dd=this.date.getDate();
if(this.isFmtZero==true && dd<10)
return "0"+dd;
else return dd;
}
;
this.getHour=function(){
var hh=this.date.getHours();
if(this.isFmtZero==true && hh<10)
return "0"+hh;
else return hh;
}
;
this.getMinute=function(){
var mi=this.date.getMinutes();
if(this.isFmtZero==true && mi<10)
return "0"+mi;
else return mi;
}
;
this.getSecond=function(){
var ss=this.date.getSeconds();
if(this.isFmtZero==true && ss<10)
return "0"+ss;
else return ss;
}
;
this.getMillisecond=function(){
var ss=this.date.getMilliseconds();
if(this.isFmtZero==true && ss<10)
return "00"+ss;
else if(this.isFmtZero==true && ss<100)
return "0"+ss;
else return ss;
}
;
this.getWeek=function(){
return this.date.getDay();
}
;
this.setIsFmtZero=function(val){
this.isFmtZero=val;
}
;
/*
功能:根据输入表达式返回日期字符串
参数:dateFmt:字符串,由以下结构组成 yy:长写年,YY:短写年mm:数字月,MM:英文月,dd:日,hh:时,mi:分,ss秒,ms:毫秒,we:汉字星期,WE:英文星期.
isFmtZero:布尔值,true:需要用0补位,false:不需要用0补位
*/

this.getString=function(dateFmt){
if(typeof(dateFmt) != "string" )
throw(new Error(-1, 'getString()方法需要字符串类型参数!'));
var str=dateFmt;
str
=str.replace(/yy/g,this.getFullYear());
str
=str.replace(/YY/g,this.getYear());
str
=str.replace(/mm/g,this.getMonth());
str
=str.replace(/MM/g,this.monthArr[this.getMonth()-1]);
str
=str.replace(/dd/g,this.getDay());
str
=str.replace(/hh/g,this.getHour());
str
=str.replace(/mi/g,this.getMinute());
str
=str.replace(/ss/g,this.getSecond());
str
=str.replace(/ms/g,this.getMillisecond());
str
=str.replace(/we/g,this.weekArr[0][this.getWeek()]);
str
=str.replace(/WE/g,this.weekArr[1][this.getWeek()]);
return str;
}
;
//返回N天前(后)的日期
//
返回与另一日期之间的时间间隔
//
}

PowerDate.prototype.fmtWithZero
= function(){

}

var d= new PowerDate("");
d.setIsFmtZero(
true);
alert(d.getString(
"yy-mm-dd hh:mi:ss.ms"));
//-->
</script>
<body>
</body>



/*
******************************************
日期函数扩充 
******************************************
*/



/*
===========================================
//转换成大写日期(中文)
===========================================
*/

Date.prototype.toCase 
= function()
{
var digits= new Array('零','一','二','三','四','五','六','七','八','九','十','十一','十二');
var unit= new Array('年','月','日','点','分','秒');

var year= this.getYear() + "";
var index;
var output="";

////////得到年
for (index=0;index<year.length;index++ )
{
output 
+= digits[parseInt(year.substr(index,1))];
}

output 
+=unit[0];

///////得到月
output +=digits[this.getMonth()] + unit[1];

///////得到日
switch (parseInt(this.getDate() / 10))
{
case 0:
output 
+=digits[this.getDate() % 10];
break;
case 1:
output 
+=digits[10+ ((this.getDate() % 10)>0?digits[(this.getDate() % 10)]:"");
break;
case 2:
case 3:
output 
+=digits[parseInt(this.getDate() / 10)] + digits[10]  + ((this.getDate() % 10)>0?digits[(this.getDate() % 10)]:"");
default:

break;
}

output 
+=unit[2];

///////得到时
switch (parseInt(this.getHours() / 10))
{
case 0:
output 
+=digits[this.getHours() % 10];
break;
case 1:
output 
+=digits[10+ ((this.getHours() % 10)>0?digits[(this.getHours() % 10)]:"");
break;
case 2:
output 
+=digits[parseInt(this.getHours() / 10)] + digits[10+ ((this.getHours() % 10)>0?digits[(this.getHours() % 10)]:"");
break;
}

output 
+=unit[3];

if(this.getMinutes()==0&&this.getSeconds()==0)
{
output 
+="";
return output;
}


///////得到分
switch (parseInt(this.getMinutes() / 10))
{
case 0:
output 
+=digits[this.getMinutes() % 10];
break;
case 1:
output 
+=digits[10+ ((this.getMinutes() % 10)>0?digits[(this.getMinutes() % 10)]:"");
break;
case 2:
case 3:
case 4:
case 5:
output 
+=digits[parseInt(this.getMinutes() / 10)] + digits[10+ ((this.getMinutes() % 10)>0?digits[(this.getMinutes() % 10)]:"");
break;
}

output 
+=unit[4];

if(this.getSeconds()==0)
{
output 
+="";
return output;
}


///////得到秒
switch (parseInt(this.getSeconds() / 10))
{
case 0:
output 
+=digits[this.getSeconds() % 10];
break;
case 1:
output 
+=digits[10+ ((this.getSeconds() % 10)>0?digits[(this.getSeconds() % 10)]:"");
break;
case 2:
case 3:
case 4:
case 5:
output 
+=digits[parseInt(this.getSeconds() / 10)] + digits[10+ ((this.getSeconds() % 10)>0?digits[(this.getSeconds() % 10)]:"");
break;
}

output 
+=unit[5];



return output;
}



/*
===========================================
//转换成农历
===========================================
*/

Date.prototype.toChinese 
= function()
{
//暂缺
}


/*
===========================================
//是否是闰年
===========================================
*/

Date.prototype.isLeapYear 
= function()
{
return (0==this.getYear()%4&&((this.getYear()%100!=0)||(this.getYear()%400==0)));
}


/*
===========================================
//获得该月的天数
===========================================
*/

Date.prototype.getDayCountInMonth 
= function()
{
var mon = new Array(12);

    mon[
0= 31; mon[1= 28; mon[2= 31; mon[3=