Date functions: easter


easter() #@ Calculate Easter (and related dates) for any year
{        #@ USAGE: easter [YEAR]
         #@ Variables set: Easter Palm_Sun Good_Fri Ash_Wed
  declare -i E a b c d e f g h i k l m p year emonth eday palm_sun ash_wed good_fri

  [[ -s $1 ]] && year=$1 ||  printf -v year '%(%Y)T'

  a=year%19
  b=year/100
  c=year%100
  d=b/4
  e=b%4
  f=(b+8)/25
  g=(b-f+1)/3
  h=(19*a+b-d-g+15)%30
  i=c/4
  k=c%4
  l=(32+2*e+2*i-h-k)%7
  m=(a+11*h+22*l)/451
  emonth=(h+l-7*m+114)/31
  p=(h+l-7*m+114)%31
  eday=p+1

  printf -v Easter %d-%02d-%02d "$year" "$emonth" "$eday"
  datenum "$Easter" E
  palm_sun=E-7
  good_fri=E-2
  ash_wed=E-46

  numdate "$palm_sun" Palm_Sun
  numdate "$good_fri" Good_Fri
  numdate "$ash_wed" Ash_Wed
  ((debug||verbose)) && vshow a b c d e f g h i k l m emonth p eday E Easter Palm_Sun Good_Fri Ash_Wed
}

Don't ask.