src/cal-heatmap.js
function (d, range) {
		"use strict";

		var weekStart;

		if (this.options.weekStartOnMonday === false) {
			weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate() - d.getDay());
		} else {
			if (d.getDay() === 1) {
				weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate());
			} else if (d.getDay() === 0) {
				weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate());
				weekStart.setDate(weekStart.getDate() - 6);
			} else {
				weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate()-d.getDay()+1);
			}
		}

		var endDate = new Date(weekStart);

		var stop = range;
		if (typeof range !== "object") {
			stop = new Date(endDate.setDate(endDate.getDate() + range * 7));
		}

		return (this.options.weekStartOnMonday === true) ?
			d3.time.mondays(Math.min(weekStart, stop), Math.max(weekStart, stop)):
			d3.time.sundays(Math.min(weekStart, stop), Math.max(weekStart, stop))
		;
	}
function (d, range) {
		"use strict";

		var weekStart;

		if (this.options.weekStartOnMonday === false) {
			weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate() - d.getDay());
		} else {
			if (d.getDay() === 1) {
				weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate());
			} else if (d.getDay() === 0) {
				weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate());
				weekStart.setDate(weekStart.getDate() - 6);
			} else {
				weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate()-d.getDay()+1);
			}
		}

		var endDate = new Date(weekStart);

		var stop = range;
		if (typeof range !== "object") {
			stop = new Date(endDate.setDate(endDate.getDate() + range * 7));
		}

		return (this.options.weekStartOnMonday === true) ?
			d3.time.mondays(Math.min(weekStart, stop), Math.max(weekStart, stop)):
			d3.time.sundays(Math.min(weekStart, stop), Math.max(weekStart, stop))
		;
	}
function ( d , range ) { "use strict" ; var weekStart ; if ( this . options . weekStartOnMonday === false ) { weekStart = new Date ( d . getFullYear ( ) , d . getMonth ( ) , d . getDate ( ) - d . getDay ( ) ) ; } else { if ( d . getDay ( ) === 1 ) { weekStart = new Date ( d . getFullYear ( ) , d . getMonth ( ) , d . getDate ( ) ) ; } else if ( d . getDay ( ) === 0 ) { weekStart = new Date ( d . getFullYear ( ) , d . getMonth ( ) , d . getDate ( ) ) ; weekStart . setDate ( weekStart . getDate ( ) - 6 ) ; } else { weekStart = new Date ( d . getFullYear ( ) , d . getMonth ( ) , d . getDate ( ) - d . getDay ( ) + 1 ) ; } } var endDate = new Date ( weekStart ) ; var stop = range ; if ( typeof range !== "object" ) { stop = new Date ( endDate . setDate ( endDate . getDate ( ) + range * 7 ) ) ; } return ( this . options . weekStartOnMonday === true ) ? d3 . time . mondays ( Math . min ( weekStart , stop ) , Math . max ( weekStart , stop ) ) : d3 . time . sundays ( Math . min ( weekStart , stop ) , Math . max ( weekStart , stop ) ) ; }
Return all the weeks between 2 dates

@param  Date	d	A date
@param  int|date	range	Number of minutes in the range, or a stop date
@return array	An array of weeks
Return all the weeks between 2 dates