Well perhaps not time travel in the science fiction sense, but we will be performing transmogrification between time format specification ... which is time travel in the developer sense (grin). A recent project involved reading an RSS feed and formatting it for display within a web page. Unfortunately the pubDate time format in the RSS feed was not compatible with the KRL time library. So we developed a KRL function to convert the time format. Perhaps you will find this function useful when you embark on your own time travels.

The RSS pubDate time string accepted by the KRL function is of the format:

Wed, 21 Sep 2011 15:02:01 -0700

and will be converted to RFC3339 format:


We use the function to convert the RSS pubDate, then call the time:strftime() library to generate the needed display format:

krlDate = rss2krlTime("Wed, 21 Sep 2011 15:02:01 -0700");
strDate = time:strftime(krlDate, "%b %d %Y");

Here is the KRL time travel function is all it's glory:

rss2krlTime = function(pubDate) {
  tarr = pubDate.split(re/ /);
  tzoff = tarr[5].replace(re/\d\d$/, "");
  rfcTime = tarr[3] + "-" + mon2num{[tarr[2]]} + "-" +
            tarr[1] + "T" + tarr[4] + tzoff + ":00";

mon2num = { "Jan": "01", "Feb": "02", "Mar": "03",
            "Apr": "04", "May": "05", "Jun": "06",
            "Jul": "07", "Aug": "08", "Sep": "09",
            "Oct": "10", "Nov": "11", "Dec": "12" };