karen987
03-16-2008, 04:16 AM
I have a news weblog with asp pages. I need to make a system wide change so that the articles are showing 2 hours ahead in the public view. This is because the server is in another country. I'd need to be able to adjust for daylight saving.
I think the common file for this is the include file "config.asp", and i have included the code below.
Here is a page example which shows the political news in posted date order, latest on top. Call it "page.asp"
<%Dim iStart, iOffset, SQL, RS, EOF_VAL, strRETURNED_DATA, iRows, iCols, iStop, iRowLoop, strPREV_LINK, strNEXT_LINK, CID, CNAME, AUTHOR, NID, SUMMARY, IMAGE, CATEGORIES, TITLE, POSTED, XI
CID = Trim(Request.QueryString("CID"))
CNAME = Request("CNAME")
iStart = Request.QueryString("Start")
iOffset = Request.QueryString("Offset")
IF IS_VALID_ID(CID) THEN
If Not IsNumeric(iStart) or Len(iStart) = 0 then
iStart = 0
Else
iStart = CInt(iStart)
End If
If Not IsNumeric(iOffset) or Len(iOffset) = 0 then
iOffset = ALL_ARTICLES_PAGE_SIZE
Else
iOffset = Cint(iOffset)
End If
IF DB_TO_USE = 1 OR DB_TO_USE = 3 THEN
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldSUMMARY AS SUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_agent.fldNAME AS ANAME, nm_tbl_news.fldPOSTED AS POSTED 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"
ELSE
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldSUMMARY AS SUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_agent.fldNAME AS ANAME, nm_tbl_news.fldPOSTED AS POSTED 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"
END IF
Call OPEN_DB()
Set RS = MyConn.Execute(SQL)
IF NOT RS.EOF THEN
strRETURNED_DATA = RS.getrows
EOF_VAL = False
ELSE
EOF_VAL = True
END IF
RS.close
Set RS = Nothing
' Get settings
Dim DATE_F
DATE_F = GET_SETTINGS(False, "fldDATE_F")
IF not EOF_VAL = True THEN
iRows = UBound(strRETURNED_DATA, 2)
iCols = UBound(strRETURNED_DATA, 1)
If iRows > (iOffset + iStart) Then
iStop = iOffset + iStart - 1
Else
iStop = iRows
End If
FOR iRowLoop = iStart to iStop
NID = strRETURNED_DATA(0, iRowLoop)
SUMMARY = strRETURNED_DATA(1, iRowLoop)
IMAGE = strRETURNED_DATA(2, iRowLoop)
TITLE = strRETURNED_DATA(3, iRowLoop)
AUTHOR = strRETURNED_DATA(4, iRowLoop)
POSTED = strRETURNED_DATA(5, iRowLoop)
TITLE = PROCESS_SHORTCUTS(False, TITLE)
SUMMARY = PROCESS_SHORTCUTS(False, SUMMARY)
CATEGORIES = GET_CATES(NID)
%>
<table cellpadding="2" cellspacing="0" border="0" width="100%"><tr>
<td><div align="justify"><a href="page.asp?ID=<%=NID%>" class="aTITLE"><%= TITLE %></a></div></td>
</tr>
<tr><td colspan="2" class="divPOSTEDON"><div align="justify"><%= FormatDateTime(POSTED,DATE_F) %>
<% IF SHOW_AUTHOR = True THEN %>
By:<%= AUTHOR %>
<% Else %>
<% End If %>
</div></td></tr>
<tr><td colspan="2" class="tdSUMMARY"><div align="justify">
<%IF NOT (IMAGE = "" OR IsNull(IMAGE)) THEN%>
<img src="<%=IMAGE%>" width="50" height="50" border="1" align="left" />
<% END IF %>
<%= SUMMARY %></div></td></tr>
</table>
<div align="justify"><hr width="100%" size="1" style="color: gray;height: 1px;width: 100%;" />
<%
NEXT
' Close DB
MyConn.close
Set MyConn = Nothing
If iStart > 0 Then
strPREV_LINK = "<A class=""clsPAGING"" HREF=""politics.asp?Start=" & iStart-iOffset & "&Offset=" & iOffset & "&CID=" & CID & """>Previous " & iOffset & "</A>"
Else
strPREV_LINK = " "
End If
If iStop < iRows Then
strNEXT_LINK = " <A class=""clsPAGING"" HREF=""politics.asp?Start=" & iStart+iOffset & "&Offset=" & iOffset & "&CID=" & CID & """>Next " & iOffset & "</A>"
Else
strNEXT_LINK = " "
End If %>
<table width="100%" align="center" cellpadding="2" cellspacing="0" border="0"><tr class="trPAGING">
<td width="50%" align="left"><%=strPREV_LINK%></td>
<td width="50%" align="right"><%=strNEXT_LINK%></td>
</tr></table>
<%ELSE%>
<table width="100%" align="center" cellpadding="2" cellspacing="0" border="0"><tr><td>No political news yet</td></tr></table>
<%END IF%>
<%END IF%>
and i believe this is the common code which is used for all the dates, and it's in the include file which is included in the header file and it's called "config.asp". I have only shown the code which i think is relevant to the dating of articles below:
Is there something i can add below to make a system wide change of 2 hours ahead? I'd need to be able to adjust for daylight, so i presume it's a matter of changing only the number for the hours somewhere.
config.asp
' Assemble date value
FUNCTION ASEMBLE_DATE_FORMAT(sDAY, sMONTH, sYEAR)
Dim DATE_FORMAT, sDATE
DATE_FORMAT = 1 ' US Locale
SELECT CASE DATE_FORMAT
CASE 1
sDATE = sMONTH & "/" & sDAY & "/" & sYEAR
CASE ELSE
sDATE = sMONTH & "/" & sDAY & "/" & sYEAR
END SELECT
ASEMBLE_DATE_FORMAT = sDATE
END FUNCTION
END SUB
%>
and this
It does actually say, that there is no need to modify it, but that may be because the other things on the config.asp page are customisable, ie. email, and number of articles etc.
config.asp
<% '// NO NEED TO MODIFY ANYTHING BELOW
FUNCTION CNT_DATE(sDATE)
IF IsDate(sDATE) = True THEN
SELECT CASE DATE_FORMAT
CASE 1 'YYYYMMDD
CNT_DATE = Year(sDATE) & Right(Cstr(Month(sDATE) + 100),2) & Right(Cstr(Day(sDATE) + 100),2)
CASE 2 'YYYY-MM-DD
CNT_DATE = Year(sDATE) & "-" & Right(Cstr(Month(sDATE) + 100),2) & "-" & Right(Cstr(Day(sDATE) + 100),2)
CASE 101 'mm/dd/yy
CNT_DATE = Right(Cstr(Month(sDATE) + 100),2) & "/" & Right(Cstr(Day(sDATE) + 100),2) & "/" & Right(Cstr(Year(sDATE)),2)
CASE 102 'yy.mm.dd
CNT_DATE = Right(Cstr(Year(sDATE)),2) & "." & Right(Cstr(Month(sDATE) + 100),2) & "." & Right(Cstr(Day(sDATE) + 100),2)
CASE 103 'dd/mm/yy
CNT_DATE = Right(Cstr(Day(sDATE) + 100),2) & "/" & Right(Cstr(Month(sDATE) + 100),2) & "/" & Right(Cstr(Year(sDATE)),2)
CASE 104 'dd.mm.yy
CNT_DATE = Right(Cstr(Day(sDATE) + 100),2) & "." & Right(Cstr(Month(sDATE) + 100),2) & "." & Right(Cstr(Year(sDATE)),2)
CASE 105 'dd-mm-yy
CNT_DATE = Right(Cstr(Day(sDATE) + 100),2) & "-" & Right(Cstr(Month(sDATE) + 100),2) & "-" & Right(Cstr(Year(sDATE)),2)
CASE 110 'mm-dd-yy
CNT_DATE = Right(Cstr(Month(sDATE) + 100),2) & "-" & Right(Cstr(Day(sDATE) + 100),2) & "-" & Right(Cstr(Year(sDATE)),2)
CASE 111 'yy/mm/dd
CNT_DATE = Right(Cstr(Year(sDATE)),2) & "/" & Right(Cstr(Month(sDATE) + 100),2) & "/" & Right(Cstr(Day(sDATE) + 100),2)
CASE 112 'yymmdd
CNT_DATE = Right(Cstr(Year(sDATE)),2) & Right(Cstr(Month(sDATE) + 100),2) & Right(Cstr(Day(sDATE) + 100),2)
END SELECT
ELSE
CNT_DATE = Null
END IF
END FUNCTION
%>
Much appreciated, if anyone could give me some advice.
I think the common file for this is the include file "config.asp", and i have included the code below.
Here is a page example which shows the political news in posted date order, latest on top. Call it "page.asp"
<%Dim iStart, iOffset, SQL, RS, EOF_VAL, strRETURNED_DATA, iRows, iCols, iStop, iRowLoop, strPREV_LINK, strNEXT_LINK, CID, CNAME, AUTHOR, NID, SUMMARY, IMAGE, CATEGORIES, TITLE, POSTED, XI
CID = Trim(Request.QueryString("CID"))
CNAME = Request("CNAME")
iStart = Request.QueryString("Start")
iOffset = Request.QueryString("Offset")
IF IS_VALID_ID(CID) THEN
If Not IsNumeric(iStart) or Len(iStart) = 0 then
iStart = 0
Else
iStart = CInt(iStart)
End If
If Not IsNumeric(iOffset) or Len(iOffset) = 0 then
iOffset = ALL_ARTICLES_PAGE_SIZE
Else
iOffset = Cint(iOffset)
End If
IF DB_TO_USE = 1 OR DB_TO_USE = 3 THEN
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldSUMMARY AS SUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_agent.fldNAME AS ANAME, nm_tbl_news.fldPOSTED AS POSTED 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"
ELSE
SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldSUMMARY AS SUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_agent.fldNAME AS ANAME, nm_tbl_news.fldPOSTED AS POSTED 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"
END IF
Call OPEN_DB()
Set RS = MyConn.Execute(SQL)
IF NOT RS.EOF THEN
strRETURNED_DATA = RS.getrows
EOF_VAL = False
ELSE
EOF_VAL = True
END IF
RS.close
Set RS = Nothing
' Get settings
Dim DATE_F
DATE_F = GET_SETTINGS(False, "fldDATE_F")
IF not EOF_VAL = True THEN
iRows = UBound(strRETURNED_DATA, 2)
iCols = UBound(strRETURNED_DATA, 1)
If iRows > (iOffset + iStart) Then
iStop = iOffset + iStart - 1
Else
iStop = iRows
End If
FOR iRowLoop = iStart to iStop
NID = strRETURNED_DATA(0, iRowLoop)
SUMMARY = strRETURNED_DATA(1, iRowLoop)
IMAGE = strRETURNED_DATA(2, iRowLoop)
TITLE = strRETURNED_DATA(3, iRowLoop)
AUTHOR = strRETURNED_DATA(4, iRowLoop)
POSTED = strRETURNED_DATA(5, iRowLoop)
TITLE = PROCESS_SHORTCUTS(False, TITLE)
SUMMARY = PROCESS_SHORTCUTS(False, SUMMARY)
CATEGORIES = GET_CATES(NID)
%>
<table cellpadding="2" cellspacing="0" border="0" width="100%"><tr>
<td><div align="justify"><a href="page.asp?ID=<%=NID%>" class="aTITLE"><%= TITLE %></a></div></td>
</tr>
<tr><td colspan="2" class="divPOSTEDON"><div align="justify"><%= FormatDateTime(POSTED,DATE_F) %>
<% IF SHOW_AUTHOR = True THEN %>
By:<%= AUTHOR %>
<% Else %>
<% End If %>
</div></td></tr>
<tr><td colspan="2" class="tdSUMMARY"><div align="justify">
<%IF NOT (IMAGE = "" OR IsNull(IMAGE)) THEN%>
<img src="<%=IMAGE%>" width="50" height="50" border="1" align="left" />
<% END IF %>
<%= SUMMARY %></div></td></tr>
</table>
<div align="justify"><hr width="100%" size="1" style="color: gray;height: 1px;width: 100%;" />
<%
NEXT
' Close DB
MyConn.close
Set MyConn = Nothing
If iStart > 0 Then
strPREV_LINK = "<A class=""clsPAGING"" HREF=""politics.asp?Start=" & iStart-iOffset & "&Offset=" & iOffset & "&CID=" & CID & """>Previous " & iOffset & "</A>"
Else
strPREV_LINK = " "
End If
If iStop < iRows Then
strNEXT_LINK = " <A class=""clsPAGING"" HREF=""politics.asp?Start=" & iStart+iOffset & "&Offset=" & iOffset & "&CID=" & CID & """>Next " & iOffset & "</A>"
Else
strNEXT_LINK = " "
End If %>
<table width="100%" align="center" cellpadding="2" cellspacing="0" border="0"><tr class="trPAGING">
<td width="50%" align="left"><%=strPREV_LINK%></td>
<td width="50%" align="right"><%=strNEXT_LINK%></td>
</tr></table>
<%ELSE%>
<table width="100%" align="center" cellpadding="2" cellspacing="0" border="0"><tr><td>No political news yet</td></tr></table>
<%END IF%>
<%END IF%>
and i believe this is the common code which is used for all the dates, and it's in the include file which is included in the header file and it's called "config.asp". I have only shown the code which i think is relevant to the dating of articles below:
Is there something i can add below to make a system wide change of 2 hours ahead? I'd need to be able to adjust for daylight, so i presume it's a matter of changing only the number for the hours somewhere.
config.asp
' Assemble date value
FUNCTION ASEMBLE_DATE_FORMAT(sDAY, sMONTH, sYEAR)
Dim DATE_FORMAT, sDATE
DATE_FORMAT = 1 ' US Locale
SELECT CASE DATE_FORMAT
CASE 1
sDATE = sMONTH & "/" & sDAY & "/" & sYEAR
CASE ELSE
sDATE = sMONTH & "/" & sDAY & "/" & sYEAR
END SELECT
ASEMBLE_DATE_FORMAT = sDATE
END FUNCTION
END SUB
%>
and this
It does actually say, that there is no need to modify it, but that may be because the other things on the config.asp page are customisable, ie. email, and number of articles etc.
config.asp
<% '// NO NEED TO MODIFY ANYTHING BELOW
FUNCTION CNT_DATE(sDATE)
IF IsDate(sDATE) = True THEN
SELECT CASE DATE_FORMAT
CASE 1 'YYYYMMDD
CNT_DATE = Year(sDATE) & Right(Cstr(Month(sDATE) + 100),2) & Right(Cstr(Day(sDATE) + 100),2)
CASE 2 'YYYY-MM-DD
CNT_DATE = Year(sDATE) & "-" & Right(Cstr(Month(sDATE) + 100),2) & "-" & Right(Cstr(Day(sDATE) + 100),2)
CASE 101 'mm/dd/yy
CNT_DATE = Right(Cstr(Month(sDATE) + 100),2) & "/" & Right(Cstr(Day(sDATE) + 100),2) & "/" & Right(Cstr(Year(sDATE)),2)
CASE 102 'yy.mm.dd
CNT_DATE = Right(Cstr(Year(sDATE)),2) & "." & Right(Cstr(Month(sDATE) + 100),2) & "." & Right(Cstr(Day(sDATE) + 100),2)
CASE 103 'dd/mm/yy
CNT_DATE = Right(Cstr(Day(sDATE) + 100),2) & "/" & Right(Cstr(Month(sDATE) + 100),2) & "/" & Right(Cstr(Year(sDATE)),2)
CASE 104 'dd.mm.yy
CNT_DATE = Right(Cstr(Day(sDATE) + 100),2) & "." & Right(Cstr(Month(sDATE) + 100),2) & "." & Right(Cstr(Year(sDATE)),2)
CASE 105 'dd-mm-yy
CNT_DATE = Right(Cstr(Day(sDATE) + 100),2) & "-" & Right(Cstr(Month(sDATE) + 100),2) & "-" & Right(Cstr(Year(sDATE)),2)
CASE 110 'mm-dd-yy
CNT_DATE = Right(Cstr(Month(sDATE) + 100),2) & "-" & Right(Cstr(Day(sDATE) + 100),2) & "-" & Right(Cstr(Year(sDATE)),2)
CASE 111 'yy/mm/dd
CNT_DATE = Right(Cstr(Year(sDATE)),2) & "/" & Right(Cstr(Month(sDATE) + 100),2) & "/" & Right(Cstr(Day(sDATE) + 100),2)
CASE 112 'yymmdd
CNT_DATE = Right(Cstr(Year(sDATE)),2) & Right(Cstr(Month(sDATE) + 100),2) & Right(Cstr(Day(sDATE) + 100),2)
END SELECT
ELSE
CNT_DATE = Null
END IF
END FUNCTION
%>
Much appreciated, if anyone could give me some advice.