ASP 如何正确输出 RSS 的 pubDate

作者:vkvi收集 来源: 日期:2008-12-22

'时间转换函数,符合rfc822标准
Function return_RFC822_Date(byVal myDate, byVal TimeZone)
    Dim myDay, myDays, myMonth, myYear
    Dim myHours, myMinutes, mySeconds
    myDate = CDate(myDate)
    myDay = EnWeekDayName(myDate)
    myDays = Right("00" & Day(myDate),2)
    myMonth = EnMonthName(myDate)
    myYear = Year(myDate)
    myHours = Right("00" & Hour(myDate),2)
    myMinutes = Right("00" & Minute(myDate),2)
    mySeconds = Right("00" & Second(myDate),2)
    return_RFC822_Date = myDay & ", " & _
        myDays & " " & _
        myMonth & " " & _
        myYear & " " & _
        myHours & ":" & _
        myMinutes & ":" & _
        mySeconds & " " & _
        TimeZone
End Function
 
 
'星期转换函数
Function EnWeekDayName(InputDate)
    Dim Result
    Select Case WeekDay(InputDate,1)
        Case 1 : Result = "Sun"
        Case 2 : Result = "Mon"
        Case 3 : Result = "Tue"
        Case 4 : Result = "Wed"
        Case 5 : Result = "Thu"
        Case 6 : Result = "Fri"
        Case 7 : Result = "Sat"
    End Select
   
    EnWeekDayName = Result
End Function
 
 
'月份转换函数
Function EnMonthName(InputDate)
    Dim Result
    Select Case Month(InputDate)
        Case 1 : Result = "Jan"
        Case 2 : Result = "Feb"
        Case 3 : Result = "Mar"
        Case 4 : Result = "Apr"
        Case 5 : Result = "May"
        Case 6 : Result = "Jun"
        Case 7 : Result = "Jul"
        Case 8 : Result = "Aug"
        Case 9 : Result = "Sep"
        Case 10 : Result = "Oct"
        Case 11 : Result = "Nov"
        Case 12 : Result = "Dec"
    End Select
   
    EnMonthName = Result
End Function

应用示例

return_RFC822_Date(Now(), "+0800")

你前面那位网友看了:C# 3.0 -扩展方法

▲▲▲嘿,欢迎转载传播本站原创文章,尽量保留来源噢。▲▲▲

文章评论
赞助商们