PDA

View Full Version : Calender help

c1lonewolf
11-22-2010, 03:20 PM
I need help fixing the calculation function below, I think that's the problem.

function easter(year) {
// feed in the year it returns the month and day of Easter using two GLOBAL variables: eastermonth and easterday
var a = year % 19;
var b = Math.floor(year/100);
var c = year % 100;
var d = Math.floor(b/4);
var e = b % 4;
var f = Math.floor((b+8) / 25);
var g = Math.floor((b-f+1) / 3);
var h = (19*a + b - d - g + 15) % 30;
var i = Math.floor(c/4);
var j = c % 4;
var k = (32 + 2*e + 2*i - h - j) % 7;
var m = Math.floor((a + 11*h + 22*k) / 451);
var month = Math.floor((h + k - 7*m + 114) / 31);
var day = ((h + k - 7*m +114) % 31) + 1;
eastermonth = month;
easterday = day;
}

This is extracted from an event calender posted to Javascript Kit.
http://www.javascriptkit.com/script/script2/eventscalendar.shtml

The problem is how it handles 'Easter'.
2002-2005-2008<< (present 20210) >> 2013-2016-2018
The forward and backward years shown above do not show 'Easter' at all. I believe it's a calculation error. I checked the original on site script to be sure I didn't mess something up, but itdoesn't work on theirs either. Can someone help me fix the equations?

Thanks in advance!

jscheuer1
11-22-2010, 07:19 PM
The link:

http://www.javascriptkit.com/script/script2/eventscalendar.shtml

works fine here for Easter past present and future.

What browser (include browser version) are you using?

Are you using something other than the buttons on the calendar to set the years and months?

If you want more help: Please post a link to a page on your site that contains the problematic code so we can check it out.

Oh, and let me know the browser and what version of it you're using.