Advertisement
5_2007-2008 Clocks #181087

Calculate the week # of the year

Calculates what the week number is for the year, according to the current date.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>The week number of this year is....</title>
<meta name="author" content="DJ Hall">
<meta name="description" content="Find what week of the year it is.">
<script>
			//to test change Date to Date(yyyy,mm,dd) Remember for the month, Jan = 00
now = new Date()
			//Creates a date object that equals the first day of the current year.
curryearstart = new Date(now.getFullYear(),00,01)
			//valueOf() returns the number of milliseconds passed since Midnight Jan 1, 1970.
			//86400000 = Number of milliseconds in a day
dayselapsed = (now.valueOf() - curryearstart.valueOf()) / 86400000
			//calculates what day of week the year started on and adds
			//it to the number of days elapsed in the year.
weeknum = parseInt((dayselapsed + curryearstart.getDay()) / 7) + 1
document.write("Today, " + now.toString().slice(0,10) + ", is in week # " + "<span style='font-weight:bold;font-size:125%;color:firebrick'>" + weeknum + "</span> of the year " + now.getFullYear())

</script>
</head>
<body>
</body>
</html>
Upload
Original Comments (3)
Recovered from Wayback Machine