/*
 * $Id: timestamp.js,v 1.4 2008/05/30 20:43:46 mripplin Exp $
 *
 * +------+   Copyright 2008, ICx Transportation Group
 * | ICx  |                   All Rights Reserved
 * +------+----------------------------------------------------------
 * This file is property of ICx Transportation Group.  Any unauthorized use or
 * duplication of this file, or removal of the header, constitutes
 * theft of intellectual property.
 *
 * Include this file to print a "last refreshed" timestamp.
 * This is implemented in JavaScript so that it prints the local, client-side time.
 */

/**
 * Return integer "num" as a 2-digit string (for dates and times).
 */
function pad(num) {
	return (num < 10) ? '0' + num : num;
}

/**
 * Return date "d" formatted as "M/D/YY h:mm am/pm"
 * @param d	A javascript "Date" object.
 */
function timestring(d) {
	var h = d.getHours();
	var hour = h % 12;
	if (hour == 0) hour = 12;
	var year = d.getYear();
	if (year < 1900)
		year = 1900 + year;

	var theString = d.getMonth() + 1 + '/' + d.getDate() +	'/' + pad(year%100);

	theString += ' ' + hour + ':' + pad(d.getMinutes());
	theString += (h < 12) ? '&nbsp;a.m.' : '&nbsp;p.m.';

	return theString.replace(" ", "&nbsp;");
}

document.write("Last refreshed: " + timestring(new Date()));

