<%
'轉發時請保留此聲明信息,這段聲明不并會影響你的速度!
'************************** 【日期擴展類】Ver 0.1.0 ********************************
'開發人:??Sman、Net Fetch
'開發日期:??2005-11-11
'版本號:??Ver 0.1.0
'官方網站:
http://www.sman.cnhttp://www.ad0.cn'電子郵件:huihui3030@126.com、Ad0@Ad0.Cn QQ:19341293 32050450
'版權聲明:版權沒有,盜版不究,源碼公開,歡迎盜版,歡迎你到官方網站來尋求支持。
'如有任何改進之處,麻煩轉發或者反饋一份到 huihui3030@126.com、Ad0@Ad0.Cn,Thanks!
'詳細使用說明或范例請見下載附件或到官方站點或Email聯系下載!
'************************************************************************************
Class DateFunEx
Private d_
?Private Sub class_initialize()
??d_ = ""
?End Sub
?
Public Property Let setDate(strDate) '傳入日期參數 strDate
d_ = strDate
End Property
?
?Public Property Get Version
??Version = "Copyright ? Date Function Extend Ver 0.1.0<br />" & _
????"Power by <a href='
http://www.sman.cn' target='_blank'>Sman</a> " & _
????" & <a href='mailto:NetFetchStudio@163.com' target='_blank'>Net Fetch</a>"
?End Property
Sub FormatDate()
??On Error Resume Next
??If IsNumeric(d_) Then
???d_ = Cint(d_)
???If len(d_)< 3 Then d_ = "20" & right("0"&d_,2)
???d_ = d_ & "-1"
??End If
??d_ = cDate(d_)
End Sub??
'------------------------------
' 功能說明:算第幾周的星期幾是幾號
' 參數說明:y 年,w周,week 星期 (星期一1 星期天7) FirstDayofWeek 每周的第一天(詳細設置請參照VBS手冊)
' 例 2005年40周星期天 GetWeekDate(2005,40,7)
'------------------------------
Public Function GetWeekDate(y, w, DayofWeek)
??Call FormatDate()
Dim NewYearDay,FirstDayofWeek
FirstDayofWeek = 2
NewYearDay = CDate(y & "-1-1") '元旦
GetWeekDate = ((NewYearDay - Weekday(NewYearDay, FirstDayofWeek)) + (w - 1) * 7 + DayofWeek)
?End Function
'------------------------------
' 功能說明:獲得某年某月的天數
' 參數說明:d_ 年-月-日
' 例 2005年10月 GetMonthDayCount("2005-10-11")(日可要可不要)
'------------------------------
Public Function GetMonthDayCount()
??Call FormatDate()
GetMonthDayCount = DateDiff("d", d_, DateAdd("m", 1, d_))
End Function
'------------------------------
' 功能說明:得到某年某月的第一天
' 相關函數:GetMonthFirstDay
' 例 本月 GetMonthFirstDay(date)(日可要可不要) 上月 GetMonthFirstDay(dateadd("m",-1,date)) 以此類推
'------------------------------
Public Function GetMonthFirstDay()
??Call FormatDate()
GetMonthFirstDay = CDate( Year(d_) & "-" & Month(d_) & "-1")
End Function
?
'------------------------------
' 功能說明:得到某年的某月的最后一天
' 參數說明:d_ 年-月-日
' 關聯函數:GetMonthDayCount
' 例 本月 GetMonthLastDay(date)(日可要可不要) 上月 GetMonthLastDay(dateadd("m",-1,date)) 以此類推
'------------------------------
Public Function GetMonthLastDay()
??Call FormatDate()
GetMonthLastDay = CDate( Year(d_) & "-"&Month(d_) & "-" & DateDiff("d", d_, DateAdd("m", 1, d_)))
End Function
'------------------------------
' 功能說明:某日所在的周的第一天的日期
' 相關函數:GetWeekDate
' 例 本周 WeekFirstDay(date) 上周 WeekFirstDay(dateadd("ww",-1,date)) 以此類推
'------------------------------
Public Function WeekFirstDay()
??Call FormatDate()
WeekFirstDay = GetWeekDate(Year(d_), DatePart("ww", d_), 1)
End Function
'------------------------------
' 功能說明:某日所在的周的第最后一天的日期
' 相關函數:GetWeekDate
' 例 本周 WeekLastDay(date) 上周 WeekLastDay(dateadd("ww",-1,date)) 以此類推
'------------------------------
Public Function WeekLastDay()
??Call FormatDate()
WeekLastDay = GetWeekDate(Year(d_), DatePart("ww", d_), 7)
End Function
?
End Class
%>