Календарик

Под катом полная версия на 2013 год и код генератора на любой год.

function January_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',    '',     1,     2,     3,     4,    '5' ],
		[    '6',     7,     8,     9,    10,    11,   '12' ],
		[   '13',    14,    15,    16,    17,    18,   '19' ],
		[   '20',    21,    22,    23,    24,    25,   '26' ],
		[   '27',    28,    29,    30,    31,    '',    ''  ]
	];
}
,
function February_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',    '',    '',    '',    '',     1,    '2' ],
		[    '3',     4,     5,     6,     7,     8,    '9' ],
		[   '10',    11,    12,    13,    14,    15,   '16' ],
		[   '17',    18,    19,    20,    21,    22,   '23' ],
		[   '24',    25,    26,    27,    28,    29,   '30' ],
		[   '31',    '',    '',    '',    '',    '',    ''  ]
	];
}
,
function March_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',    '',    '',    '',    '',     1,    '2' ],
		[    '3',     4,     5,     6,     7,     8,    '9' ],
		[   '10',    11,    12,    13,    14,    15,   '16' ],
		[   '17',    18,    19,    20,    21,    22,   '23' ],
		[   '24',    25,    26,    27,    28,    '',    ''  ]
	];
}
,
function April_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',     1,     2,     3,     4,     5,    '6' ],
		[    '7',     8,     9,    10,    11,    12,   '13' ],
		[   '14',    15,    16,    17,    18,    19,   '20' ],
		[   '21',    22,    23,    24,    25,    26,   '27' ],
		[   '28',    29,    30,    31,    '',    '',    ''  ]
	];
}
,
function May_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',    '',    '',     1,     2,     3,    '4' ],
		[    '5',     6,     7,     8,     9,    10,   '11' ],
		[   '12',    13,    14,    15,    16,    17,   '18' ],
		[   '19',    20,    21,    22,    23,    24,   '25' ],
		[   '26',    27,    28,    29,    30,    '',    ''  ]
	];
}
,
function June_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',    '',    '',    '',    '',    '',    '1' ],
		[    '2',     3,     4,     5,     6,     7,    '8' ],
		[    '9',    10,    11,    12,    13,    14,   '15' ],
		[   '16',    17,    18,    19,    20,    21,   '22' ],
		[   '23',    24,    25,    26,    27,    28,   '29' ],
		[   '30',    31,    '',    '',    '',    '',    ''  ]
	];
}
,
function July_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',     1,     2,     3,     4,     5,    '6' ],
		[    '7',     8,     9,    10,    11,    12,   '13' ],
		[   '14',    15,    16,    17,    18,    19,   '20' ],
		[   '21',    22,    23,    24,    25,    26,   '27' ],
		[   '28',    29,    30,    '',    '',    '',    ''  ]
	];
}
,
function August_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',    '',    '',    '',     1,     2,    '3' ],
		[    '4',     5,     6,     7,     8,     9,   '10' ],
		[   '11',    12,    13,    14,    15,    16,   '17' ],
		[   '18',    19,    20,    21,    22,    23,   '24' ],
		[   '25',    26,    27,    28,    29,    30,   '31' ]
	];
}
,
function September_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[    '1',     2,     3,     4,     5,     6,    '7' ],
		[    '8',     9,    10,    11,    12,    13,   '14' ],
		[   '15',    16,    17,    18,    19,    20,   '21' ],
		[   '22',    23,    24,    25,    26,    27,   '28' ],
		[   '29',    30,    31,    '',    '',    '',    ''  ]
	];
}
,
function October_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',    '',     1,     2,     3,     4,    '5' ],
		[    '6',     7,     8,     9,    10,    11,   '12' ],
		[   '13',    14,    15,    16,    17,    18,   '19' ],
		[   '20',    21,    22,    23,    24,    25,   '26' ],
		[   '27',    28,    29,    30,    '',    '',    ''  ]
	];
}
,
function November_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[     '',    '',    '',    '',    '',     1,    '2' ],
		[    '3',     4,     5,     6,     7,     8,    '9' ],
		[   '10',    11,    12,    13,    14,    15,   '16' ],
		[   '17',    18,    19,    20,    21,    22,   '23' ],
		[   '24',    25,    26,    27,    28,    29,   '30' ],
		[   '31',    '',    '',    '',    '',    '',    ''  ]
	];
}
,
function December_2013() {
	return [
		[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],
		[    '1',     2,     3,     4,     5,     6,    '7' ],
		[    '8',     9,    10,    11,    12,    13,   '14' ],
		[   '15',    16,    17,    18,    19,    20,   '21' ],
		[   '22',    23,    24,    25,    26,    27,   '28' ],
		[   '29',    30,    '',    '',    '',    '',    ''  ]
	];
}

И его простенький генератор.

var year = prompt("Enter year", new Date().getFullYear()),
	calendar = [],
	DAYS = {
		SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6
	},
	MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 
		'July', 'August', 'September', 'October', 'November', 'December'];
for (var month = 0; month < 12; month++) {
	var firstDay = new Date(year, month, 1).getDay(),
		days = new Date(year, month, 0).getDate(),			
		lastDay = new Date(year, month, days).getDay(),
 
		str = "\nfunction " + MONTHS[month] + "_" + year + "() ";
	str += "{\n\treturn [\n\t\t[  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',  'Sat' ],";
	if (firstDay !== DAYS.SUN) {
		str += "\n\t\t[ "; 
	}
 
	for(var emptyDay = DAYS.SUN; emptyDay < firstDay; emptyDay++) {
		str += "    '',";
	}	
	for (var day = 1; day <= days; day++) {
		var date = new Date(year, month, day);
		if (date.getDay() === DAYS.SUN) {
			str += "\n\t\t["; 
		}		
		if (day / 10 < 1) { 
			str += " ";
		}
		if (date.getDay() === DAYS.SUN || date.getDay() === DAYS.SAT) {
			str += "   '" + day + "'";
		} else {
			str += "    " + day;
		}
		if (date.getDay() === DAYS.SAT) { 
			str += " ]"; 
			if	(day !== days) {
				str += ",";
			}
		} else {
			str += ",";
		}
	}
	for (emptyDay = lastDay; emptyDay < DAYS.SAT; emptyDay++) {
		str += "    ''";
		if(emptyDay !== DAYS.FRI) {
			str+=",";
		}
	}
	if(lastDay !== DAYS.SAT) {
		str+="  ]";
	}
	str += "\n\t];\n}\n";
	calendar[month] = str;
}
 
var pre = document.getElementsByTagName('pre')[0];
pre.innerHTML = calendar;

Результирующий код подставляется в первый тег pre на странице.

Оставить комментарий


Примечание - Вы можете использовать эти HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>