// Week_Of.js
// 1.0 - r. lundy - 97 Nov 07
//                - return the user's `Week of <the most recent Monday>` in dd Month_Name yy
// 2.0 - r. lundy - 2000 jan 08
//                - NN4.7 displayed year = "100"!

// How to contact the Author: rlundy@ican.net

// Y2K tested - 07 Nov 97, by the author
//     this script does not crash when the year turns to `2000` 

// usage: in HTML file: 
//      [optional formatting]<SCRIPT SRC="/Tools/Week_Of.js"></SCRIPT>[/optional formatting]

var oneDay = 1000 * 60 * 60 * 24;   // 1000 milliseconds/sec * 60 seconds/minute * 60 minutes/hour * 24 hours/day = 1 Day

// NOTE: `date.getMonth()` returns `0` for Jan, `1` for Feb, ..., `11` for Dec  <-------
function monthName(indX) {
   monthNames = new Array("Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember");
   return monthNames[indX];
}

function today(x) {
  return x.getDay();
}

// main()
now = new Date();

while (today(now) != 1) {
  now.setTime(now - oneDay);
}

thisYear = now.getYear();
	if(thisYear < 1900) {thisYear += 1900};  // corrections if Y2K display problem

document.write(now.getDate() + " " + monthName(now.getMonth()) + " " + thisYear);

// the end