Home >Web Front-end >JS Tutorial >Date function extension class Ver0.1.1_javascript skills

Date function extension class Ver0.1.1_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:26:211068browse

Copy code The code is as follows:

<%
'Please keep this statement information when forwarding, this statement will not affect your speed!
'************** ************ 【Date extension class】Ver 0.1.1****************************** ***
'Developer: Sman, Net Fetch
'Development date: 2005-11-11
'Version number: Ver 0.1.1

'Official website: http:/ /www.sman.cn http://www.ad0.cn
'Email: huihui3030@126.com NetFetchStudio@163.com
'Daily Online QQ: 19341293 32050450
'Copyright statement: There is no copyright, piracy will not be investigated, the source code is open, piracy is welcome, and you are welcome to go to the official website for support.
'If there are any improvements, please forward or feedback a copy to huihui3030@126.com, NetFetchStudio@163.com, Thanks!
'For detailed usage instructions or examples, please see the download attachment or go to the official site or Email to download!
'************************************************ ****************************************

Class DateFunEx

Private d_
Private firstweekofyear_
Private firstdayofweek_

Private Sub class_initialize()
d_ = date() 'Default current date
firstdayofweek_ = 2 'vbMonday
firstweekofyear_ = 1 'Starts the week of January 1st.
End Sub

'Property setDate Date
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_ = c Date( value)
End Property

'Attribute firstweekofyear The first week of each year (for detailed settings, please refer to the VBS manual)
Public Property Let firstweekofyear(value)
firstweekofyear_ = cInt(value)
End Property

'Property FirstDayofWeek The first day of the week (for detailed settings, please refer to the VBS manual)
Public Property Let firstdayofweek(value)
firstdayofweek_ = cInt(value)
End Property


'------------------------------
' Function description: Count the number What is the day of the week?
' Parameter description: y year, w week, 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: Get 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 a certain month of a certain year The first day of
'------------------------------
Public Function GetMonthFirstDay()
GetMonthFirstDay = CDate( Year(d_) & "-" & Month(d_) & "-1")
End Function

'---------------- ----------------
' Function description: Get the last day of a certain month in 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 in which a certain day is located
'-------------------------- ----------
Public Function WeekFirstDay()
WeekFirstDay = GetWeekDate(Year(d_), DatePart("ww", d_,firstdayofweek_,firstweekofyear_), 1)
End Function

'------------------------------
'Function description: The week of a certain day The date of the last day
'---------------------------------
Public Function WeekLastDay()
WeekLastDay = GetWeekDate(Year(d_), DatePart("ww", d_,firstdayofweek_,firstweekofyear_), 7)
End Function

End Class
%>

How to use
Copy codeThe code is as follows:

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




Test_clsDateFunEx