var DateTime={
	Format:function(strDate,byDate,byTimeZone){
		if (byDate==""){
			if (byTimeZone==-1){
				byDate = new Date();
			}else{
				byDate = new Date(System.Time.getLocalTime(System.Time.timeZones.item(parseInt(byTimeZone))));
			}
		}
		var ret=strDate;
		
		var hr24 = byDate.getHours();
		var mn = byDate.getMinutes();
		var sc = byDate.getSeconds();
		var ampm = "am"
		var hr12 = hr24;
		if (sc < 10){
			sc = "0"+sc;
		}
		if (mn < 10){
			mn = "0"+mn;
		}
		if (hr12 > 11){
			hr12 -= 12;
			ampm = "pm";
		}
		if (hr12 == 0){hr12 = 12}
		
		var suffix=byDate.getDate().toString();
		suffix=suffix.substr(suffix.length-1);
		suffix=this.Suffixes[suffix];
		var lzDay=byDate.getDate();
		if (lzDay<10){lzDay="0"+lzDay}
		var lzMonth=byDate.getMonth()+1;
		if (lzMonth<10){lzMonth="0"+lzMonth}
		var lzHr12=hr12;
		if (lzHr12<10){lzHr12="0"+lzHr12}
		var lzHr24=hr24;
		if (lzHr24<10){lzHr24="0"+lzHr24}
		//DAY
		ret=ret.replace(/%d/g,lzDay);
		ret=ret.replace(/%j/g,byDate.getDate());
		ret=ret.replace(/%D/g,this.Days[byDate.getDay()].substr(0,3));
		ret=ret.replace(/%l/g,this.Days[byDate.getDay()]);
		ret=ret.replace(/%S/g,suffix);
		
		//MONTH
		ret=ret.replace(/%F/g,this.Months[byDate.getMonth()]);
		ret=ret.replace(/%M/g,this.Months[byDate.getMonth()].substr(0,3));
		ret=ret.replace(/%m/g,lzMonth);
		ret=ret.replace(/%n/g,byDate.getMonth()+1);
		
		//YEAR
		ret=ret.replace(/%Y/g,byDate.getFullYear());
		ret=ret.replace(/%y/g,byDate.getFullYear().toString().substr(2,2));
		
		//TIME
		ret=ret.replace(/%a/g,ampm);
		ret=ret.replace(/%A/g,ampm.toUpperCase());
		ret=ret.replace(/%g/g,hr12);
		ret=ret.replace(/%h/g,lzHr12);
		ret=ret.replace(/%G/g,hr24);
		ret=ret.replace(/%H/g,lzHr24);
		ret=ret.replace(/%i/g,mn);
		ret=ret.replace(/%s/g,sc);
		
		return ret;
	},
	Months:["January","February","March","April","May","June","July","August","September","October","November","December"],
	Days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
	Suffixes:["st","nd","rd","th","th","th","th","th","th","th"]
}