dist/ng-flat-datepicker.js
function getWeeks (date) {

                    var weeks = [];
                    var date = moment.utc(date);
                    var firstDayOfMonth = moment(date).date(1);
                    var lastDayOfMonth  = moment(date).date(date.daysInMonth());

                    var startDay = moment(firstDayOfMonth);
                    var endDay   = moment(lastDayOfMonth);
                    // NB: We use weekday() to get a locale aware weekday
                    startDay = firstDayOfMonth.weekday() === 0 ? startDay : startDay.weekday(0);
                    endDay   = lastDayOfMonth.weekday()  === 6 ? endDay   : endDay.weekday(6);

                    var currentWeek = [];

                    for (var start = moment(startDay); start.isBefore(moment(endDay).add(1, 'days')); start.add(1, 'days')) {

                        var afterMinDate  = !scope.config.minDate || start.isAfter(scope.config.minDate, 'day');
                        var beforeMaxDate = !scope.config.maxDate || start.isBefore(scope.config.maxDate, 'day');
                        var isFuture      = start.isAfter(today);
                        var beforeFuture  = scope.config.allowFuture || !isFuture;

                        var day = {
                            date: moment(start).toDate(),
                            isToday: start.isSame(today, 'day'),
                            isInMonth: start.isSame(firstDayOfMonth, 'month'),
                            isSelected: start.isSame(dateSelected, 'day'),
                            isSelectable: afterMinDate && beforeMaxDate && beforeFuture
                        };

                        currentWeek.push(day);

                        if (start.weekday() === 6 || start === endDay) {
                            weeks.push(currentWeek);
                            currentWeek = [];
                        }
                    }

                    return weeks;
                }
function getWeeks (date) {

                    var weeks = [];
                    var date = moment.utc(date);
                    var firstDayOfMonth = moment(date).date(1);
                    var lastDayOfMonth  = moment(date).date(date.daysInMonth());

                    var startDay = moment(firstDayOfMonth);
                    var endDay   = moment(lastDayOfMonth);
                    // NB: We use weekday() to get a locale aware weekday
                    startDay = firstDayOfMonth.weekday() === 0 ? startDay : startDay.weekday(0);
                    endDay   = lastDayOfMonth.weekday()  === 6 ? endDay   : endDay.weekday(6);

                    var currentWeek = [];

                    for (var start = moment(startDay); start.isBefore(moment(endDay).add(1, 'days')); start.add(1, 'days')) {

                        var afterMinDate  = !scope.config.minDate || start.isAfter(scope.config.minDate, 'day');
                        var beforeMaxDate = !scope.config.maxDate || start.isBefore(scope.config.maxDate, 'day');
                        var isFuture      = start.isAfter(today);
                        var beforeFuture  = scope.config.allowFuture || !isFuture;

                        var day = {
                            date: moment(start).toDate(),
                            isToday: start.isSame(today, 'day'),
                            isInMonth: start.isSame(firstDayOfMonth, 'month'),
                            isSelected: start.isSame(dateSelected, 'day'),
                            isSelectable: afterMinDate && beforeMaxDate && beforeFuture
                        };

                        currentWeek.push(day);

                        if (start.weekday() === 6 || start === endDay) {
                            weeks.push(currentWeek);
                            currentWeek = [];
                        }
                    }

                    return weeks;
                }
function getWeeks ( date ) { var weeks = [ ] ; var date = moment . utc ( date ) ; var firstDayOfMonth = moment ( date ) . date ( 1 ) ; var lastDayOfMonth = moment ( date ) . date ( date . daysInMonth ( ) ) ; var startDay = moment ( firstDayOfMonth ) ; var endDay = moment ( lastDayOfMonth ) ; // NB: We use weekday() to get a locale aware weekday startDay = firstDayOfMonth . weekday ( ) === 0 ? startDay : startDay . weekday ( 0 ) ; endDay = lastDayOfMonth . weekday ( ) === 6 ? endDay : endDay . weekday ( 6 ) ; var currentWeek = [ ] ; for ( var start = moment ( startDay ) ; start . isBefore ( moment ( endDay ) . add ( 1 , 'days' ) ) ; start . add ( 1 , 'days' ) ) { var afterMinDate = ! scope . config . minDate || start . isAfter ( scope . config . minDate , 'day' ) ; var beforeMaxDate = ! scope . config . maxDate || start . isBefore ( scope . config . maxDate , 'day' ) ; var isFuture = start . isAfter ( today ) ; var beforeFuture = scope . config . allowFuture || ! isFuture ; var day = { date : moment ( start ) . toDate ( ) , isToday : start . isSame ( today , 'day' ) , isInMonth : start . isSame ( firstDayOfMonth , 'month' ) , isSelected : start . isSame ( dateSelected , 'day' ) , isSelectable : afterMinDate && beforeMaxDate && beforeFuture } ; currentWeek . push ( day ) ; if ( start . weekday ( ) === 6 || start === endDay ) { weeks . push ( currentWeek ) ; currentWeek = [ ] ; } } return weeks ; }
Get all weeks needed to display a month on the Datepicker
@return {array} list of weeks objects
Get all weeks needed to display a month on the Datepicker