手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >日期函数扩展类Ver0.1.1
日期函数扩展类Ver0.1.1
摘要:复制代码代码如下:使用方法复制代码代码如下:Test_clsDateFunEx

复制代码 代码如下:

<%

'转发时请保留此声明信息,这段声明不并会影响你的速度!

'**************************【日期扩展类】Ver0.1.1********************************

'开发人:Sman、NetFetch

'开发日期:2005-11-11

'版本号:Ver0.1.1

'官方网站:http://www.sman.cnhttp://www.ad0.cn

'电子邮件:huihui3030@126.comNetFetchStudio@163.com

'每日在线QQ:1934129332050450

'版权声明:版权没有,盗版不究,源码公开,欢迎盗版,欢迎你到官方网站来寻求支持。

'如有任何改进之处,麻烦转发或者反馈一份到huihui3030@126.com、NetFetchStudio@163.com,Thanks!

'详细使用说明或范例请见下载附件或到官方站点或Email联系下载!

'************************************************************************************

ClassDateFunEx

Privated_

Privatefirstweekofyear_

Privatefirstdayofweek_

PrivateSubclass_initialize()

d_=date()'默认当前日期

firstdayofweek_=2'vbMonday

firstweekofyear_=1'由1月1日所在的星期开始。

EndSub

'属性setDate日期

PublicPropertyLetsetDate(value)

OnErrorResumeNext

IfIsNumeric(value)Then

value=Cint(value)

Iflen(value)<3Thenvalue="20"&right("0"&value,2)

value=value&"-1"

EndIf

d_=cDate(value)

EndProperty

'属性firstweekofyear每年的第一周(详细设置请参照VBS手册)

PublicPropertyLetfirstweekofyear(value)

firstweekofyear_=cInt(value)

EndProperty

'属性FirstDayofWeek每周的第一天(详细设置请参照VBS手册)

PublicPropertyLetfirstdayofweek(value)

firstdayofweek_=cInt(value)

EndProperty

'------------------------------

'功能说明:算第几周的星期几是几号

'参数说明:y年,w周,week星期(星期一1星期天7)

'------------------------------

PublicFunctionGetWeekDate(y,w,DayofWeek)

DimNewYearDay

NewYearDay=CDate(y&"-1-1")'元旦

GetWeekDate=((NewYearDay-Weekday(NewYearDay,firstdayofweek_))+(w-1)*7+DayofWeek)

EndFunction

'------------------------------

'功能说明:获得某年某月的天数

'------------------------------

PublicFunctionGetMonthDayCount()

GetMonthDayCount=DateDiff("d",d_,DateAdd("m",1,d_))

EndFunction

'------------------------------

'功能说明:得到某年某月的第一天

'------------------------------

PublicFunctionGetMonthFirstDay()

GetMonthFirstDay=CDate(Year(d_)&"-"&Month(d_)&"-1")

EndFunction

'------------------------------

'功能说明:得到某年的某月的最后一天

'------------------------------

PublicFunctionGetMonthLastDay()

GetMonthLastDay=CDate(Year(d_)&"-"&Month(d_)&"-"&DateDiff("d",d_,DateAdd("m",1,d_)))

EndFunction

'------------------------------

'功能说明:某日所在的周的第一天的日期

'------------------------------

PublicFunctionWeekFirstDay()

WeekFirstDay=GetWeekDate(Year(d_),DatePart("ww",d_,firstdayofweek_,firstweekofyear_),1)

EndFunction

'------------------------------

'功能说明:某日所在的周的第最后一天的日期

'------------------------------

PublicFunctionWeekLastDay()

WeekLastDay=GetWeekDate(Year(d_),DatePart("ww",d_,firstdayofweek_,firstweekofyear_),7)

EndFunction

EndClass

%>

使用方法

复制代码 代码如下:

<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%>

<%OptionExplicit%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>

<title>Test_clsDateFunEx</title>

</head>

<body>

<>

<%

DimmyDateFun,strDate

strDate="2005-4-1"

SetmyDateFun=newDateFunEx

myDateFun.setDate=strDate

Response.write"2006年第2周的星期一是几号:"&_

myDateFun.GetWeekDate(2006,2,1)&"<br>"

Response.Write"2005年4月的天数:"&_

myDateFun.GetMonthDayCount&"<br>"

Response.Write"2005年4月的第一天:"&_

myDateFun.GetMonthFirstDay&"<br>"

Response.Write"2005年4月的最后一天:"&_

myDateFun.GetMonthLastDay&"<br>"

Response.Write"2005年4月1日所在的周的第一天的日期:"&_

myDateFun.WeekFirstDay&"<br>"

Response.Write"2005年4月1日所在的周的第最后一天的日期:"&_

myDateFun.WeekLastDay&"<br>"

SetmyDateFun=Nothing

%>

<br><br><br>

</body>

</html>

【日期函数扩展类Ver0.1.1】相关文章:

浅谈jQuery构造函数分析

javascript无刷新评论实现方法

JQuery实现带排序功能的权限选择实例

繁简字转换功能

精通JavaScript的this关键字

prototype 1.5 & scriptaculous 1.6.1 学习笔记

基于Web标准的UI组件 — 树状菜单(2)

javascript中动态函数用法

JS选项卡动态替换banner图片路径的方法

日历-指定日期的新闻

精品推荐
分类导航