
// COTD Entry submitted by Arclight [Daniel.Davies@blueyonder.co.uk]

Function Moon_Age(y,m,d : integer) : integer; stdcall;
var i : integer;
    c : integer;
begin
     c:=(y div 100);
     if (m>2) then dec(m,2) else inc(m,10);
     i:=((((((y mod 19)*11)+(c div 3)+(c div 4)+8)-c)+m+d) mod 30);
     moon_age:=i;
end;
