Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for easter.rex

(view source code of easter.rex as plain text)

  1. /* Easter.rex,  Version 1.00 for Regina Rexx */
  2. /* Calculate Easter Day for a specified year */
  3. /* Written by Rob van der Woude              */
  4. /* http://www.robvanderwoude.com             */
  5.  
  6. /* Check command line parameters */
  7. Parse Arg year dummy
  8. If dummy <> "" Then Call Syntax
  9. thisYear = Substr( Date( "S" ), 1, 4 )
  10. If year = "" Then year = thisYear
  11. If DataType( year, "W" ) = 0 Then Call Syntax
  12. If year < 1752 Then Call Syntax
  13. If year > 3000 Then Call Syntax
  14.  
  15. /* Calculate Easter Day using the instructions found at  */
  16. /* Simon Kershaw's "KEEPING THE FEAST"                   */
  17. /* http://www.oremus.org/liturgy/etc/ktf/app/easter.html */
  18. G  = year // 19 + 1
  19. S  = ( year - 1600 ) % 100 - ( year - 1600 ) % 400
  20. L  = ( ( ( year - 1400 ) % 100 ) * 8 ) % 25
  21. P1 = ( 30003 - 11 * G + S - L ) // 30
  22. P  = P1
  23. If P = 28 Then If G > 11 Then P = 27
  24. If P = 29 Then P = 28
  25. D  = ( year + ( year % 4 ) - ( year % 100 ) + ( year % 400 )) // 7
  26. D1 = ( 8 - D ) // 7
  27. P2 = ( 70003 + P ) // 7
  28. X  = ( ( 70004 - D - P ) // 7 ) + 1
  29. E  = P + X
  30. If E < 11 Then Do
  31. 	ED = E + 21
  32. 	EM = "March"
  33. End
  34. Else Do
  35. 	ED = E - 10
  36. 	EM = "April"
  37. End
  38. If year < thisYear Then is = "was"
  39. If year = thisYear Then is = "is"
  40. If year > thisYear Then is = "will be"
  41.  
  42. /* Display the result */
  43. Say "In "||year||" Easter Day "||is||" "||EM||" "||ED
  44.  
  45. /* Computer, end program */
  46. Exit 0
  47.  
  48. Syntax:
  49. 	Say
  50. 	Say "Easter.rex,  Version 1.00 for Regina Rexx"
  51. 	Say "Calculate the date of Easter Day for the specified year."
  52. 	Say
  53. 	Say "Usage:  Regina  EASTER.REX  [ year ]"
  54. 	Say
  55. 	Say "Where:  year should be within the range of 1752 through 3000"
  56. 	Say
  57. 	Say "Written by Rob van der Woude"
  58. 	Say "http://www.robvanderwoude.com"
  59. 	Say
  60. 	Say "Based on the instructions found at"
  61. 	Say "Simon Kershaw's "||'"KEEPING THE FEAST"'
  62. 	Say "http://www.oremus.org/liturgy/etc/ktf/app/easter.html"
  63. 	Exit 1
  64. Return
  65.  

page last uploaded: 2017-08-21, 14:26