
// ~~~~~~~~~~~~~~~~~~~~~~~~ BEGIN DATE FUNCTIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~, Gary M, Sep 2007.

function DateVerifier(day,month,year) {

	// Note that Javascript indexes months in the range 0 - 11:
	var month=month-1;
	/* 
	The command below will attempt to create a date object from the tokens supplied.
	If it fails it will take its best guess, altering the value of at least one of the tokens en route.
	Therefore if the resulting date token does not match the corresponding input, we know an error has occurred.
	*/
	source_date = new Date(year,month,day);
	
	if 	(year != source_date.getFullYear() || 
		month != source_date.getMonth() || 
		day != source_date.getDate())
	{
		return false;
	} else {
		return true;
	}
	
}

function DateCompartitor(FromDay,FromMonth,FromYear,FromHours,FromMinutes,	ToDay,ToMonth,ToYear,ToHours,ToMinutes) {
	// Ensures that the "From" date is earlier than the "To" date.
	
	// Assumes validity of input date parameters based on usage of DateVerifier();
	var DateFromObject = new Date(FromYear,FromMonth,FromDay,FromHours,FromMinutes,0);
	var DateToObject = new Date(ToYear,ToMonth,ToDay,ToHours,ToMinutes,0);
	
	if (DateFromObject < DateToObject) {
		return true;
	} else {
		return false;
	}
	
}

// ~~~~~~~~~~~~~~~~~~~~~~~~ END DATE FUNCTIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


