{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\f0\fs20\par
<!-- Paste this code into an external JavaScript file named: dateFormat.js  -->\par
\par
/* This script and many more are available free online at\par
The JavaScript Source :: http://javascript.internet.com\par
Created by: Oded Arbel :: http://geek.co.il/wp/ */\par
\par
/**\par
* Extension of the JavaScript internal Date object to allow various formatting of\par
* date/time values.\par
* This implementation was designed to be compliant with the formatting of the\par
* Java class library's SimpleDateFormat object, with the addition of the 'x' format\par
* option to show number of seconds since the epoch (1/1/1970 00:00).\par
*\par
* See http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html for\par
* full details.\par
*\par
* (c) Copyright 2006 - Oded Arbel\par
* (c) Portions copyright 2006 - Jack Slocum\par
*/\par
\par
// Static definition of Month names\par
Date.MONTH_NAMES = [\par
"January", "February", "March",\par
"April", "May", "June",\par
"July", "August", "September",\par
"October", "November", "December" ];\par
\par
// Static definition of weekday names\par
Date.WEEKDAY_NAMES = [\par
"Sunday", "Monday", "Tuesday",\par
"Wednesday", "Thursday", "Friday",\par
"Saturday" ];\par
\par
// clone the current date object and return a different object with identical value\par
Date.prototype.clone = function () \{\par
  return new Date(this.getTime());\par
\}\par
\par
// clear the time information from this date and return it\par
Date.prototype.clearTime = function () \{\par
  this.setHours(0); this.setMinutes(0);\par
  this.setSeconds(0); this.setMilliseconds(0);\par
  return this;\par
\}\par
\par
// return the last day of this month\par
Date.prototype.lastDay = function () \{\par
  var tempDate = this.clone();\par
  tempDate.setMonth(tempDate.getMonth()+1);\par
  tempDate.setDate(0);\par
  return tempDate.getDate();\par
\}\par
\par
// return number of days since start of year\par
Date.prototype.getYearDay = function () \{\par
  var today = new Date(this);\par
  today.setHours(0); today.setMinutes(0); today.setSeconds(0);\par
  var tempDate = new Date(today);\par
  // set start of year\par
  tempDate.setDate(1);\par
  tempDate.setMonth(0);\par
  return Math.round(\par
  (today.getTime() - tempDate.getTime())\par
  / 86400 / 1000) + 1; // Jan/1 is day 1\par
\}\par
\par
// add format() to Date\par
Date.prototype.format = function(formatString) \{\par
  var out = new String();\par
  var token = ""\par
  for (var i = 0; i < formatString.length; i++) \{\par
    if (formatString.charAt(i) == token.charAt(0)) \{\par
      token = token.concat(formatString.charAt(i));\par
      continue;\par
    \}\par
    out = out.concat(this.convertToken(token));\par
    token = formatString.charAt(i);\par
  \}\par
  return out + this.convertToken(token);\par
\}\par
\par
// internal call to map tokens to the date data\par
Date.prototype.convertToken = function (str) \{\par
  switch(str.charAt(0)) \{\par
    case 'y': // set year\par
      if (str.length > 2)\par
      return this.getFullYear();\par
      return this.getFullYear().toString().substring(2);\par
    case 'd': // set date\par
      return Date.zeroPad(this.getDate(),str.length);\par
    case 'D': // set day in year\par
      return this.getYearDay();\par
    case 'a':\par
      return this.getHours() > 11 ? "PM" : "AM";\par
    case 'H': // set hours\par
      return Date.zeroPad(this.getHours(),str.length);\par
    case 'h':\par
      return Date.zeroPad(this.get12Hours(),str.length);\par
    case 'm': // set minutes\par
      return Date.zeroPad(this.getMinutes(),2);\par
    case 's': // set secondes\par
      return Date.zeroPad(this.getSeconds(),2);\par
    case 'S': // set milisecondes\par
      return Date.zeroPad(this.getMilliseconds(),str.length);\par
    case 'x': // set epoch time\par
      return this.getTime();\par
    case 'Z': // set time zone\par
      return (this.getTimezoneOffset() / 60) + ":" +\par
      Date.zeroPad(this.getTimezoneOffset() % 60,2);\par
    case 'M': // set month\par
      if (str.length > 3) return this.getFullMonthName();\par
      if (str.length > 2) return this.getShortMonthName();\par
      return Date.zeroPad(this.getMonth()+1,str.length);\par
    case 'E': // set dow\par
      if (str.length > 3) return this.getDOWName();\par
      if (str.length > 1) return this.getShortDOWName();\par
      return this.getDay();\par
      default:\par
      return str;\par
  \}\par
\}\par
\par
// Retreive the month's name in english\par
Date.prototype.getFullMonthName = function() \{\par
  return Date.MONTH_NAMES[this.getMonth()];\par
\}\par
\par
// Retreive the abberviated month name in english\par
Date.prototype.getShortMonthName = function() \{\par
  return Date.MONTH_NAMES[this.getMonth()].substring(0,3);\par
\}\par
\par
// Retreive the week day name in english\par
Date.prototype.getDOWName = function () \{\par
  return Date.WEEKDAY_NAMES[this.getDay()];\par
\}\par
\par
// Retreive the abberviated week day name in english\par
Date.prototype.getShortDOWName = function () \{\par
  return Date.WEEKDAY_NAMES[this.getDay()].substring(0,3);\par
\}\par
\par
// Retreive the hour in a 12 hour clock (without the AM/PM specification)\par
Date.prototype.get12Hours = function () \{\par
  return this.getHours() == 0 ? 12 :\par
  (this.getHours() > 12 ? this.getHours() - 12 : this.getHours());\par
\}\par
\par
// helper function to add required zero characters to fixed length fields\par
Date.zeroPad = function(num, width) \{\par
  num = num.toString();\par
  while (num.length < width)\par
  num = "0" + num;\par
  return num;\par
\}\par
}
 
