środa, 16 września 2009

Easter calculation using Meeus/Jones/Butcher algorithm in as3

Well it will be short - for Gregorian calendar it will be:

public static function resolveEasterDate(year:Number):Date {
var a:Number, b:Number, c:Number,
d:Number, e:Number, f:Number, g:Number,
h:Number, i:Number, k:Number,
l:Number, m:Number, p:Number;
a = year % 19;
b = int(year / 100);
c = year % 100;
d = int(b / 4);
e = b % 4;
f = int((b+8)/25);
g = int((b-f+1)/3);
h = (19*a+b-d-g+15) % 30;
i = int(c / 4);
k = c % 4;
l = (32+(2*e)+(2*i)-h-k) % 7;
m = int((a+(11*h)+(22*l))/451);
p = (h+l-(7*m)+114) % 31;
return new Date(year,int((h+l-(7*m)+114)/31)-1, p+1 );
}

4 komentarze: