Calculate the date of Easter Sunday

后端 未结 6 624
半阙折子戏
半阙折子戏 2020-12-11 16:32

Write a program to compute the date of Easter Sunday. Easter Sunday is the first Sunday after the first full moon of spring. Use the algorithm invented by the mathematician

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-11 16:40

    ...or someone needs it in ColdFusion:

    
    
        
        
    
            var currentYear = arguments["year"];
    
            var a = floor(currentYear % 19);
            var b = floor(currentYear / 100);
            var c = floor(currentYear % 100);
            var d = floor(b / 4);
            var e = floor(b % 4);
            var f = floor((b + 8) / 25);
            var g = floor((b - f + 1) / 3);
            var h = floor((19 * a + b - d - g + 15) % 30);
            var i = floor(c / 4);
            var k = floor(c % 4);
            var l = floor((32 + 2 * e + 2 * i - h - k) % 7);
            var m = floor((a + 11 * h + 22 * l) / 451);
            var n = floor((h + l - 7 * m + 114) / 31);
            var p = floor(((h + l - 7 * m + 114) % 31) + 1);
    
            var month = n;
            if (len(month) lt 2) {
                month = "0" & month;
            } 
    
            var day = p;
            if (len(day) lt 2) {
                day = "0" & day;
            }
    
            var dateString = day & '.' & month & '.' & currentYear;
    
            return dateString;
    
        
    
    

提交回复
热议问题