<commit_before><commit_msg>added week logic<commit_after>app.controller('DateDelegator', function ($scope, WeekFactory) {

	// constants
	// @TODO should we use angular constants?
	$scope.START_DAY = 0;
	$scope.END_DAY = 6;

	/**
	 * @type {Array}
	 */
	$scope.weeks = [];

	/**
	 * Initializer
	 * @return {undefined} 
	 */
	$scope.init = function () {
		$scope.setWeek();
	};

	/**
	 * Create week configuration
	 * @param {String|Date|Moment} date 
	 * @return {undefined}
	 */
	$scope.setWeek = function (date) {
		var days = $scope.createWeek(date);

		// push out week info
		$scope.weeks.push({
			days: days,
			label: $scope.getRangeLabel(days[$scope.START_DAY], days[$scope.END_DAY])
		});
	};

	/**
	 * Week factory
	 * @param  {String|Date|Moment} date 
	 * @return {Array} list of `Moment`s
	 */
	$scope.createWeek = function (date) {
		// `moment(undefined)` is now, which means an empty arg is now
		return WeekFactory.getWeekFromDay(moment(date));
	};

	/**
	 * Return range label
	 * @param  {Moment} startDate 
	 * @param  {Moment} endDate   
	 * @return {String}           
	 */
	$scope.getRangeLabel = function (startDate, endDate) {
		// format
		var fullFormat = 'MMMM Do';

		// logic to determine end label
		function getEndLabel() {
			return endDate.format(startDate.month() === endDate.month() ? 'Do' : fullFormat);
		}

		// return full string
		return [startDate.format(fullFormat),getEndLabel()].join(' - ');
	}
});
{'fraction_non_alphanumeric': 0.16470588235294117, 'fraction_numerical': 0.001384083044982699, 'mean_word_length': 3.2781065088757395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5887556', 'n_tokens_mistral': 535, 'n_tokens_neox': 480, 'n_words': 112}