// JavaScript Month Calendar for website (C)2001-2007 Jan Kaluza
// -- v2.7 r3 -- 20070302
//
Usage Example
//
//
//
//
//
function thisMonth() {
var muns = new Array("January","February","March","April","May","June",
"July","August","September","October","November","December");
var deew = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
var mday = new Array(31,0,31,30,31,30,31,31,30,31,30,31);
dt = new Date();
yr = dt.getFullYear();
mo = dt.getMonth();
dy = dt.getDate();
dw = dt.getDay();
md1 = (dw + 7 - (dy % 7) + 1) % 7;
mday[1] = (isLeap(yr)==1)?29:28;
jd=0; cm=0;
while (cm < mo) {
jd += mday[cm];
cm++;
}
jd += dy;
d1 = (jd + 7 - (dw % 7) + 1) % 7;
document.write("");
calGrid(md1,mday[mo],muns[mo]+" "+yr,dy);
// wkn = Math.ceil((jd + d1) / 7);
// if (dy<10) { dy="0"+dy; }
// if (wkn<10) { wkn="0"+wkn; }
// if (jd<100) { if (jd<10){jd="00"+jd;}else{jd="0"+jd;} }
// document.write(""+deew[dw]+" ");
// document.write(dy+"-"+muns[mo].substring(0,3)+"-"+yr);
// document.writeln(" Week "+wkn+" Day "+jd+"");
}
function isLeap(yy) {
if ((yy%400)==0) return 1; if ((yy%100)==0) return 0;
if ((yy%4)==0) return 1; return 0;
}
function calGrid(wd1,dys,ttl,ddxx) {
document.write("");
if (ttl != "") { document.write("| "+ttl+" |
"); }
document.write("| SU | ");
document.write("Mo | ");
document.write("Tu | ");
document.write("We | ");
document.write("Th | ");
document.write("Fr | ");
document.write("Sa |
");
wd = 0; md = 1; while (wd < wd1) { document.write("| - | "); wd++; }
while (md <= dys) {
if (md == ddxx) {
document.write(""+md+" | ");
} else {
document.write(""+md+" | ");
}
md++; wd++; if (wd==7) { if (md < dys) {
document.write("
"); } else {
document.write("
"); } wd = 0; } }
if (wd > 0) {
while (wd<7) { document.write("- | "); wd++; }
}
document.writeln("
");
}
// == END ==