Results 1 to 2 of 2

Thread: Calender help

  1. #1
    Join Date
    Nov 2010
    Posts
    11
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Calender help

    I need help fixing the calculation function below, I think that's the problem.

    Code:
    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/...calendar.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!
    Last edited by jscheuer1; 11-22-2010 at 03:26 PM. Reason: format code

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The link:

    http://www.javascriptkit.com/script/...calendar.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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •