RSS 파싱해서 DB에 저장하려고 하다보니 pubDate 값이 GMT로 되어 있어서 한참을 알아보다가
정규식으로 처리하는 방법을 찾았다.
<%
Function parseRSSDate(sRSSDate)
' take RFC822-formatted date string and return VBScript date object
' ie: "Fri, 13 Jun 2008 16:33:50 GMT"
dim sDay, sMonthName, sMonthNum, sYear, sHour, sMinute, sSecond
dim oRE, oMatches, oMatch
dim sDate, oDate
Set oRE = new regexp
oRE.IgnoreCase = True
oRE.Global = True
oRE.Pattern = "^([A-Za-z]{3}),\s([0-9]{1,2})\s([A-Za-z]{3})\s([0-9]{4})\s([0-9]{2}):([0-9]{2}):([0-9]{2})"
Set oMatches = oRE.Execute(sRSSDate)
If oMatches.count > 0 Then
set oMatch = oMatches(0)
sDay = oMatch.SubMatches(1)
sMonthName = oMatch.SubMatches(2)
sMonthNum = monthVal(sMonthName)
sYear = oMatch.SubMatches(3)
sHour = oMatch.SubMatches(4)
sMinute = oMatch.SubMatches(5)
sSecond = oMatch.SubMatches(6)
sDate = sYear &"-"& sMonthNum &"-"& sDay &" "& sHour &":"& sMinute &":"& sSecond
oDate = cDate(sDate)
Set oMatch = Nothing
End If
Set oMatches = Nothing
Set oRE = Nothing
parseRSSDate = oDate
End Function
Function monthVal(sMonthName)
' return month number (1-12) from month name
Dim rv
Dim aMonths : aMonths = Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
For i = 0 To uBound(aMonths)
If sMonthName = aMonths(i) Then rv = i+1
next
monthVal = rv
End Function
%>
위 소스는 아래 출처에서 날짜만 가져오던 소스를 시간까지 가져오게 수정하였다.
출처:
http://stackoverflow.com/questions/1293598/rfc-32-date-format-to-short-date-mm-dd-yyyy-with-asp-classic