// Extend the built in Date object be more clever

/*
instance functions are:

number.pad = add zeros to the left of the number and return a string of the appropriate length 2.pad(3) = "002"

static functions:

*/



new Number();	// to force creation of a prototype if it's not already been done.

Number.prototype.pad = function (digits) {
	
	var string = this.toString();
	if (string.length < digits) {
		
		for (var i=0; i<=(digits-string.length); i++) {
			string = "0" + string;
		}
	}
	
	return string;
}

Number.prototype.dateEnding = function () {
	
	var end = "";
	thisAsString = this.toString();
	var lastDigit = thisAsString.charAt(thisAsString.length-1);

	switch (lastDigit) {
		
		case "1": end = "st";break;
		case "2": end = "nd";break;
		case "2": end = "rd";break;
		default: end="th";
		
	}
	
	return end;
}