X龙@China .Net 'blog

需要的不仅仅是工作,而是通过努力得来的美好将来。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

javascript时间类

Posted on 2009-06-09 11:42  X龙  阅读(283)  评论(0编辑  收藏  举报

 

function Time()
{
    
var theDate = new Date();
    
    
this.Year = theDate.getFullYear;
    
this.Mouth = theDate.getMonth;
    
this.Date = theDate.getDate();
    
this.Day = theDate.getDay();
    
this.LocalTimeString = theDate.toLocaleDateString();
    
this.CurrentTime = theDate.toLocaleTimeString();

    
if (typeof (Time._initialized) == "undefined")
    {
        Time.prototype.getChineseWeek 
= function(day)
        {
            
var Chinese_Week = "";
            
switch (day)
            {
                
case 1: Chinese_Week = "星期一"break;
                
case 2: Chinese_Week = "星期二"break;
                
case 3: Chinese_Week = "星期三"break;
                
case 4: Chinese_Week = "星期四"break;
                
case 5: Chinese_Week = "星期五"break;
                
case 6: Chinese_Week = "星期六"break;
                
case 7: Chinese_Week = "星期日"break;
            }
            
return Chinese_Week;
        }
        
this._initialized = true;
    }

    
if (typeof (Time._initialized) == "undefined")
    {
        Time.prototype.getLongTime 
= function()/* 格式:2009年6月9日  星期二  11:39:05 */
        {
            
return this.LocalTimeString + "  " + this.getChineseWeek(this.Day) + "  " + this.CurrentTime;
        }
        
this._initialized = true;
    }

}

 

点击这里给我发消息http://wp.qq.com/index.html