/* ***********************************************************
config_dateformat.js
Javascript for Map Viewer
by Howie Sternberg (howies@snet.net)

Map Viewer is placed in the public domain and is "Freeware". 
Map Viewer may be freely used and redistributed, is provided 
"AS-IS" without warranty of any kind, and there is no technical 
support provided. 
--------------------------------------------------------------
History
Jul 2005, Initial code for Map Viewer 3rd Edition update  
************************************************************ */

// This is customizable. Just specify desired format for date fields 
// for feature attributes listed when selected or identified. These
// date formats apply to all date fields for all layers in map service.

// This is customizable. Just specify desired date format below by changing the lines that are commented out.

function formatDates() {
	aDates = document.getElementsByName("mapDateField")	
	for (var i = 0; i < aDates.length; i++) {
	
		// see date in milliseconds
		// window.alert(aDates[i])
		
		// create date object
		var theDateObj = new Date(parseFloat(aDates[i].innerHTML));

		// ** DATE FORMAT OPTIONS
		// ** 1. Year only - Example: 1901
		//var theDate = theDateObj.getUTCFullYear().toString();
	
		// ** 2. Date and Time - Example: Tue, 31 Dec 1901 00:00:00
		//var d1 = theDateObj.toUTCString();
		//var theDate = d1.replace(/GMT|UTC/,"");
		
		// ** 3. Date with Name of Day - Example: Tue, 31 Dec 1901
		//var d1 = theDateObj.toUTCString();
		//var d2 = d1.replace(/GMT|UTC/,"");
		//var theDate = d2.replace(/00:00:00/,"");
		
		// ** 4. Date without Name of Day - Example: 31 Dec 1901
		var d1 = theDateObj.toUTCString();
		var d2 = d1.replace(/GMT|UTC/,"");
		var d3 = d2.replace(/00:00:00/,"");
		var theDate = d3.replace(/Sun, |Mon, |Tue, |Wed, |Thu, |Fri, |Sat, /,"");
		
		// see formatted date
		// window.alert(theDate)
		
		// show formatted date on web page
		aDates[i].innerHTML = theDate;
		theDate = null;
	}		
}



