You are here: irt.org | Articles | JavaScript | Date and Time | Easter [ previous next ]
Published on: Saturday 6th December 1997 By: Martin Webb
<HTML><HEAD> <SCRIPT LANGUAGE="JavaScript"><!-- function y2k(number) { return (number < 1000) ? number + 1900 : number; } var today = new Date(); var year = y2k(today.getYear()); //--></SCRIPT> <FRAMESET ROWS="50%,50%"> <FRAME SCROLLING=NO FRAMEBORDER=0 BORDER=0 NORESIZE SRC="input.htm"> <FRAME SCROLLING=YES FRAMEBORDER=0 BORDER=0 NORESIZE SRC="blank.htm" NAME="outputFrame"> </FRAMESET> </HEAD></HTML>
<BODY></BODY>
<HTML><HEAD> <LINK REL=STYLESHEET HREF="../../utility/main.css" TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript"><!-- function ChosenDate(object) { year = object.year.value; if (parent.location.href != window.location.href) { parent.year = year; parent.outputFrame.location.href = 'output.htm'; } else { return true; } return false; } function y2k(number) { return (number < 1000) ? number + 1900 : number; } var today = new Date(); var thisYear = y2k(today.getYear()); var yearOutput = '<INPUT TYPE="TEXT" NAME="year" SIZE="4" VALUE="' + thisYear + '">'; //--></SCRIPT> </HEAD> <BODY><FONT FACE="ARIAL,HELVETICA"><CENTER> <H2>Select year:</H2> <FORM NAME="inputDateForm" ACTION="output.htm" onSubmit="return ChosenDate(document.inputDateForm);"> Year: <SCRIPT LANGUAGE="JavaScript"><!-- document.write(yearOutput); //--></SCRIPT> <INPUT TYPE="SUBMIT" VALUE="Show"> </FORM> <A HREF="index.htm" TARGET="_parent">Return</A> </CENTER></FONT></BODY> </HTML>
<HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"><!-- function Easter(Y) { var C = Math.floor(Y/100); var N = Y - 19*Math.floor(Y/19); var K = Math.floor((C - 17)/25); var I = C - Math.floor(C/4) - Math.floor((C - K)/3) + 19*N + 15; I = I - 30*Math.floor((I/30)); I = I - Math.floor(I/28)*(1 - Math.floor(I/28)*Math.floor(29/(I + 1))*Math.floor((21 - N)/11)); var J = Y + Math.floor(Y/4) + I + 2 - C + Math.floor(C/4); J = J - 7*Math.floor(J/7); var L = I - J; var M = 3 + Math.floor((L + 40)/44); var D = L + 28 - 31*Math.floor(M/4); return padout(M) + '.' + padout(D); } function padout(number) { return (number < 10) ? '0' + number : number; } function getMM(string) { return eval(string.substring(0,2)); } function getDD(string) { return eval(string.substring(3,5)); } function makeArray() { this[0] = makeArray.arguments.length; for (i = 0; i<makeArray.arguments.length; i++) this[i+1] = makeArray.arguments[i]; } var accumulate = new makeArray( 0, 31, 59, 90,120,151,181,212,243,273,304,334); var accumulateLY = new makeArray( 0, 31, 60, 91,121,152,182,213,244,274,305,335); function LeapYear(year) { if ((year/4) != Math.floor(year/4)) return false; if ((year/100) != Math.floor(year/100)) return true; if ((year/400) != Math.floor(year/400)) return false; return true; } function daysinyear(year) { if (LeapYear(year)) return 366; else return 365; } function addDays(day,month,year,addition) { if (LeapYear(year)) var number = day + accumulateLY[month] + addition; else var number = day + accumulate[month] + addition; var days = daysinyear(year); while (number > days) { number -= days; days = daysinyear(++year); } while (number < 1) { days = daysinyear(--year); number += days; } month = 1; if (LeapYear(year)) { while (number > accumulateLY[month]) { month++; } day = number - accumulateLY[--month]; } else { while (number > accumulate[month]) { month++; } day = number - accumulate[--month]; } return year + '.' + padout(month) + '.' + padout(day); } function getYYYY(string) { return eval(string.substring(0,string.indexOf('.'))); } function getMMDD(string) { return string.substring(string.indexOf('.')+1,string.length); } var daysofweek = new makeArray('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); var monthsofyear = new makeArray('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); function DayOfWeek(day,month,year) { var a = Math.floor((14 - month)/12); var y = year - a; var m = month + 12*a - 2; var d = (day + y + Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400) + Math.floor((31*m)/12)) % 7; return d+1; } function Nths(day) { if (day == 1 || day == 21 || day == 31) return 'st'; if (day == 2 || day == 22) return 'nd'; if (day == 3 || day == 23) return 'rd'; return 'th'; } function FullDate(day,month,year) { return daysofweek[DayOfWeek(day,month,year)] +' '+ day + Nths(day) +' '+ monthsofyear[month] +' '+ year; } //--></SCRIPT> </HEAD> <BODY><CENTER> <SCRIPT LANGUAGE="JavaScript"><!-- if (location.search.length == 0) var year = parent.year - 0; else var year = location.search.substring(6) - 0; var easter = Easter(year); var easterDay = getDD(easter); var easterMonth = getMM(easter); var when = addDays(easterDay,easterMonth,year,-63); document.write('Septuagesima Sunday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,-56); document.write('Sexagesima Sunday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,-49); document.write('Shrove Sunday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,-47); document.write('Shrove Tuesday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,-46); document.write('Ash Wednesday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,-14); document.write('Passion Sunday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,-7); document.write('Palm Sunday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,-3); document.write('Holy or Maundy Thursday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,-2); document.write('Good Friday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); document.write('Easter Sunday - ' + FullDate(easterDay,easterMonth,year)+'<BR>'); var when = addDays(easterDay,easterMonth,year,35); document.write('Rogation Sunday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,39); document.write('Ascension Day - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,49); document.write('Pentecost or Whitsunday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,50); document.write('Whitmundy - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,56); document.write('Trinity Sunday - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,60); document.write('Corpus Christi - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); var when = addDays(easterDay,easterMonth,year,63); document.write('Corpus Christi (Catholic Church in the United States) - ' + FullDate(getDD(getMMDD(when)),getMM(getMMDD(when)),getYYYY(when))+'<BR>'); //--></SCRIPT> <P><A HREF="index.htm" TARGET="_parent">Return</A> </CENTER></BODY> </HTML>
And now...The Weekly Update Script
Extending "Born of the 4th of July"