function validDate( value, name ) {
	var type;

	type = typeof value;
	if ( type === 'string' ) {
		value = Date.parse( value );
		if ( value !== value ) {
			throw new Error( format( 'invalid argument. Unable to parse %s date.', name.toLowerCase() ) );
		}
		value = new Date( value );
	}
	if ( type === 'number' ) {
		if ( !timestamp.test( value ) ) {
			throw new Error( format( 'invalid argument. Numeric %s date must be either a Unix or JavaScript timestamp.', name.toLowerCase() ) );
		}
		if ( value.toString().length === 10 ) {
			value *= 1000; // sec to ms
		}
		value = new Date( value );
	}
	if ( !(value instanceof Date) ) {
		throw new TypeError( format( 'invalid argument. %s date must either be a date string, Date object, Unix timestamp, or JavaScript timestamp.', name ) );
	}
	return value;
}
Validates a date parameter.

@private
@param {*} value - value to be validated
@param {string} name - name to be used in error messages
@throws {TypeError} value must either be a date string, Date object, Unix timestamp, or JavaScript timestamp
@throws {Error} numeric date must be either a Unix or JavaScript timestamp
@returns {Date} validated date