View Single Post
  #2  
Old 08-04-2012, 02:45 PM
mithrandir's Avatar
mithrandir (Andrew)
Registered User

mithrandir is offline
 
Join Date: Jan 2009
Location: Glenhaven
Posts: 4,161
Ron, since just about everyone has Perl on their computers these days:

Code:
#!/usr/bin/perl -w
use POSIX;

$y=($#ARGV>-1)?$ARGV[0]:strftime('%Y',localtime())
  or die("$0: year required\n");

$c = int($y/100);
$n = $y-19*int($y/19);
$k = int(($c-17)/25);
$i = $c-int($c/4)-int(($c-$k)/3)+19*$n+15;
$i = $i-30*int($i/30);
$i = $i-int($i/28)*(1-int($i/28)*int(29/($i+1))*int((21-$n)/11));
$j = $y+int($y/4)+$i+2-$c+int($c/4);
$j = $j-7*int($j/7);
$l = $i-$j;
$m = 3+int(($l+40)/44);
$d = $l+28-31*($m/4);
@when=(0,0,0,$d,$m-1,$y-1900);
print strftime("%Y/%b/%d\n",@when);
or if you install the Date::Easter module:

Code:
#!/usr/bin/perl -w
use POSIX;
use Date::Easter;

$y=($#ARGV>-1)?$ARGV[0]:strftime('%Y',localtime())
  or die("$0: year required\n");

($M,$D)=gregorian_easter($y);
@when=(0,0,0,$D,$M-1,$y-1900);
print strftime("%Y/%b/%d gregorian\n",@when);

($M,$D)=julian_easter($y);
@when=(0,0,0,$D,$M-1,$y-1900);
print strftime("%Y/%b/%d julian\n",@when);

($M,$D)=orthodox_easter($y);
@when=(0,0,0,$D,$M-1,$y-1900);
print strftime("%Y/%b/%d orthodox\n",@when);
The first version is probably simpler in C.
Reply With Quote