Currently unable to get my rss feed to validate through W3C RSS Validator. It seems there's a problem with the time/date. If you click the W3C link it'll show the errors. When I comment out the date it works fine but the date is kinda crucial!!
Here's the original script:
include "db.php";
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("cache-control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: text/xml");
print "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
?>
<rss version="2.0">
<channel>
<title>MediWales Events</title>
<description>The latest Events, updates and announcements from MediWales.</description>
<link>http://www.mediwales.com</link>
<copyright>Copyright 2011 MediWales.</copyright>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<language>en-us</language>
<lastBuildDate><? print date("D, d M Y H:i:s"); ?> 0000</lastBuildDate>
<managingEditor>info#mediwales.com</managingEditor>
<pubDate><? print date("D, d M Y H:i:s"); ?> 0000</pubDate>
<webMaster>info#mediwales.com</webMaster>
<generator>codeworks rss script (1.0.0)</generator>
<image>
<url>http://mediwales.com/login/uploaded/template/logo.png</url>
<title>MediWales Website</title>
<link>http://www.mediwales.com</link>
<description>The latest Events, updates and announcements from MediWales.</description>
<width>144</width>
<height>52</height>
</image>
<?
$latestnews = mysql_query("SELECT myevents.*, myevents_dates.datefrom from myevents, myevents_dates WHERE myevents_dates.datefrom >= CURDATE() AND myevents.id = myevents_dates.eventid order by myevents_dates.datefrom");
while ($news = mysql_fetch_assoc($latestnews)) {
$datetime = explode(" ",$news[datefrom]);
$date = explode("-",$datetime[0]);
$time = explode(":",$datetime[1]);
$news[description] = strip_tags($news[description]);
$news[description] = htmlspecialchars($news[description]);
echo "<item>";
echo "<title>".mb_convert_encoding(htmlspecialchars($news[title]),"US-ASCII")."</title>";
echo "<description>".mb_convert_encoding(substr($news[description],0, 250),"US-ASCII")."</description>";
echo "<link>http://www.mediwales.com/index.php?id=4&nid=$news[id]</link>";
echo "<pubDate>".date('D, d M Y H:i:s O', mktime($time[0],$time[1],$time[2],$date[1],$date[2],$date[0]))."</pubDate>";
echo "</item>";
}
?>
</channel>
</rss>
Notice that the only error is in the line 56:
nbsp;&</description>
should be:
nbsp;&</description>
The problem is that you are calling htmlspecialchars and then substr, so the last & gets truncated to &, and that makes your feed invalid. Call substr first and htmlspecialchars last, to fix this.
The other things ("Email address is missing real name", "item should contain a guid element") are just recomendations: you should follow them because they are good ideas, but they would caise the feed to fail the validation.
There are a number of other errors you'll need to fix (like cutting off in the middle of an HTML entity). But they provide a Help link for each one.
In specific reference to the date error, if you follow their Help link, you'll see that one of the possible reasons for this warning is that a date is in the future. The date they're complaining about is "Implausible date: Mon, 07 Mar 2011 00:00:00 +0000". Today is 1 Mar 2011, so 7 Mar 2011 is indeed in the future.
If you continue reading their Help link, they explain why this is a problem. The fix is not to include future dates in your feed.
I think they're complaining about the fact that you're using a date that's in the future.
If so, that is not, imho, a reason to declare your feed invalid. Real-world publications often have publication dates in the future.
The spec, which is the actual authority on this doesn't say there's anything wrong with pubdates in the future.
http://cyber.law.harvard.edu/rss/rss.html
Validators can have bugs too. :-)
I've temporarily solved the problem by removing some html characters on my actual website so the feed isn't grabbing them.
I know the problem may arise when we grab the next set of feeds but too rushed to fix at the moment.
Related
I can't seem to get the list function to work when I pass in a string to kramdown:
For example, this is my text:
email_body = "Hi, Tim! Hopefully you get this. I just got your email address. \n\n My email is x#xcom. \n\n For example, you could tell me: * 3 hours from now\n * 2 days from now at 5pm\n * Wednesday afternoon\n"
email_body = Kramdown::Document.new(email_body).to_html
email_body = "<p>Hi, Tim! Hopefully you get this. I just got your email address. \n\n My email is x#xcom. \n\n For example, you could tell me: * 3 hours from now\n * 2 days from now at 5pm\n * Wednesday afternoon\n</p>"
I can't get it to turn into proper HTML based on Markdown/kramdown (e.g. insert <ul> and proper line breaks.
It might be easier if we took your body text and formatted it as a heredoc:
email_body = <<BODY
Hi, Tim! Hopefully you get this. I just got your email address.
My email is x#xcom.
For example, you could tell me: * 3 hours from now
* 2 days from now at 5pm
* Wednesday afternoon
BODY
Notice that each of your subsequent lines start with a space? Normal paragraphs should not be indented. Also to start a list you need a blank line like starting new paragraphs. So as a heredoc what you actually want looks like:
email_body = <<BODY
Hi, Tim! Hopefully you get this. I just got your email address.
My email is x#xcom.
For example, you could tell me:
* 3 hours from now
* 2 days from now at 5pm
* Wednesday afternoon
BODY
Or as a single line: email_body_single_line = "Hi, Tim! Hopefully you get this. I just got your email address.\n\nMy email is x#xcom.\n\nFor example, you could tell me:\n\n* 3 hours from now\n* 2 days from now at 5pm\n* Wednesday afternoon\n"
Then you get closer to your expected output:
output = Kramdown::Document.new(email_body).to_html
=> "<p>Hi, Tim! Hopefully you get this. I just got your email address.</p>\n\n<p>My email is x#xcom.</p>\n\n<p>For example, you could tell me:</p>\n\n<ul>\n <li>3 hours from now</li>\n <li>2 days from now at 5pm</li>\n <li>Wednesday afternoon</li>\n</ul>\n"
The date format for my begin_date attribute is displaying like : 2015-04-25 00:00:00
and i want it like : 25 04 2015
I tried :
<?php
echo $this->helper('core')->formatDate(getbegin_date(), Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
?>
But it don't work.
Here is how you can format the time (in PHP). If you need more reference then check this page: Playing with Dates in Magento
$current_time = Mage::getModel('core/date')->timestamp(time());
echo $date = date('d m Y', $current_time);
Here goes the problem:
I have a requirement that an (classical)asp application should display different content at specific EST(Eastern Time) duration. The clients can arrive from any timezone, but the server should take only EST time into consideration.
I am sorry for my ignorance, but I am from ASP.Net background and have no idea of doing this in classical asp.
This SO Link guided me to get UTC, but I still don't know how to convert it to EST.
Any help will be greatly appreciated.
If your server is in EST then not an issue, otherwise you'll need to compensate for it.
mytime = now()
myadjtime = DateAdd("h", 3, mytime)
will add 3 hours to the current time
<%
mytime = now()
response.write hour(mytime)
if hour(mytime) >=12 then
response.write "It's noon or later"
end if
%>
you can check http://worldclockapi.com web site. You can take current time as timezone..
example: http://worldclockapi.com/api/json/est/now
if you go to above address you can see EST current date, time and other data..
example: http://worldclockapi.com/api/json/pst/now
if you go to above address, you can see PST current date, time and other data...
and you can use XMLHTTP for getting data from external site.
`
private Function GETHTTP(adres)
Set StrHTTP = Server.CreateObject("Microsoft.XMLHTTP" )
StrHTTP.Open "GET" , adres, false
StrHTTP.sEnd
GETHTTP = StrHTTP.Responsetext
Set StrHTTP = Nothing
End Function
full_data= GETHTTP("http://worldclockapi.com/api/json/est/now")
`
after you use split code by comma:
parts=split(full_data,",")
response.write parts(1)
I am using the codeigniter time helper to echo the TIMESTAMP (CURRENT_TIMESTAMP) row of my mysql database.
The timestamp in my database in raw format is: 2011-11-15 14:40:45
When I echo the time in my view using the helper i get the following: 15/11/2011 02:40
My time now appears to be in AM. Why???
This is the code I use to echo the time:
$the_date = mdate('%d/%m/%Y %h:%i', strtotime($row->date))
echo $the_date
You need to change the format of your data when returning it from the database. Chage the lowercase h (%h) to a capital H (%H) to return 24-hour format rather than the 12 hour you're currently getting.
You're code should look like the below:
$the_date = mdate('%d/%m/%Y %H:%i', strtotime($row->date))
I have got below code, where I am sending the formatted date and time to my XSLT and which is giving a XML as output.
#importXSLT "tcm:228-190529-2048" As expandXSLT
#importXSLT "tcm:228-642694-2048" As renderXSLT
Dim xml, currentDateTime, datLong , datLongTime , fullDate
Set xml = getNewDomDocument()
xml.loadXML TDSE.GetListPublications(3)
expandXSLT.input = xml
Call expandXSLT.addParameter("publication", Component.Publication.Id)
expandXSLT.transform
xml.loadXML(expandXSLT.output)
'WriteOut xml.xml
currentDateTime = now()
datLong = FormatDateTime(currentDateTime, 1)
datLongTime = FormatDateTime(currentDateTime, 3)
fullDate = datLong &" "& datLongTime
renderXSLT.input = xml
Call renderXSLT.addParameter("currentPublishedDate", CStr(fullDate))
renderXSLT.transform
WriteOut renderXSLT.output
Set xml = Nothing
Now above logic for doing date formatting is same for two outputted XML, but suprising I am getting different output for both the files.
First File gives - Sunday, October 23, 2011 8:52:36 AM as output
Second File gives - 23 October 2011 09:14:45 as output.
Please suggest what can be reason as well as solution also, and one more thing if I want output as below for both the file as 23 October 2011 09:14:45 AM
Thanks!!
Before you do the date formatting, try to explicitly set the locale using something like SetLocale(2057).
2057 is UK format which seems to be what you want, otherwise look at this Locale ID Chart to find the correct value.