Programming/Coding (HTML, JavaScript)
Calculate date of Easter source code below
JavaScript code for calculating the date of Easter (for years 1000 - 3000)
<html>
<head>
<body> <BODY BGCOLOR = "lightblue" > </body>
<title> Calculate Easter Version 0.1B by tomyy@optonline.net. </title>
<script type="text/javascript">
document.write("<font size='+2' color=Green><center> Todd Middle School (Ipad Edition) - Easter Formula release V0.1B </center></font>")
document.write(" ")
/************************************************************************/
/* Tom Yurkovic tomyy@optonline.net */
/************************************************************************/
dte = new Date()
/* alert("dte is " + dte ) */
mm = dte.getMonth()
mm = mm-0
mm = mm+1
dd = dte.getDate()
yy = dte.getYear()
/*alert ("yy=" +yy)*/
todays_date = mm +'/' + dd + '/' + yy
/*****************************************/
/* */
/* GLOBAL Variables */
/* variables defined here are global */
/* */
/*****************************************/
var hdr1
var outputLine = new Array()
var temp
var ol
var nlo /* Numberof Linesof Output */
ol=1 /* Output Line */
var retAmt
var errfnd = 'N'
var a
var b
var c
var d
var e
var f
var g
var h
var j
var k
var l
var m
var mon
var y
var year
var day
/************************************************************/
/* */
/* Function: main() */
/* */
/************************************************************/
function main() {
temp = ckInput()
/*
alert("returned from ckInput with temp = "+temp )
alert("returned from ckInput with errfnd = "+errfnd )
*/
errfnd = "N"
if (errfnd == "N")
{
temp = display()
/* alert ("returned from display with temp = " +temp)*/
}
} /* end of Main */
/************************************************************/
/* */
/* Function: open a new window */
/* */
/* */
/************************************************************/
function openNew() {
myWindow=window.open('','','width=452,height=370,resizable=yes,scrollbars=yes' )
myWindow.document.write("<form name=east3 bgcolor= 'lightblue' > ")
myWindow.document.write("<body bgcolor=darkseagreen> <title> HTMC </title> ")
myWindow.document.write("<center><p><b><u><font color=black size=+1> HT Math Club - Easter Formula </u></b><br></center>")
myWindow.document.write("<br><br> ")
myWindow.document.write("Here is the easter Formula: ")
myWindow.document.write("<br> ")
myWindow.document.write("a = Y mod 19 ")
myWindow.document.write("<br> ")
myWindow.document.write("b = Y / 100 ")
myWindow.document.write("<br> ")
myWindow.document.write("c = Y mod 100 ")
myWindow.document.write("<br> ")
myWindow.document.write("d = b / 4 ")
myWindow.document.write("<br> ")
myWindow.document.write("e = b mod 4 ")
myWindow.document.write(" ")
myWindow.document.write("f = (" +b +"+ 8) / 25 ")
myWindow.document.write("f = "+b + 8 +" / 25 ")
myWindow.document.write("f = (b + 8) / 25 ")
myWindow.document.write("<br> ")
myWindow.document.write("g = (b - f + 1) / 3 ")
myWindow.document.write("<br> ")
myWindow.document.write("h = (19 × a + b - d - g + 15) mod 30 ")
myWindow.document.write("<br> ")
myWindow.document.write("i = c / 4 ")
myWindow.document.write("<br> ")
myWindow.document.write("k = c mod 4 ")
myWindow.document.write("<br> ")
myWindow.document.write("L = (32 + 2 × e + 2 × i - h - k) mod 7 ")
myWindow.document.write("<br> ")
myWindow.document.write("m = (a + 11 × h + 22 × L) / 451 ")
myWindow.document.write("<br> ")
myWindow.document.write("month = (h + L - 7 × m + 114) / 31 ")
myWindow.document.write("<br> ")
myWindow.document.write("day = ((h + L - 7 × m + 114) mod 31) + 1 ")
myWindow.document.write("<br> ")
myWindow.document.write("<HR> ")
myWindow.document.write("<br> ")
myWindow.document.write("Note: ")
myWindow.document.write("<br> ")
myWindow.document.write(" mod means division ===> ignore quotient, keep remainder ")
myWindow.document.write("<br> ")
myWindow.document.write(" / means integer division ===> keep quotient, ignore remainder ")
myWindow.document.write("<br> ")
myWindow.document.write("<br> ")
myWindow.document.write(" Example: 16 / 3 = 5 remainder 1 ")
myWindow.document.write("<br> ")
myWindow.document.write("16 is the dividend ")
myWindow.document.write("<br> ")
myWindow.document.write(" 3 is the divisor ")
myWindow.document.write(" 5 is the quotient ")
myWindow.document.write(" 1 is the remainder ")
myWindow.document.write("</form> ")
}
/************************************************************/
/* */
/* Function: ckInput() */
/* */
/* */
/************************************************************/
function ckInput() {
year = document.forms[0].avs.value
return year
}
/************************************************************/
/* */
/* Function: ckInput() */
/* */
/************************************************************/
function display() {
y = year
if (year < 1000 | year > 3000) {
alert("Please enter a year >1000 & < 3000")
errfnd = "Y"
document.Form.out.value = "Invalid year"
}
else {
/* openNew() */
y = year
a = y%19
b = parseInt(y/100)
c = y % 100
d = parseInt(b/4)
e = b % 4
f = parseInt((b+8)/25)
g = parseInt((b - f + 1) /3)
h = (19*a+b-d-g+15) % 30
i = parseInt(c/4)
k = c % 4
l = (32 + 2*e +2 * i-h-k) % 7
m = parseInt((a + 11 * h + 22 * l) / 451)
mon= parseInt((h+l-7*m+114)/31)
day = ((h + l - 7 * m +114) % 31 )+1
document.Form.out.value = ""
document.Form.out.value = document.Form.out.value +"a = " +a +" " +"\n"
document.Form.out.value = document.Form.out.value +"b = " +b +" " +"\n"
document.Form.out.value = document.Form.out.value +"c = " +c +" " +"\n"
document.Form.out.value = document.Form.out.value +"d = " +d +" " +"\n"
document.Form.out.value = document.Form.out.value +"e = " +e +" " +"\n"
document.Form.out.value = document.Form.out.value +"f = " +f +" " +"\n"
document.Form.out.value = document.Form.out.value +"g = " +g +" " +"\n"
document.Form.out.value = document.Form.out.value +"h = " +h +" " +"\n"
document.Form.out.value = document.Form.out.value +"i = " +i +" " +"\n"
document.Form.out.value = document.Form.out.value +"k = " +k +" " +"\n"
document.Form.out.value = document.Form.out.value +"l = " +l +" " +"\n"
document.Form.out.value = document.Form.out.value +"m = " +m +" " +"\n"
document.Form.out.value = document.Form.out.value +"y = " +y +" " +"\n"
document.Form.out.value = document.Form.out.value +"mon = " +mon +" " +"\n"
document.Form.out.value = document.Form.out.value +"day = " +day +" " +"\n"
}
/*
alert("a =" +a
+ "\n b =" +b
+ "\n c =" +c
+ "\n d =" +d
+ "\n e =" +e
+ "\n f =" +f
+ "\n g =" +g
+ "\n h =" +h
+ "\n i =" +i
+ "\n k =" +k
+ "\n l =" +l
+ "\n m =" +m
+ "\n y =" +y
+ "\n mon =" +mon
+ "\n day =" +day)
*/
} /* end of Function display() */
function doIt(theForm) {
defval="Tbd"
}
</script>
<form name=Form bgcolor= "lightblue" >
<br><br>
Calculate for year :
<input type="text" STYLE="color:#FEFEFE; font-style:bold ;background-color: darkblue;font-size:150%;"; value="2017" name="avs" onFocus="this.value=' ' " size=30 maxlength=6 > <br>
<br><hr><br>
<input type="button" STYLE="color:#FEFEFE; font-style:bold ;background-color: darkblue;font-size:100%;";
value="Calculate Easter & Display Formula in a window " onClick="main()" >
<br>
<br>
Results:
<textarea name=out rows=14 cols=25 wrap=virtual STYLE="color: Black; background-color: #C0C0C0;" >
</textarea>
<br>