function toRfcDate( jsDate )
{
		if(!jsDate) {
			jsDate = new Date();
		}
		var year = jsDate.getFullYear();
		var month = jsDate.getMonth() + 1;
		if (month < 10) {
			month = "0" + month.toString();
		}
		var date = jsDate.getDate();
		if (date < 10) {
			date = "0" + date.toString();
		}
		// because this is a date picker and not a time picker, we treat time
		// as zero
		return year + "-" + month + "-" + date + "T00:00:00";
}


// returns the date string for the event date embedded the google calendar
// event summary.  The event summary looks like:
//	"When: Nov 11, 2006<br><br>Event Status: confirmed"
//
function getDatesFromSummary( summary )
{
	str = new String( summary );
	return str.match( /(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9][0-9]?/g );
}
	

function getWhenFromSummary( summary )
{
	when = getDatesFromSummary( summary );
	// when contains one or two dates. 
	if ( when.length < 2 )
		return when;
	else
		if ( when[0].substr(4,3) == when[1].substr(4,3) )
			// the end date is in the same month
			return when[0] + "-" + when[1].substr(8)
		else
			// the end date is in a different month.
			// return the ending month as well.
			return when[0] + "-" + when[1].substr( 4 );
}

