getMonthMatrix(year, month_index) {
        var first_day_of_week = this.getDayOfWeekOfFirstMonthDay(year, month_index);
        var days_in_month = this.getDaysInMonth(year, month_index);
        var weeks_in_month = this.getWeeksInMonth(year, month_index);

        var matrix = [];
        var day_nr = 1;
        for (var j = 0; j < weeks_in_month; j++) {
            matrix[j] = [];
            for (var k = 0; k < 7; k++) {
                var td = document.createElement('td');
                if (j == 0) {
                    // if first week
                    if (k >= first_day_of_week) {
                        matrix[j][k] = day_nr;
                        day_nr++;
                    } else {
                        matrix[j][k] = null;
                    }
                } else if (j == weeks_in_month - 1) {
                    // if last week
                    if (day_nr <= days_in_month) {
                        matrix[j][k] = day_nr;
                        day_nr++;
                    } else {
                        matrix[j][k] = null;
                    }
                } else {
                    // mid weeks
                    matrix[j][k] = day_nr;
                    day_nr++;
                }
            }
        }
        return matrix;
    }
Get matrix (table of 4-5 rows and 7 columns) of month of year.
Each cell contains month day number (1-31) or null if day belongs to previous/next month
Matrix can be used to easily build custom calendar/datepicker
@param  year
@param  month_index
@returns  {Array} - 2D array