<%
'//类说明
'//类名:FormatDateClass
'//作用:格式化时间
Class FormatDateClass
'//声明成员变量
Private Obtainvalue '//获取格式化时间值
'//!====================构造函数====================!//
Private Sub Class_InitiaLize()
Obtainvalue=Now '//初始化变量Obtainvalue
End Sub
'//!====================析构函数====================!//
Private Sub Class_Terminate()
Set FormatDateClass=Nothing
End Sub
'//!====================Let属性=====================!//
Public Property Let ObtainDate(Str)
If ISNull(Str)=False Then
If ISDate(Str)=True Then
Obtainvalue=Str
Else
Obtainvalue=Now()
End If
Else
Exit Property
End If
End Property
'//!====================Get属性======================!//
Public Property Get ObtainDate()
ObtainDate=Obtainvalue
End Property
'//!====================FormatDateFunction============!//
'//函数名:FormatDateFunction
'//参数:Obtainvalue,Strtype
'//作用:格式化日期时间
'//被格式化的值
Public Function FormatDateFunction(Strtype)
Dim StrDate,ReturnDate
StrDate=Obtainvalue
If ISNull(StrDate)=True Then
Exit Function
Else
If ISDate(StrDate)=False Then
Exit Function
End If
End If
If Strtype<1 Or Strtype>25 Then
Strtype=1
Else
Strtype=Strtype
End If
Select Case Strtype
'//以年月格式化
Case 1
ReturnDate=Year(StrDate)&"年"&Month(StrDate)&"月"
Case 2
ReturnDate=Year(StrDate)&"-"&Month(StrDate)
Case 3
ReturnDate=Year(StrDate)&"/"&Month(StrDate)
'//以年月日格式化
Case 4
ReturnDate=Year(StrDate)&"年"&Month(StrDate)&"月"&Day(StrDate)&"日"
Case 5
ReturnDate=Year(StrDate)&"-"&Month(StrDate)&"-"&Day(StrDate)
Case 6
ReturnDate=Year(StrDate)&"/"&Month(StrDate)&"/"&Day(StrDate)
Case 7
'//以年月格式化
ReturnDate=Year(StrDate)&"年"&Month(StrDate)&"月"
Case 8
ReturnDate=Year(StrDate)&"-"&Month(StrDate)
Case 9
ReturnDate=Year(StrDate)&"/"&Month(StrDate)
'//以月日格式化
Case 10
ReturnDate=Month(StrDate)&"月"&Day(StrDate)&"日"
Case 11
ReturnDate=Month(StrDate)&"-"&Day(StrDate)
Case 12
ReturnDate=Month(StrDate)&"/"&Day(StrDate)
'//以小时分秒格式化
Case 13
ReturnDate=Hour(StrDate)&"-"&Minute(StrDate)&"-"&Second(StrDate)
Case 14
ReturnDate=Hour(StrDate)&"/"&Minute(StrDate)&"/"&Second(StrDate)
'//以小时分格式化
Case 15
ReturnDate=Hour(StrDate)&"-"&Minute(StrDate)
Case 16
ReturnDate=Hour(StrDate)&"/"&Minute(StrDate)
'//以年月日小时格式化
Case 17
ReturnDate=Year(StrDate)&"年"&Month(StrDate)&"月"&Day(StrDate)&"日"&Minute(StrDate)
Case 18
ReturnDate=Year(StrDate)&"-"&Month(StrDate)&"-"&Day(StrDate)&"-"&Minute(StrDate)
Case 19
ReturnDate=Year(StrDate)&"/"&Month(StrDate)&"/"&Day(StrDate)&"/"&Minute(StrDate)
Case 20
ReturnDate=FormatWeekFunction(1)
Case 21
ReturnDate=FormatWeekFunction(2)
Case 22
ReturnDate=FormatWeekFunction(3)
Case 23
ReturnDate=FormatWeekFunction(4)
Case 24
ReturnDate=FormatWeekFunction(5)
Case Else
Exit Function
End Select
FormatDateFunction=ReturnDate
End Function
'//=======================FormatWeekFunction==========================!//
'//函数名:FormatWeekFunction
'//参数:Strtype
'//作用:格式化星期
'//返回值:被格式化的星期
Public Function FormatWeekFunction(Strtype)
Dim FormatDate,FormatWeek,StrDate
If FormatDateFunction(2)=Date() Then
FormatDate=FormatDateFunction(2)
Else
FormatDate=Date()
End If
If ISNull(Strtype) Then
Exit Function
End If
If ISnull(Obtainvalue)=False And ISDate(Obtainvalue)=True Then
StrDate=Obtainvalue
Else
StrDate=Now()
End If
FormatWeek=FormatWeekvalue(WeekDay(FormatDate))
Select Case Strtype
'//以年月日星期格式化
Case 1
FormatWeekFunction=Year(StrDate)&"年"&Month(StrDate)&"月"&Day(StrDate)&"日 "&FormatWeek
Case 2
FormatWeekFunction=Year(StrDate)&"-"&Month(StrDate)&"-"&Day(StrDate)&"日 "&FormatWeek
Case 3
FormatWeekFunction=Year(StrDate)&"/"&Month(StrDate)&"/"&Day(StrDate)&" "&FormatWeek
'//以年月星期格式化
Case 4
FormatWeekFunction=Year(StrDate)&"年"&Month(StrDate)&"月 "&FormatWeek
Case 5
FormatWeekFunction=Year(StrDate)&"-"&Month(StrDate)&" "&FormatWeek
End Select
End Function
'//!=====================FormatWeekvalue===============================!//
'//函数名:FormatWeekvalue
'//参数:StrFormatvalue
'//返回值:被格式化的星期
Public Function FormatWeekvalue(StrFormatvalue)
If ISNull(StrFormatvalue)=True Then
Exit Function
End If
Select Case StrFormatvalue
Case 1
FormatWeekvalue="星期日"
Case 2
FormatWeekvalue="星期一"
Case 3
FormatWeekvalue="星期二"
Case 4
FormatWeekvalue="星期三"
Case 5
FormatWeekvalue="星期四"
Case 6
FormatWeekvalue="星期五"
Case 7
FormatWeekvalue="星期六"
Case Else
Exit Function
End Select
End Function
'//!======================FormatCurrentDate===========================!//
'//函数名:FormatCurrentDate
'//参数:Strvalue
'//作用:格式化当前时间
'//返回值:被格式化的当前时间
Public Function FormatCurrentDate(Strvalue)
Dim FormatDate,ReturnDate
FormatDate=Strvalue
If ISNull(FormatDate)=True Then
Exit Function
Else
If ISDate(FormatDate)=False Then
FormatDate=Now()
Else
FormatDate=Obtainvalue
End If
End If
ReturnDate=Replace(FormatDate," ","")
ReturnDate=Replace(ReturnDate,"-","")
ReturnDate=Replace(ReturnDate,":","")
ReturnDate=Replace(ReturnDate,"PM","")
ReturnDate=Replace(ReturnDate,"AM","")
ReturnDate=Replace(ReturnDate,"上午","")
ReturnDate=Replace(ReturnDate,"下午","")
FormatCurrentDate=ReturnDate
End Function
'//!====================ContraryDateFunction========================!//
'//函数名:ContraryDateFunction
'//参数:Strvalue
'//作用:反格式化时间函数
Public Function ContraryDateFunction(Strvalue)
End Function
End Class
%>
'//类说明
'//类名:FormatDateClass
'//作用:格式化时间
Class FormatDateClass
'//声明成员变量
Private Obtainvalue '//获取格式化时间值
'//!====================构造函数====================!//
Private Sub Class_InitiaLize()
Obtainvalue=Now '//初始化变量Obtainvalue
End Sub
'//!====================析构函数====================!//
Private Sub Class_Terminate()
Set FormatDateClass=Nothing
End Sub
'//!====================Let属性=====================!//
Public Property Let ObtainDate(Str)
If ISNull(Str)=False Then
If ISDate(Str)=True Then
Obtainvalue=Str
Else
Obtainvalue=Now()
End If
Else
Exit Property
End If
End Property
'//!====================Get属性======================!//
Public Property Get ObtainDate()
ObtainDate=Obtainvalue
End Property
'//!====================FormatDateFunction============!//
'//函数名:FormatDateFunction
'//参数:Obtainvalue,Strtype
'//作用:格式化日期时间
'//被格式化的值
Public Function FormatDateFunction(Strtype)
Dim StrDate,ReturnDate
StrDate=Obtainvalue
If ISNull(StrDate)=True Then
Exit Function
Else
If ISDate(StrDate)=False Then
Exit Function
End If
End If
If Strtype<1 Or Strtype>25 Then
Strtype=1
Else
Strtype=Strtype
End If
Select Case Strtype
'//以年月格式化
Case 1
ReturnDate=Year(StrDate)&"年"&Month(StrDate)&"月"
Case 2
ReturnDate=Year(StrDate)&"-"&Month(StrDate)
Case 3
ReturnDate=Year(StrDate)&"/"&Month(StrDate)
'//以年月日格式化
Case 4
ReturnDate=Year(StrDate)&"年"&Month(StrDate)&"月"&Day(StrDate)&"日"
Case 5
ReturnDate=Year(StrDate)&"-"&Month(StrDate)&"-"&Day(StrDate)
Case 6
ReturnDate=Year(StrDate)&"/"&Month(StrDate)&"/"&Day(StrDate)
Case 7
'//以年月格式化
ReturnDate=Year(StrDate)&"年"&Month(StrDate)&"月"
Case 8
ReturnDate=Year(StrDate)&"-"&Month(StrDate)
Case 9
ReturnDate=Year(StrDate)&"/"&Month(StrDate)
'//以月日格式化
Case 10
ReturnDate=Month(StrDate)&"月"&Day(StrDate)&"日"
Case 11
ReturnDate=Month(StrDate)&"-"&Day(StrDate)
Case 12
ReturnDate=Month(StrDate)&"/"&Day(StrDate)
'//以小时分秒格式化
Case 13
ReturnDate=Hour(StrDate)&"-"&Minute(StrDate)&"-"&Second(StrDate)
Case 14
ReturnDate=Hour(StrDate)&"/"&Minute(StrDate)&"/"&Second(StrDate)
'//以小时分格式化
Case 15
ReturnDate=Hour(StrDate)&"-"&Minute(StrDate)
Case 16
ReturnDate=Hour(StrDate)&"/"&Minute(StrDate)
'//以年月日小时格式化
Case 17
ReturnDate=Year(StrDate)&"年"&Month(StrDate)&"月"&Day(StrDate)&"日"&Minute(StrDate)
Case 18
ReturnDate=Year(StrDate)&"-"&Month(StrDate)&"-"&Day(StrDate)&"-"&Minute(StrDate)
Case 19
ReturnDate=Year(StrDate)&"/"&Month(StrDate)&"/"&Day(StrDate)&"/"&Minute(StrDate)
Case 20
ReturnDate=FormatWeekFunction(1)
Case 21
ReturnDate=FormatWeekFunction(2)
Case 22
ReturnDate=FormatWeekFunction(3)
Case 23
ReturnDate=FormatWeekFunction(4)
Case 24
ReturnDate=FormatWeekFunction(5)
Case Else
Exit Function
End Select
FormatDateFunction=ReturnDate
End Function
'//=======================FormatWeekFunction==========================!//
'//函数名:FormatWeekFunction
'//参数:Strtype
'//作用:格式化星期
'//返回值:被格式化的星期
Public Function FormatWeekFunction(Strtype)
Dim FormatDate,FormatWeek,StrDate
If FormatDateFunction(2)=Date() Then
FormatDate=FormatDateFunction(2)
Else
FormatDate=Date()
End If
If ISNull(Strtype) Then
Exit Function
End If
If ISnull(Obtainvalue)=False And ISDate(Obtainvalue)=True Then
StrDate=Obtainvalue
Else
StrDate=Now()
End If
FormatWeek=FormatWeekvalue(WeekDay(FormatDate))
Select Case Strtype
'//以年月日星期格式化
Case 1
FormatWeekFunction=Year(StrDate)&"年"&Month(StrDate)&"月"&Day(StrDate)&"日 "&FormatWeek
Case 2
FormatWeekFunction=Year(StrDate)&"-"&Month(StrDate)&"-"&Day(StrDate)&"日 "&FormatWeek
Case 3
FormatWeekFunction=Year(StrDate)&"/"&Month(StrDate)&"/"&Day(StrDate)&" "&FormatWeek
'//以年月星期格式化
Case 4
FormatWeekFunction=Year(StrDate)&"年"&Month(StrDate)&"月 "&FormatWeek
Case 5
FormatWeekFunction=Year(StrDate)&"-"&Month(StrDate)&" "&FormatWeek
End Select
End Function
'//!=====================FormatWeekvalue===============================!//
'//函数名:FormatWeekvalue
'//参数:StrFormatvalue
'//返回值:被格式化的星期
Public Function FormatWeekvalue(StrFormatvalue)
If ISNull(StrFormatvalue)=True Then
Exit Function
End If
Select Case StrFormatvalue
Case 1
FormatWeekvalue="星期日"
Case 2
FormatWeekvalue="星期一"
Case 3
FormatWeekvalue="星期二"
Case 4
FormatWeekvalue="星期三"
Case 5
FormatWeekvalue="星期四"
Case 6
FormatWeekvalue="星期五"
Case 7
FormatWeekvalue="星期六"
Case Else
Exit Function
End Select
End Function
'//!======================FormatCurrentDate===========================!//
'//函数名:FormatCurrentDate
'//参数:Strvalue
'//作用:格式化当前时间
'//返回值:被格式化的当前时间
Public Function FormatCurrentDate(Strvalue)
Dim FormatDate,ReturnDate
FormatDate=Strvalue
If ISNull(FormatDate)=True Then
Exit Function
Else
If ISDate(FormatDate)=False Then
FormatDate=Now()
Else
FormatDate=Obtainvalue
End If
End If
ReturnDate=Replace(FormatDate," ","")
ReturnDate=Replace(ReturnDate,"-","")
ReturnDate=Replace(ReturnDate,":","")
ReturnDate=Replace(ReturnDate,"PM","")
ReturnDate=Replace(ReturnDate,"AM","")
ReturnDate=Replace(ReturnDate,"上午","")
ReturnDate=Replace(ReturnDate,"下午","")
FormatCurrentDate=ReturnDate
End Function
'//!====================ContraryDateFunction========================!//
'//函数名:ContraryDateFunction
'//参数:Strvalue
'//作用:反格式化时间函数
Public Function ContraryDateFunction(Strvalue)
End Function
End Class
%>