I'm trying to draw table having 3 rows.
First row should have month name, second - number of day in month and third day of week.
Something like this:
I managed to do something that looks like this, but only for 2013. What I would like to get custom table for specific time period. So if I specify that I want table from 2013-01-15 to 2013-02-10 then it will have 27 columns in second and third row and 2 in first (with correct rowspan).
This is what I have right now: http://jsfiddle.net/Misiu/amEug/
This is my code for table generation for current year:
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var monthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var dayNames = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Sn"];
var months = '';
for (var i = 0; i < monthNames.length; i++) {
months += '<td colspan="' + monthDays[i] + '">' + monthNames[i] + '</td>';
}
$('tr#months').html(months);
var numbers = '';
var counter = 1;
var month = 0;
for (i = 0; i < 365; i++) {
numbers += '<td>' + counter + '</td>';
counter++;
if (counter > monthDays[month]) {
month++;
counter = 1;
}
}
$('tr#numbers').html(numbers);
var days = '';
var day = 0;
for (i = 0; i < 365; i++) {
days += '<td' + (dayNames[day] == 'Sa' || dayNames[day] == 'Sn' ? ' class="weekend"' : '') + '>' + dayNames[day] + '</td>';
day++;
if (day > 6) day = 0;
}
$('tr#days').html(days);
Also I would like it to be as fast as possible, because if for some reason I would need large time period (4 years) I would like it to render fast (even on IE8).
Any advice on how to get this working will help. I've looked at jQuery UI datepicker code, but it is complex and has all features I don't need.