Jeff Woodman, Santa Fe, New Mexico, U.S.A. -

RSS Feed for Coffee and Code - Jeff Woodman’s Blog

Jeff’s Code Toolbox

When I first launched this website in 2005, I provided several code examples in JavaScript and Classic ASP. I have kept them online because people are downloading them, but some are honestly a little dated.

Legacy Code Samples

RFC-822 DateTime with JavaScript

I’ll be the first to admit it: the RFC-822 date/time format is an absolute pain in the butt. It's not sortable, and good lord, it seems to be only useful to machines... However, sometimes you need it, especially for valid RSS 2.0 formats.

Below is a bit of JS I worked up a few years ago for coverting a Date object to an RFC-822 string. Originally posted on my old site,

<script type="text/javascript">
  /*Accepts a Javascript Date object as the parameter;
  outputs an RFC822-formatted datetime string. */
  function GetRFC822Date(oDate)
    var aMonths = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", 
                            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    var aDays = new Array( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
    var dtm = new String();
    dtm = aDays[oDate.getDay()] + ", ";
    dtm += padWithZero(oDate.getDate()) + " ";
    dtm += aMonths[oDate.getMonth()] + " ";
    dtm += oDate.getFullYear() + " ";
    dtm += padWithZero(oDate.getHours()) + ":";
    dtm += padWithZero(oDate.getMinutes()) + ":";
    dtm += padWithZero(oDate.getSeconds()) + " " ;
    dtm += getTZOString(oDate.getTimezoneOffset());
    return dtm;
  //Pads numbers with a preceding 0 if the number is less than 10.
  function padWithZero(val)
    if (parseInt(val) < 10)
      return "0" + val;
    return val;

  /* accepts the client's time zone offset from GMT 
     in minutes as a parameter.
     returns the timezone offset in the format [+|-}DDDD */
  function getTZOString(timezoneOffset)
    var hours = Math.floor(timezoneOffset/60);
    var modMin = Math.abs(timezoneOffset%60);
    var s = new String();
    s += (hours > 0) ? "-" : "+";
    var absHours = Math.abs(hours)
    s += (absHours < 10) ? "0" + absHours :absHours;
    s += ((modMin == 0) ? "00" : modMin);


Home-grown AJAX Code

There was a brief period of time, long ago, when you had to write your own AJAX code (back in the days when XMLRPC was a buzzword). Here are a couple of do-it-yourself AJAX examples I posted long ago.

Classic ASP Tricks

Yes, these examples are in ASP “Classic”, a.k.a., old. But, they are written using server-side JavaScript, which beats VBScript any day of the week!