Fra RFC-822 til alm. date
Hej Eksperter,Jeg har noget kode som konverterer rss feed ind til alm. html.
Jeg har dog lidt problemer med rss datoen(Wed, 13 May 2009 13:56:15 +0200:) som jeg gerne vil have lavet om til eks. 13-05-2009.
Jeg har fundet denne funktion på nettet:
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
if rv < 10 then
monthVal = "0" & rv
else
monthVal = rv
End if
end function
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 = sMonthNum & "/" & sDay & "/" & sYear
oDate = cDate(sDate)
set oMatch = nothing
end if
set oMatches = nothing
set oRE = nothing
parseRSSDate = oDate
end function
men hvis jeg kalder parseRSSDate med datoen i loopet vil loopet blot stoppe og den samme nyhed vil komme ud hele tiden. Kan i hjælpe? Enten med anden funktion til at konvertere datoen eller hjælpe mig med denne?
