<%
'Please keep this statement information when forwarding, this statement will not affect your speed!
'****************************** 【Date Extension Class】Ver 0.1.1******************************
'Developers: Sman, Net Fetch
'Development date: 2005-11-11
'Ver 0.1.1
'Official website: http://
'Email: huihui3030@ NetFetchStudio@
'Daily online QQ: 19341293 �
'Copyright Statement: There is no copyright, no piracy is investigated, source code is disclosed, pirated version is welcome, and you are welcome to go to the official website to seek support.
'If there are any improvements, please forward or feedback to huihui3030@, NetFetchStudio@, Thanks!
'For detailed instructions or examples, please see the download attachment or contact the official website or email to download!
'************************************************************************************
Class DateFunEx
Private d_
Private firstweekofyear_
Private firstdayofweek_
Private Sub class_initialize()
d_ �
firstdayofweek_ = 2 'vbMonday
firstweekofyear_ = 1 'Start from the week of January 1.
End Sub
'Properties 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
'Properties firstweekofyear The first week of each year (refer to the VBS manual for details)
Public Property Let firstweekofyear(value)
firstweekofyear_ = cInt(value)
End Property
'Properties First Day of Week (refer to the VBS manual for details)
Public Property Let firstdayofweek(value)
firstdayofweek_ = cInt(value)
End Property
'------------------------------
Function description: What week is the week of the year
' Parameter description: y year, w weeks, week (Monday 1 Sunday 7)
'------------------------------
Public Function GetWeekDate(y, w, DayofWeek)
Dim NewYearDay
NewYearDay = CDate(y & "-1-1") 'New Year's Day
GetWeekDate = ((NewYearDay - Weekday(NewYearDay, firstdayofweek_)) + (w - 1) * 7 + DayofWeek)
End Function
'------------------------------
Function description: Obtain the number of days in a certain year and month
'------------------------------
Public Function GetMonthDayCount()
GetMonthDayCount = DateDiff("d", d_, DateAdd("m", 1, d_))
End Function
'------------------------------
Function description: Get the first day of a certain month
'------------------------------
Public Function GetMonthFirstDay()
GetMonthFirstDay = CDate( Year(d_) & "-" & Month(d_) & "-1")
End Function
'------------------------------
Function description: Get the last day of a certain month of a certain year
'------------------------------
Public Function GetMonthLastDay()
GetMonthLastDay = CDate( Year(d_) & "-"&Month(d_) & "-" & DateDiff("d", d_, DateAdd("m", 1, d_)))
End Function
'------------------------------
Function description: The date of the first day of the week on which a certain day is located
'------------------------------
Public Function WeekFirstDay()
WeekFirstDay = GetWeekDate(Year(d_), DatePart("ww", d_,firstdayofweek_,firstweekofyear_), 1)
End Function
'------------------------------
Function description: The date of the last day of the week on which a certain day is located
'------------------------------
Public Function WeekLastDay()
WeekLastDay = GetWeekDate(Year(d_), DatePart("ww", d_,firstdayofweek_,firstweekofyear_), 7)
End Function
End Class
%>