By John Gruber
Addigy — An Apple device management solution that scales with you.
Yesterday, Mark Pilgrim and Sam Ruby released their nifty new RSS Validator.
So, of course, I immediately ran Daring Fireball’s RSS feed through the validator. There were three errors. I shouldn’t have taken this personally, because my RSS feed was automatically generated by Movable Type’s default RSS 0.91 template, but take it personally I did. My HTML validates, my CSS validates, so damn it, my RSS ought to validate.
The RSS Validator even helpfully (and correctly) guessed that my RSS was being generated by Movable Type, and offered suggestions for fixing it. However, its suggestion for fixing a Movable Type RSS 0.91 template is to use an RSS 2.0 template instead.
That doesn’t help if you really want to stick with 0.91. All things considered, I like RSS 0.91 because it is really, really simple; RSS 1.0 and 2.0 are not. So, I decided to fix my RSS 0.91 template so that my feed would validate.
RFC-822 dates shouldn’t be hard to generate. One thing that’s very nice about RFC-822 dates is that they’re very much human readable. Here’s an example:
Mon, 21 Oct 2002 14:04:23 EDT
Alternatively, in lieu of specifying the abbreviation for the time zone, you can specify an offset from Universal Time (a.k.a. Greenwich Mean Time):
Mon, 21 Oct 2002 14:04:23 -0500
If this format looks familiar, that’s because it’s the format for Date: headers in email messages.
The “Mon, 21 Oct 2002 14:04:23” part is easy to output from Movable Type, using this template tag:
<$MTEntryDate format="%a, %d %b %Y %H:%M:%S"$>
The problem is the time zone offset. Movable Type’s built-in <MTBlogTimeZone> tag outputs the offset, but it includes a colon between the hour and minute:
and the RSS Validator disallows it.
So, I whipped up a tiny MT plug-in which creates a new template tag, <MTrfc822BlogTimeZone>, which spits out timezone offsets without the colon.
Thus, after installing the plug-in, the following template code produces a valid RFC-822 date string that passes through the RSS Validator:
<MTEntries lastn="1"> <$MTEntryDate format="%a, %d %b %Y %H:%M:%S"$><$MTrfc822BlogTimeZone$> </MTEntries>
Download the plug-in: rfc822BlogTimeZone_1.0.zip (3.2 KB). Installation instructions and further details are included.
Here is an example Movable Type RSS 0.91 template that uses the plug-in.