It should be business as usual that aggregators support date/time informations on RSS feed items. But on RSS 0.91 it is completely missed, newer versions (should) have at least the
pubDate element. Some also support the dublin core element
date formatted as xsd:dateTime. Some use the US-centric (
day-of-week, DD month-name CCYY hh:mm:ss zone, aka RFC822 or RFC2822) other the ISO format (
CCYY-MM-DDThh:mm:ssTZD). As the whole format is XML one may expect to get dates in the XMLSchema format (ISO). Who knows? We are on the WWW, why not use the HTTP date (
day-of-week, DD month-name CCYY hh:mm:ss GMT) defined in RFC2616 as a RFC1123-date? Or some of the specific database datetime formats?
Enough confusing...
So I am lucky with
Don's RSS 2.0 Profile in general, but not in the special case of date format: why the
date SHOULD use TZ of post, MAY use GMT and not HAVE to use TZ of post? The other side of the medal: how we get the date(s) into a native .NET DateTime format? Simply use
DateTime.Parse(). Well, works 75 percent. No RFC2822 support. Use
XmlConvert.ToDateTime() for the ISO dates, nice again 20 percent. May be there is somewhere a (internal) function to parse HTTP dates. OK, lets start implementing the missing 5 percent. Write a
class RFC822DateTime: DateTime { ... Ups! It's a structure, no inheritance, sorry. How about to extend it?
Reading over the docs about IFormatProvider (more related to convert a DateTime to a string), DateTimeFormatInfo, Calendars, CultureInfo, etc.: my head explodes! OK, try the other way and
check whether it is at all possible: no RFC(2)822 support. Now it was time to write the x'th date time parser. Deterred from the quantity of code found
here, thus I decided to transfer the main load of datetime parse to the RegEx class. The
Ruby class Time used as a blueprint now it works
well.
BTW: feel free to download/test the official
RSS Bandit 1.1 Beta 5.