/*
-------------------------------------------------------------------------------------
N	smgDateTime
D	javascript object used for manipulating date / time strings / values
	isn't this already provided somewhere?  i suspect so :|
-------------------------------------------------------------------------------------
*/

function DateTime() {
	this.now = new Date();
	this.sGetMonthName = sGetMonthName;
	this.sGetYear = sGetYear;
	this.sGetDay = sGetDay;
}

function sGetMonthName() {
	month = this.now.getMonth();
	// unfortunately, the if / elseifs are necessary to maintain compat with NS3
	// since it doesn't support switch
	if (month == 0)
			return "January";
	else if (month == 1)
			return "February";
	else if (month == 2)
			return "March";
	else if (month == 3)
			return "April";
	else if (month == 4)
			return "May";
	else if (month == 5)
			return "June";
	else if (month == 6)
			return "July";
	else if (month == 7)
			return "August";
	else if (month == 8)
			return "September";
	else if (month == 9)
			return "October";
	else if (month == 10)
			return "November";
	else if (month == 11)
			return "December";
	else
		return null;
}

// miserable javascript doesn't have any enums so we have to make do with sending the
// number of digets required <- wassat mean?  so much for comments :|
function sGetYear(digets) {
	// the javascript date object returns a two diget date for years between 1900 / 2000,
	// and 4 for years < 1900 or > 1999
	year = this.now.getYear();
	// bloody scape decided to change what the date form is somwhere from 4.04 to 4.7, so
	// i've decided to handle it by saying anything under 1900 is representing that number of years
	// -from- 1900 (i.e. 100 is 2000).
	if (parseInt(year) < 1900)
		year = 1900 + year;
	year = String(year);
	currentDigets = year.length;
	if (currentDigets != digets) {
		if (currentDigets == 2 && digets == 4)
			year = "19" + year;
		else if (currentDigets == 4 && digets == 2)
			year = year.substr(2);
		else
			year = null;
	}
	return year;
}

function sGetDay(digets) {
	day = String(this.now.getDate());
	if (digets == 2) {
		if (day.length == 1)
			day = "0" + day;
	}
	return day;
}

