var getMonthWeek = function (a, b, c) {
/*
a = d = current date
b = 6 - w = how many days are left in the current week (not counting today)
The sum of a b divided by 7 means that today is the current month Week
*/
var date = new Date(a, parseInt(b) - 1, c), w = date.getDay(), d = date.getDate();
return Math .ceil(
(d 6 - w) / 7
);
};
var getYearWeek = function (a, b, c) {
/*
date1 is the current date
date2 is the first day of the current year
d is the current date’s day of the year
Use d to divide the sum of the week differences of the first day of the current year by 7 to get the day of the year Week
*/
var date1 = new Date(a, parseInt(b) - 1, c), date2 = new Date(a, 0, 1),
d = Math.round((date1 .valueOf() - date2.valueOf()) / 86400000);
return Math.ceil(
(d ((date2.getDay() 1) - 1)) / 7
);
};
document.write(
"Today is the month of the month", getMonthWeek(2007, 03, 19), "Week
"
, "Today is the ", getYearWeek(2007, 03, 19), "week"
);