<%Response.AddHeader "ContentType","application/xml"%><?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>SEEDA Press Releases</title>
<link>http://www.seeda.co.uk/feed/pressreleases.xml</link>
<description>The latest news from SEEDA, The South East England Development Agency</description>
<lastBuildDate><%=GetRFC822(now())%></lastBuildDate>
<language>en-us</language>
<atom:link href="http://www.seeda.co.uk/feed/pressreleases.xml" rel="self" type="application/rss+xml" />
<%=getResultSet()%>
</channel>
</rss>


<%

Function LastWeek()
	Dim strOut, dDate
	dDate = dateAdd("d", -7 ,now())
	strOut = year(dDate) & "-" & right("0" & month(dDate),2) & "-" & right("0" & day(dDate),2) & " 00:00:00"
	LastWeek = strOut
End Function


Function getResultSet()
	Dim strThisScope, strQuery, strOut
	set Q = CreateObject("ixsso.Query")
	Q.catalog ="SEEDA"
	Q.SortBy  = "filename[d]"
	Q.Columns = "DocTitle, vpath, path, filename, size, create, write, characterization, rank"
	Q.MaxRecords = 10 
	
	set util = CreateObject("IXSSO.Util")
	util.AddScopeToQuery Q, "/News_&_Events/Press_Releases", "deep"
	Q.Query = "#filename *.asp and ( @Contents like SEEDA ) and @create > " & LastWeek() & " and not @filename index.asp "
	Q.Query = "#filename *.asp and ( @Contents like SEEDA ) and not @filename index.asp "
	
	
	on error resume next
	set RS = Q.CreateRecordSet("nonsequential")
		if rs.Eof Then
			strOut = strOut &  "No results"	
		Else
			rs.MoveFirst
			do While NOT rs.Eof
				strOut = strOut & FormatResult(rs)
				rs.MoveNext
			Loop
		End If
	rs.Close
	Set rs = nothing
	Set util = nothing
	Set q = nothing
	getResultSet = strOut
End Function


Function FormatResult(rs)
	Dim strOut, startPos, lastSpacePos
	startPos = inStr(rs("characterization"),"Release date:")+25
	lastSpacePos = inStrRev(rs("characterization")," ")
	strOut=strOut & "<item>" & vbCrLf
	strOut=strOut & "<title><![CDATA[" & replace(rs("DocTitle"),"SEEDA - News - ","") & " - " & mid(rs("characterization"),startPos-11,10) & "]]></title>" & vbCrLf
	strOut=strOut & "<description><![CDATA[" & mid(replace(left(rs("characterization"),lastSpacePos),"&rsquo;","'"),startPos) & "...]]></description>" & vbCrLf
	strOut=strOut & "<link><![CDATA[http://www.seeda.co.uk" & rs("vpath") & "]]></link>" & vbCrLf
	strOut=strOut & "<guid><![CDATA[http://www.seeda.co.uk" & rs("vpath") & "]]></guid>" & vbCrLf	
	strOut=strOut & "<atom:link href=""http://www.seeda.co.uk/feed/pressreleases.xml"" rel=""self"" type=""application/rss+xml"" />" & vbCrLfn
	strOut=strOut & "</item>" & vbCrLf
	FormatResult = strOut
End Function

Function getSize(rs)
	Dim strOut
	if CLng(rs("size")) > 1000 Then
		strOut = strOut & "&nbsp;(" & Fix(CLng(rs("size"))/1000) & "kB)"
	Else
		strOut = strOut & "&nbsp;(1kB)"
	End if
	getSize = strOut
End Function

	Function GetRFC822(dt)
        'ie: Sat 14 Jun 2008 07:43:35 EST
		strOut = WeekDayName(WeekDay(dt),1) & ", "
		strOut = strOut & Day(dt) & " "
		strOut = strOut & MonthName(Month(dt),1) & " "
		strOut = strOut & Year(dt) & " "
		strOut = strOut & right("0" & Hour(dt),2) & ":"
		strOut = strOut & right("0" & minute(dt),2) & ":"
		strOut = strOut & right("0" & Second(dt),2) & " GMT"
		GetRFC822 = strOut
    End Function

    Private Function GetTimeZone()
        Dim strOut, i
        Dim tz()
		tx = TimeZone.CurrentTimeZone.StandardName.Split(" ")
        For i = 0 To UBound(tz)
            strOut = strOut & Left(tz(i), 1)
        Next
        GetTimeZone = strOut
    End Function

    Private Function GetMonth(month)
        Select Case month
            Case 1
                Return "Jan"
            Case 2
                Return "Feb"
            Case 3
                Return "Mar"
            Case 4
                Return "Apr"
            Case 5
                Return "May"
            Case 6
                Return "Jun"
            Case 7
                Return "Jul"
            Case 8
                Return "Aug"
            Case 9
                Return "Sep"
            Case 10
                Return "Oct"
            Case 11
                Return "Nov"
            Case 12
                Return "Dec"
            Case Else
                Return ""
        End Select
    End Function

%>


