1. #1
    Sencha User
    Join Date
    Oct 2007
    Location
    Berlin, Germany
    Posts
    888
    Vote Rating
    9
    wm003 will become famous soon enough

      0  

    Default Ext.util.EasterDate

    Ext.util.EasterDate


    For calculation of my national holidays i needed to calculate the easter Date of each year.

    The following Function returns a Date-Object of Easter-Sunday of a given year. If no year is given the routine will use the current year.

    [UPDATE 2008/03/28]
    Added option to add/subtract a number of days from the calculated eastersunday

    e.g.
    Ext.util.EasterDate(2008) returns a DateObject of 2008/03/23
    Ext.util.EasterDate(2008,5) returns a DateObject of 2008/03/28
    Ext.util.EasterDate(2008,-3) returns a DateObject of 2008/03/20


    PHP Code:
        Ext.util.EasterDate = function(yearplusDays) {
            if (
    typeof year === "undefined") {
                
    year = new Date().getFullYear();
            }
            
    year parseInt(year,10);

            if (
    typeof plusDays === "undefined") {
                
    plusDays 0;
            }
            
    plusDays parseInt(plusDays,10);
        
        
    //difference to first sunday after first fullmoon after beginning of spring
            
    var year 19;
            var 
    = (19 24) % 30;
            var 
    diffDay + (* (year 4) + * (year 7) + 5) % 7;
            if ((
    diffDay == 35) || ((diffDay == 34) && (== 28) && (10))) {
                
    diffDay -= 7;
            }
        
            var 
    EasterDate = new Date(year222);    //beginning of spring
            
    EasterDate.setTime(EasterDate.getTime() + 86400000 diffDay 86400000 plusDays);
            return 
    EasterDate;
        }; 

  2. #2
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    interesting plugin, but
    "Ext can only calculate DateObjects between 1970 and 2099"
    i didn't know that...

    are you sure?

  3. #3
    Sencha User
    Join Date
    Oct 2007
    Location
    Berlin, Germany
    Posts
    888
    Vote Rating
    9
    wm003 will become famous soon enough

      0  

    Default


    Mmh, i read about this on the net somewhere, that javascript should have these restrictions on 32-Bit machines....anyway i did some more testing and it also seems to work with other years such as 3100 and 1960....

    I deleted the exception-catch out of the code, so it should work for any year now.

    Thanks for pointing that out

  4. #4
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    Quote Originally Posted by wm003 View Post
    Mmh, i read about this on the net somewhere, that javascript should have these restrictions on 32-Bit machines....anyway i did some more testing and it also seems to work with other years such as 3100 and 1960....

    I deleted the exception-catch out of the code, so it should work for any year now.

    Thanks for pointing that out
    do you happen to have the URL to the article?
    might be good to know.

  5. #5
    Sencha User
    Join Date
    Oct 2007
    Location
    Berlin, Germany
    Posts
    888
    Vote Rating
    9
    wm003 will become famous soon enough

      0  

    Default


    Quote Originally Posted by mystix View Post
    do you happen to have the URL to the article?
    might be good to know.
    e.g:
    http://jneumeyer.com/Chap10Notes.htm

    He talks only about the 1970 thing

    The original javascript routine i had adopted the code above also had this restriction set. And i never doubt about that myself (maybe because i never happened to use any date outside this range)
    The quote about the 32-Bit machines i read in the PHP-Docs for easter_date.

  6. #6

  7. #7
    Sencha User Ronhead's Avatar
    Join Date
    May 2008
    Location
    Santiasko,Chile
    Posts
    38
    Vote Rating
    0
    Ronhead is on a distinguished road

      0  

    Default Where you apply it?

    Where you apply it?


    @wm003, I was looking where apply this method, but don't was so lucky... Where do you thought add it?

  8. #8

Thread Participants: 2