日期函數(shù)擴(kuò)展類Ver0.1.1
更新時間:2006年09月07日 00:00:00 作者:
復(fù)制代碼 代碼如下:
<%
'轉(zhuǎn)發(fā)時請保留此聲明信息,這段聲明不并會影響你的速度!
'************************** 【日期擴(kuò)展類】Ver 0.1.1********************************
'開發(fā)人: Sman、Net Fetch
'開發(fā)日期: 2005-11-11
'版本號: Ver 0.1.1
'官方網(wǎng)站:http://www.sman.cn http://www.ad0.cn
'電子郵件:huihui3030@126.com NetFetchStudio@163.com
'每日在線QQ:19341293 32050450
'版權(quán)聲明:版權(quán)沒有,盜版不究,源碼公開,歡迎盜版,歡迎你到官方網(wǎng)站來尋求支持。
'如有任何改進(jìn)之處,麻煩轉(zhuǎn)發(fā)或者反饋一份到 huihui3030@126.com、NetFetchStudio@163.com,Thanks!
'詳細(xì)使用說明或范例請見下載附件或到官方站點(diǎn)或Email聯(lián)系下載!
'************************************************************************************
Class DateFunEx
Private d_
Private firstweekofyear_
Private firstdayofweek_
Private Sub class_initialize()
d_ = date() '默認(rèn)當(dāng)前日期
firstdayofweek_ = 2 'vbMonday
firstweekofyear_ = 1 '由 1 月 1 日所在的星期開始。
End Sub
'屬性 setDate 日期
Public Property Let setDate(value)
On Error Resume Next
If IsNumeric(value) Then
value = Cint(value)
If len(value)< 3 Then value = "20" & right("0"&value,2)
value = value & "-1"
End If
d_ = cDate(value)
End Property
'屬性 firstweekofyear 每年的第一周(詳細(xì)設(shè)置請參照VBS手冊)
Public Property Let firstweekofyear(value)
firstweekofyear_ = cInt(value)
End Property
'屬性 FirstDayofWeek 每周的第一天(詳細(xì)設(shè)置請參照VBS手冊)
Public Property Let firstdayofweek(value)
firstdayofweek_ = cInt(value)
End Property
'------------------------------
' 功能說明:算第幾周的星期幾是幾號
' 參數(shù)說明:y 年,w周,week 星期 (星期一1 星期天7)
'------------------------------
Public Function GetWeekDate(y, w, DayofWeek)
Dim NewYearDay
NewYearDay = CDate(y & "-1-1") '元旦
GetWeekDate = ((NewYearDay - Weekday(NewYearDay, firstdayofweek_)) + (w - 1) * 7 + DayofWeek)
End Function
'------------------------------
' 功能說明:獲得某年某月的天數(shù)
'------------------------------
Public Function GetMonthDayCount()
GetMonthDayCount = DateDiff("d", d_, DateAdd("m", 1, d_))
End Function
'------------------------------
' 功能說明:得到某年某月的第一天
'------------------------------
Public Function GetMonthFirstDay()
GetMonthFirstDay = CDate( Year(d_) & "-" & Month(d_) & "-1")
End Function
'------------------------------
' 功能說明:得到某年的某月的最后一天
'------------------------------
Public Function GetMonthLastDay()
GetMonthLastDay = CDate( Year(d_) & "-"&Month(d_) & "-" & DateDiff("d", d_, DateAdd("m", 1, d_)))
End Function
'------------------------------
' 功能說明:某日所在的周的第一天的日期
'------------------------------
Public Function WeekFirstDay()
WeekFirstDay = GetWeekDate(Year(d_), DatePart("ww", d_,firstdayofweek_,firstweekofyear_), 1)
End Function
'------------------------------
' 功能說明:某日所在的周的第最后一天的日期
'------------------------------
Public Function WeekLastDay()
WeekLastDay = GetWeekDate(Year(d_), DatePart("ww", d_,firstdayofweek_,firstweekofyear_), 7)
End Function
End Class
%>
使用方法
復(fù)制代碼 代碼如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<% Option Explicit %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Test_clsDateFunEx</title>
</head>
<body>
<!--#include file="clsDateFunEx.asp" -->
<%
Dim myDateFun,strDate
strDate = "2005-4-1"
Set myDateFun = new DateFunEx
myDateFun.setDate = strDate
Response.write "2006年第2周的星期一是幾號:" & _
myDateFun.GetWeekDate(2006,2,1) &"<br>"
Response.Write "2005年4月的天數(shù):"&_
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>"
Set myDateFun = Nothing
%>
<br><br><br>
</body>
</html>
相關(guān)文章
在bootstrap中實(shí)現(xiàn)輪播圖實(shí)例代碼
Bootstrap中輪播圖插件叫作Carousel ,下面通過本文給大家詳細(xì)介紹了bootstrop中實(shí)現(xiàn)輪播圖效果,需要的朋友參考下2017-06-06JavaScript實(shí)現(xiàn)in-place思想的快速排序方法
這篇文章主要介紹了JavaScript實(shí)現(xiàn)in-place思想的快速排序方法的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-08-08js檢測標(biāo)題與描述中的關(guān)鍵詞發(fā)現(xiàn)就替換或跳轉(zhuǎn)到別的頁面
這篇文章主要介紹了js檢測標(biāo)題與描述中的關(guān)鍵詞發(fā)現(xiàn)就替換或跳轉(zhuǎn)到別的頁面的實(shí)現(xiàn)方法,主要是分享它的編程思路與加密方法2021-06-06javascript自定義右鍵彈出菜單實(shí)現(xiàn)方法
這篇文章主要介紹了javascript自定義右鍵彈出菜單實(shí)現(xiàn)方法,涉及javascript操作鼠標(biāo)事件及頁面元素的相關(guān)技巧,需要的朋友可以參考下2015-05-05JavaScript判斷是否為數(shù)字的4種方法及效率比較
這篇文章主要介紹了JavaScript判斷是否為數(shù)字的4種方法及效率比較,本文直接給出判斷方法實(shí)現(xiàn)代碼及運(yùn)行效率效果圖,方便大家選擇使用,需要的朋友可以參考下2015-04-04使用bootstrap validator的remote驗(yàn)證代碼經(jīng)驗(yàn)分享(推薦)
這篇文章主要介紹了使用bootstrap validator的remote驗(yàn)證器驗(yàn)證經(jīng)驗(yàn)分享(推薦)的相關(guān)資料,本文介紹的非常詳細(xì),具有參考借鑒價值,需要的朋友可以參考下2016-09-09快速理解 JavaScript 中的 LHS 和 RHS 查詢的用法
本篇文章主要介紹了快速理解 JavaScript 中的 LHS 和 RHS 查詢的用法,有一定的參考價值,感興趣的小伙伴們可以參考一下2017-08-08