home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Programmieren / Kurztests / ACE / Prgs / ShellUtils / easter.b < prev    next >
Text File  |  1994-01-17  |  2KB  |  102 lines

  1. { Easter Day Calculator.
  2.  
  3.   from "Astronomical Formulae for Calculators", Jean Meeus, 4th ed
  4.         Willmann-Bell.    chapter 4
  5.  
  6.         Valid for all years in the Gregorian Calendar (1583 on)
  7.  
  8.         DIVIDE                   by     Quotient      Remainder
  9.         the year X               19        -             A
  10.         the year X              100        B             C
  11.         B                         4        D             E
  12.         B+8                      25        F             -
  13.         B-F+1                     3        G             -
  14.         19*A+B-D-G+15            30        -             H
  15.         C                         4        I             K
  16.         32+2*E+2*I-H-K            7        -             L
  17.         A+11*H+22*L             451        M             -
  18.         H+L-7*M+114              31        N             P
  19.  
  20.         then N is the number of the Month (3=March, 4=April)
  21.         (P+1)  is the day of the month upon which Easter Sunday falls.
  22.  
  23.         The extreme dates of Easter are  March 22 (as in 1818, 2285)
  24.                     and  April 25 (as in 1886, 1943, 2038)
  25.  
  26.   Information supplied by Arlin B Collins     bcollins@utdallas.edu 
  27. }
  28.  
  29. defint a-z
  30.  
  31. shortint mn,dy
  32.  
  33. '..read month names 
  34. '..(only March and April will be used here!)
  35. dim month$(12)
  36.  
  37. for i=1 to 12
  38.   read month$(i)
  39. next
  40.  
  41. data January,February,March,April,May,June
  42. data July,August,September,October,November,December
  43.  
  44.  
  45. sub usage
  46.  print "usage:    easter yyyy"
  47.  print "    where yyyy is year >= 1583"
  48.  stop
  49. end sub
  50.  
  51. sub calculate.easter(yr)
  52. shared mn,dy
  53.   a = yr mod 19
  54.   b = yr\100
  55.   c = yr mod 100
  56.   d = b\4
  57.   e = b mod 4 
  58.   f = (b+8)\25
  59.   g = (b-f+1)\3 
  60.   h = (19*A+B-D-G+15) mod 30
  61.   i = c\4
  62.   k = c mod 4
  63.   l = (32+2*E+2*I-H-K) mod 7
  64.   m = (A+11*H+22*L)\451
  65.   mn = (H+L-7*M+114)\31
  66.   dy = ((H+L-7*M+114) mod 31) + 1
  67. end sub
  68.  
  69. sub future(yr,mn,dy)
  70.   today$=date$
  71.   c.yr = val(mid$(today$,7))
  72.   c.mn = val(mid$(today$,1,2))
  73.   c.dy = val(mid$(today$,4,5))
  74.   future=yr>c.yr or (yr=c.yr and mn>c.mn) or (yr=c.yr and mn=c.mn and dy>c.dy) 
  75. end sub
  76.  
  77. sub show.date(yr,mn,dy)
  78. shared month$
  79.   print "In";str$(yr);", ";
  80.   print "Easter Sunday ";
  81.   if future(yr,mn,dy) then 
  82.     print "falls on ";   
  83.   else
  84.     print "fell on ";
  85.   end if
  86.   print month$(mn);str$(dy);"."
  87. end sub
  88.  
  89.  
  90. '..main
  91. if argcount<>1 then
  92.   usage
  93. else
  94.   yr = val(arg$(1))
  95.   if yr < 1583 then
  96.     usage
  97.   else
  98.     calculate.easter(yr)
  99.     show.date(yr,mn,dy)
  100.   end if
  101. end if
  102.