//https://zh.wikipedia.org/wiki/%E5%BE%A9%E6%B4%BB%E7%AF%80%E7%9A%84%E8%A8%88%E7%AE%97 //Meeus/Jones/Butcher算法(公历) //Jean Meeus在他的书《天文算法》(Astronomical Algorithms,1991年)记载了这个计算公历中的复活节日期的方法,并指这个方法是来自Spencer Jones的书《一般天文学》(General Astronomy,1922年)和《英国天文学会期刊》(Journal of the Brithish Astronomical Association,1977年),后者指方法是来自Butcher's Ecclesiastical Calendar(1876年)。 //这个方法的优点是不用任何表也没有例外的情况。注意这里用的是整数除法,7/2=3非3.5。 /// <summary> /// CSharp 复活节算法 /// Meeus/Jones/Butcher算法(公历) /// geovindu Edit /// </summary> /// <param name="Y">公历年</param> /// <returns></returns> public string EcclesiasticalCalendar(int Y) { string ymd = string.Empty; int a, b, c, d, e, f, g,h,i,k,l,m,month,day; a = Mod(Y, 19); //a = Y mod 19 b = Y / 100;//b = Y / 100 c = Mod(Y, 100);//c = Y mod 100 d = 20 / 4;//d = b / 4 e = Mod(b, 4);//e = b mod 4 f=(b + 8) / 25;//f = (b + 8) / 25 g = (b - f + 1) / 3;//g = (b - f + 1) / 3 h = Mod((19 * a + b - d - g + 15), 30);//h = (19 * a + b - d - g + 15) mod 30 i = c / 4;//i = c / 4 k = Mod(c, 4);//k = c mod 4 l = Mod((32 + 2 * e + 2 * i - h - k),7);//l = (32 + 2 * e + 2 * i - h - k) mod 7 m = (a + 11 * h + 22 * l) / 451;//m = (a + 11 * h + 22 * l) / 451 month = (h + l - 7 * m + 114) / 31;//month = (h + l - 7 * m + 114) / 31 day = Mod((h + l - 7 * m + 114),31)+1;//day = ((h + l - 7 * m + 114) mod 31) + 1 ymd = Y.ToString() + "-" + month.ToString() + "-" + day.ToString(); // this.Literal1.Text = "<br/>a=" + a.ToString() + ";<br/>b=" + b.ToString() + ";<br/>c=" + c.ToString() + ";<br/>d=" + d.ToString() + ";<br/>e=" + e.ToString() + ";<br/>f=" + f.ToString() + ";<br/>g=" + g.ToString() + ";<br/>h=" + h.ToString() + ";<br/>i=" + i.ToString() + ";<br/>k=" + k.ToString() + ";<br/>l=" + l.ToString() // + ";<br/>m=" + m.ToString() + ";<br/>month=" + month.ToString() + ";<br/>day=" + day.ToString(); return ymd; } /// <summary> /// 取余运算(Complementation)和取模运算(Modulo Operation) /// </summary> /// <param name="n"></param> /// <param name="m"></param> /// <returns></returns> public static int Mod(int n, int m) { return ((n % m) + m) % m; }
js:
//JavaScript 算复活节,返回年,月,日 geovindu eidt function cclesiastical(Y) { var ymd; var a, b, c, d, e, f, g,h,i,k,l,m,month,day; a = Y%19; //a = Y mod 19 b = Y / 100;//b = Y / 100 c = Y%100;//c = Y mod 100 d = 20 / 4;//d = b / 4 e = b%4;//e = b mod 4 f=(b + 8) / 25;//f = (b + 8) / 25 g = (b - f + 1) / 3;//g = (b - f + 1) / 3 h = (19 * a + b - d - g + 15)%30;//h = (19 * a + b - d - g + 15) mod 30 i = c / 4;//i = c / 4 k = c% 4;//k = c mod 4 l = (32 + 2 * e + 2 * i - h - k)%7;//l = (32 + 2 * e + 2 * i - h - k) mod 7 m = (a + 11 * h + 22 * l) / 451;//m = (a + 11 * h + 22 * l) / 451 month = (h + l - 7 * m + 114) / 31;//month = (h + l - 7 * m + 114) / 31 day = ((h + l - 7 * m + 114)%31)+1;//day = ((h + l - 7 * m + 114) mod 31) + 1 ymd = Y.toString() + "-" + month.toString() + "-" + day.toString(); return ymd; }