       @range[0] = moment(d)
       @$body.empty()
 
-      for j in [0..6]
-        for i in [0..7]
+      for j in [0..5]
+        for i in [0..6]
           classes = ['day']
 
           classes.push('first') if i == 0
-          classes.push('last')  if i ==6
+          classes.push('last')  if i == 6
 
           if @now.month() != d.month()
             classes.push('not-in-month')

      collision: 'fit'

    events:
      "mousedown .datepicker-prev": (e) ->
        e.preventDefault()
        @prev()

      "mousedown .datepicker-next": (e) ->
        e.preventDefault()
        @next()

      "mousedown .day": (e) ->
        e.preventDefault()
        @select(e.target.getAttribute("data-datestamp"))



      @monthHeader = $('<div class="datepicker-title">' + @now.format(@headerFormat) + '</div>')

      dayLabels = _.map(["Sun", "Mon", "Tue", "Wed", "Thurs", "Fri", "Sat"], (str) -> '<span>' + str.substr(0, 1) + '</span>')
      dayLabels = dayLabels.concat(dayLabels.splice(0, @firstDayOfWeek))
      $(document.createElement("div"))
            .addClass('datepicker-header-inner')
            .append(prevBtn)
            .append(this.monthHeader)
            .append(nextBtn)
            .append('<div class="datepicker-daysofweek">' + dayLabels.join('') + '</div>')
            .appendTo(@$header)

      @$header
