// mDateTime.js
// Created by JBSM Design 2009
// Intended to work with google calendar feeds


var day = new Array(7);
day[0] = "Sunday";
day[1] = "Monday";
day[2] = "Tuesday";
day[3] = "Wednesday";
day[4] = "Thursday";
day[5] = "Friday";
day[6] = "Saturday";

var month = new Array(12);
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";

function mDateTime(dateObject) 
{	
	var dateTime = dateObject.split("T");
	var cDate = dateTime[0].split("-");
	var cTime = dateTime[1].split(":");

	var date = new Date();
	date.setFullYear(parseInt(cDate[0],10),parseInt(cDate[1]-1,10),parseInt(cDate[2],10));

	this.nYear = date.getFullYear();
	this.nMonth = date.getMonth();
	this.nDate = date.getDate();
	this.nDay = date.getDay();
	
	this.sMonth = month[this.nMonth];
	this.sDay = day[this.nDay];

	this.nHour = parseInt(cTime[0],10);
	this.sMinute = cTime[1];
	this.meridian = (this.nHour >= 12) ? "pm" : "am";
	if (this.nHour == 0)
		this.nHour = 12;
	else if (this.nHour > 12)
		this.nHour -= 12;	
	
	this.getMDate = getMDate;	
	this.getMTime = getMTime;
}

function getMDate()
{
	return (this.sDay + ' ' + this.sMonth + ' ' + this.nDate + ', ' + this.nYear);
}

function getMTime()
{
	return (this.nHour + ":" + this.sMinute + " " + this.meridian);
}

	
