First page Back Continue Last page Image

function showTheTime(currElem,tzOffset) {

var dayName = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

var thatTZ = new Date();

var dateStr = thatTZ.toUTCString();

dateStr = dateStr.substr(0,dateStr.length - 3);

thatTZ.setTime(Date.parse(dateStr));

thatTZ.setHours(thatTZ.getHours() + parseInt(tzOffset));

// Create a Time output suitable for Humans

currElem.innerHTML = showTheHours(thatTZ.getHours())+showZeroFilled(thatTZ.getMinutes())+showAmPm(thatTZ.getHours())+dayName[thatTZ.getDay()];

// Convert hours from Military Time to Civilian Time

function showTheHours(theHour) {

if (theHour == 0) {

return 12;

}

if (theHour < 13) {

return theHour;

}

return theHour-12;

}

// Zero fill the tens place in the minutes for Digital Clock Output

function showZeroFilled(inValue) {

if (inValue > 9) {

return ":" + inValue;

}

return ":0" + inValue;

}

// Use Hours to determine AM or PM

function showAmPm(thatTime) {

if (thatTime < 12) {

return " AM ";

}

return " PM ";

}

}