#!/bin/csh -f
#  Easter calculation for any Gregorian year * Richard Duffy (zeno@athena)
#
#  "calc_easter" does the trick; the rest is just to figure out whether
#  today is after this year's Easter.



alias calc_easter \
     echo "114 \!:1'dd100%sc100/sb19%ddsa19*lb4/-lbdd8+25/-1+3/-+15+30%dsh'" \
          "'11*lb4%2*lc4/2*+32+lh-lc4%-7%dsl22*++451/7*-lh+ll+d31/psm31%1+p'" \
  \| dc \
  \| sed -e 1s,3,Mar, -e 1s,4,Apr,



# Print Easter in the year $1.  If missing or non-numeric $1, 
# use the next-occurring Easter.  (Ignore any further args).

if ($#argv >= 1 && "$1" !~ *[^0-9]* ) then
	set year = $1
else
	set today = (`date`)
	set month = $today[2]
	set date =  $today[3]
	set year =  $today[6]

	switch ($month)
	case "[JF][ae]?":
		breaksw
	case "??r":
		set easter = (`calc_easter $year`)
		if (($month == $easter[1] && $date > $easter[2]) ||
		    $month == Apr) then
			@ year++
			unset easter
		endif
		breaksw
	default:
		@ year++
		breaksw
	endsw
endif

if (! $?easter) set easter = (`calc_easter $year`)
echo Easter $year is $easter

