Wicked Strategery

Where servers serve, routers route, and configulators configulate

Really Simple Syndication at Last!

Written by: Doug Jenkinson

Article

The use of RSS has finally come to Wicked Strategery!

Since WS is XML driven, I wrote a script to create the RSS feed automatically, much like the rest of the site. However, this was not without its own problems.

Problems?

The first problem is deciding what version of RSS to support. I opted to go with 2.0, as opposed to 0.92 or 1.0. It was just as easy to implement one particular version over another. And eventually, I might get around to implementing those other versions, so a choice is available.

Secondly, ASP does not have a nice, clean-cut function for the formatting of dates and times. And no easy way to get a date/time into RFC 882 formatting, as required by RSS.

Solution

I wrote this function to accept a date/time and format it as a RFC 882 compliant string. It's really easy to use, and gets the job done.

Usage: The function accepts a DateTime value and a string representing the timezone offset (-0500 for EST).

The RFC822 standard mandates that the time/date values be 0-padded, and that is what the zeroPad function accomplishes. It accepts a string to pad, and a desired length. For example, zeroPad("2", 4) would return "0002".

Code

Function zeroPad(m, t)
  zeroPad = String(t - Len(m), "0") & m
End Function
 
Function RFC822(TimeDate, offset)
  If IsDate(CDate(TimeDate)) Then
    TimeDate = CDate(TimeDate)
    RFC822 = WeekdayName(Weekday(TimeDate), True) & ", " & _
      zeroPad(Day(TimeDate), 2) & " " & _
      MonthName(Month(TimeDate), True) & " " & _
      Year(TimeDate) & " " & _
      zeroPad(Hour(TimeDate), 2) & ":" & _
      zeroPad(Minute(TimeDate), 2) & ":" & _
      zeroPad(Second(TimeDate), 2) & " " & _
      CStr(offset)
  Else
    RFC882 = ""
  End If
End Function

There you have it, a function to format a date/time as RFC 822 format.


Metadata


Revisions

  • v1.1 (24 Dec 2005) - Included the zeroPad function and better usage information.
  • v1.0 (2 Sep 2005) - Article published.

About the Author

Doug Jenkinson is an avid technology aficionado and Software Engineer with Hyland Software, Inc. / entrepreneur in Copley, OH.

Read More...

Linquistory

"The Wørd" of the Night: Truthiness, courtesy of Stephen Colbert

Wikiality

Breadcrumbs

Usability In Software

Impressions of Scrum

Pre-compiling ASP.NET

DragonStar Galaxy Map

Really Simple Syndication at Last!

Personal Links

LinkedIn

Google Profile

My del.icio.us

twitter

My flickr

My ClaimID

Projects

twitlbl

Site Updates

I've added some spiffy new features to my site. You can read all about them in the changelog.

Internet Quote

"Yeah man, I tell ya what, man. That dang ol' Internet, man. You just go on there and point and click. Talk about W-W-dot-W-com. An' lotsa nekkid chicks on there, man. Click. Click. Click. Click. Click. It's real easy, man." - Boomhauer, King of the Hill

Feeds

RSS OPML