-
how to add a timestamp to the date in rss page
This is the code i have for an RSS feed which shows all the latest articles from a news weblog. The problem is one of the search engines that index's news is saying that i should add a time stamp, because the code below only shows the date, not the timestamp. This is probably the reason some of the articles get rejected with "date too old" or "date not found".
Can someone show me what to put where? There is more code in the 2 include files if you need to see it. I'm not html literate, so i'd appreciate some help. Thanks in advance.
Code:
<!--#include file="config.asp"-->
<!--#include file="inc_api.asp"-->
<% Dim SQL, RS, NID, TITLE, POSTED, NEWS_LISTING, I_RSS, SUMMARY, RSS_BUILD, TOP_X, X, MODEX, CID
MODEX = APO(Request.QueryString("mode"))
CID = APO(Request.QueryString("cid"))
TOP_X = Trim(Request.QueryString("top"))
IF IS_VALID_ID(CID) = False AND MODEX = "cate" THEN MODEX = ""
IF IS_VALID_ID(TOP_X) = False THEN
TOP_X = 25
ELSE
TOP_X = Cint(TOP_X)
END IF
RSS_BUILD = RSS_BUILD & "<?xml version=""1.0"" encoding=""iso-8859-1"" ?>" & vbcrlf
RSS_BUILD = RSS_BUILD & "<rss version=""2.0"">" & vbcrlf
RSS_BUILD = RSS_BUILD & " <channel>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <title>latest headlines</title>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <link>" & APPLICATION_URL & "</link>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <description>latest section news</description>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <generator>mag RSS</generator>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <language>en-us</language>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <lastBuildDate>" & RFC822(Now(),0) & "</lastBuildDate>" & vbcrlf
IF DB_TO_USE = 1 OR DB_TO_USE = 3 THEN ' MS Access
SELECT CASE Lcase(MODEX)
CASE "recent" ' Most recent
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) ORDER BY nm_tbl_news.ID DESC"
CASE "pop" ' Most accessed
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) ORDER BY fldVIEWS DESC"
CASE "all" ' All articles
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) ORDER BY nm_tbl_news.ID DESC"
CASE "highlighted"
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) AND (fldHIGHLIGHT = 1) ORDER BY nm_tbl_news.ID DESC"
CASE "cate"
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) AND (nm_tbl_news.ID IN (SELECT fldNEWS_ID FROM nm_tbl_news_cate WHERE fldCATE_ID = " & CID & ")) ORDER BY nm_tbl_news.ID DESC"
CASE ELSE ' Any other mode not listed above
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) ORDER BY nm_tbl_news.ID DESC"
END SELECT
ELSE
SELECT CASE Lcase(MODEX)
CASE "recent" ' Most recent
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (GetDate() BETWEEN fldPOSTED AND fldEXPIRES) ORDER BY nm_tbl_news.ID DESC"
CASE "pop" ' Most accessed
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (GetDate() BETWEEN fldPOSTED AND fldEXPIRES) ORDER BY fldVIEWS DESC"
CASE "all" ' All articles
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (GetDate() BETWEEN fldPOSTED AND fldEXPIRES) ORDER BY nm_tbl_news.ID DESC"
CASE "highlighted"
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (GetDate() BETWEEN fldPOSTED AND fldEXPIRES) AND (fldHIGHLIGHT = 1) ORDER BY nm_tbl_news.ID DESC"
CASE "cate"
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (GetDate() BETWEEN fldPOSTED AND fldEXPIRES) AND (nm_tbl_news.ID IN (SELECT fldNEWS_ID FROM nm_tbl_news_cate WHERE fldCATE_ID = " & CID & ")) ORDER BY nm_tbl_news.ID DESC"
CASE ELSE ' Any other mode not listed above
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (GetDate() BETWEEN fldPOSTED AND fldEXPIRES) ORDER BY nm_tbl_news.ID DESC"
END SELECT
END IF
X = 0
Call OPEN_DB()
Set RS = Server.CreateObject("ADODB.Recordset")
RS.LockType = 1
RS.CursorType = 0
RS.Open SQL, MyConn
WHILE NOT RS.EOF
X = X + 1
IF Cint(X) =< TOP_X THEN
NID = PREPARE_XML(RS("NID"))
TITLE = PREPARE_XML(RS("TITLE"))
POSTED = PREPARE_XML(RS("POSTED"))
SUMMARY = PREPARE_XML(RS("fldSUMMARY"))
RSS_BUILD = RSS_BUILD & "<item>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <title>" & PROCESS_SHORTCUTS_RSS(False, TITLE) & "</title>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <link>" & PREPARE_XML(APPLICATION_URL) & "mainpage.asp?ID=" & NID & "</link>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <pubDate>" & RFC822(POSTED,0) & "</pubDate>" & vbcrlf
RSS_BUILD = RSS_BUILD & " <description>" & PROCESS_SHORTCUTS_RSS(False, SUMMARY) & "</description>" & vbcrlf
RSS_BUILD = RSS_BUILD & "</item>" & vbcrlf
END IF
RS.MoveNext
WEND
RS.Close
Set RS = Nothing
MyConn.Close
Set MyConn = Nothing
RSS_BUILD = RSS_BUILD & " </channel>" & vbcrlf
RSS_BUILD = RSS_BUILD & "</rss>" & vbcrlf
RSS_BUILD = RSS_BUILD & "<!-- Generated by mage -->" & vbcrlf
FUNCTION PROCESS_SHORTCUTS_RSS(blOPEN, TEXT)
Dim SQL, RS, strRETURNED_DATA, EOF_VAL, intNUM_COL, intNUM_ROW, intROW_COUNTER, strSIGN, strIMAGE
SQL = "SELECT fldSIGN, fldIMAGE FROM nm_tbl_library WHERE fldACTIVE = 1"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.LockType = 1
RS.CursorType = 0
RS.Open SQL, MyConn
IF NOT RS.EOF THEN
strRETURNED_DATA = RS.getrows
ELSE
EOF_VAL = True
END IF
RS.close
Set RS = Nothing
IF Not EOF_VAL = True Then
intNUM_COL=ubound(strRETURNED_DATA,1)
intNUM_ROW=ubound(strRETURNED_DATA,2)
FOR intROW_COUNTER = 0 TO intNUM_ROW
strSIGN = Trim(strRETURNED_DATA(0,intROW_COUNTER))
strIMAGE = Trim(strRETURNED_DATA(1,intROW_COUNTER))
TEXT = Replace(TEXT, strSIGN, "")
NEXT
END IF
PROCESS_SHORTCUTS_RSS = TEXT
END FUNCTION
With Response
.Buffer = True
.ContentType = "text/xml"
.write(RSS_BUILD)
End With
%>
-
changing the date to adjust for servers in differnt countries
I've decided not to fiddle with the system wide thing to change the time. Instead i'll just change the time on the comments if i can. I'd like to add 2 hours and to be able to adjust time in the future, depending on daylight saving. Below is the code for the comments, and the
Code:
<%=FormatDateTime(C_DATE,3)%>
shows the time like this
"4:34:20 AM"
Ironically, the comments show the time, but they have a separate database. The news database only shows the date, not the time. If there is a simple way to add the time in the news articles database, then i'd like to try it. Otherwise i'll do as i said above and just adjust the comments time.
Just to clarify the layout: The comments are added to the end of the article, by readers, and they open up in a separate small window from a link . Headlines of the comments show below the news article. Each headline shows the title, and date and time posted.
In other words, on the public side, i'd like the comments to show another time, 2 hours ahead. I don't mind if the database contains the orignal server time, since it won't show on the public sides. But if it's easier to adjust the database time then i'll do that.
Thanks in advance for any help.
--------------------
Code:
SQL = "SELECT ID, fldNAME, fldCOMMENT, fldDATE, fldSUBJECT, fldM_ID, fldCITY, fldCOUNTRY, fldALLOW, fldEMAIL FROM nm_tbl_comment WHERE fldNEWS_ID = " & NID & " ORDER BY ID ASC"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.LockType = 1
RS.CursorType = 0
RS.Open SQL, MyConn
WHILE NOT RS.EOF
CCOUNT = CCOUNT + 1
C_ID = trim(RS("ID"))
C_NAME = trim(RS("fldNAME"))
C_COMMENT = trim(RS("fldCOMMENT"))
C_SUBJECT = trim(RS("fldSUBJECT"))
C_M_ID = trim(RS("fldM_ID"))
C_DATE = trim(RS("fldDATE"))
C_CITY = trim(RS("fldCITY"))
C_COUNTRY = trim(RS("fldCOUNTRY"))
C_ALLOW_E = trim(RS("fldALLOW"))
C_EMAIL = trim(RS("fldEMAIL"))
%>
this is the relevant part of the code
Code:
<td width="100%"><%IF Trim(C_ALLOW_E) = "1" THEN%><a class="linkComment" href="file/_mail.asp?ID=<%=C_ID%>&AID=<%=NID%>" onClick="NewWindow(this.href,'name','450','410','Yes');return false;">
<img src="blogs/img_ss.gif" width="14" height="9" alt="" border="0" /></a> <%END IF%> <span style="color: #4169E1; font-size: 10px"><%= C_NAME %> - <%=C_CITY%>-<%=C_COUNTRY%> - <%=FormatDateTime(C_DATE,2)%>-<%=FormatDateTime(C_DATE,3)%> </span></td>
Similar Threads
-
Replies: 0
Last Post: 08-30-2007, 03:51 PM
-
By burnerofhells in forum Java
Replies: 3
Last Post: 11-06-2005, 03:26 AM
-
By nicolas in forum VB Classic
Replies: 1
Last Post: 12-06-2002, 07:17 PM
-
Replies: 2
Last Post: 10-30-2002, 08:28 PM
-
By Fabio Luis De Paoli in forum Java
Replies: 0
Last Post: 03-03-2001, 01:12 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks