lib/factory.js
function setDay(date, day) {
		// we don't want to change month when changing date
		var month = date.getMonth(),
			diff = day - (date.getDay() || 7);
		// move to correct date
		date.setDate(date.getDate() + diff);
		// check month
		if (date.getMonth() != month) {
			if (diff > 0) {
				date.setDate(date.getDate() - 7);
			} else {
				date.setDate(date.getDate() + 7);
			}
		}
	}
function setDay(date, day) {
		// we don't want to change month when changing date
		var month = date.getMonth(),
			diff = day - (date.getDay() || 7);
		// move to correct date
		date.setDate(date.getDate() + diff);
		// check month
		if (date.getMonth() != month) {
			if (diff > 0) {
				date.setDate(date.getDate() - 7);
			} else {
				date.setDate(date.getDate() + 7);
			}
		}
	}
function setDay ( date , day ) { // we don't want to change month when changing date var month = date . getMonth ( ) , diff = day - ( date . getDay ( ) || 7 ) ; // move to correct date date . setDate ( date . getDate ( ) + diff ) ; // check month if ( date . getMonth ( ) != month ) { if ( diff > 0 ) { date . setDate ( date . getDate ( ) - 7 ) ; } else { date . setDate ( date . getDate ( ) + 7 ) ; } } }
set the proper date value matching the weekday
set the proper date value matching the weekday