Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for easter.kix

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

  1. If $Year = ""
  2. 	$Year = @YEAR
  3. EndIf
  4.  
  5. ; Is the specified year valid?
  6. ; Check if number and if within range
  7. If VarType($Year) = 1 OR VarType($Year) <> 3 OR $Year < 1752 OR $Year > 3000
  8. 	GOTO Syntax
  9. EndIf
  10.  
  11. ; Calculate Easter Day using the instructions found at
  12. ; Simon Kershaw's "KEEPING THE FEAST"
  13. ; http://www.oremus.org/liturgy/etc/ktf/app/easter.html
  14. $G  = Mod( $Year, 19 ) + 1
  15. $S  = (( $Year - 1600 ) / 100 ) - (( $Year - 1600 ) / 400 )
  16. $L  = ((( $Year - 1400 ) / 100 ) * 8 ) / 25
  17. $P1 = Mod(( 30003 - 11 * $G + $S - $L ), 30)
  18. Select
  19. 	Case $P1 = 28 AND $G > 11
  20. 		$P = 28
  21. 	Case $P1 = 29
  22. 		$P = 28
  23. 	Case 1
  24. 		$P = $P1
  25. EndSelect
  26. $D  = Mod(( $Year + ( $Year / 4 ) - ( $Year / 100 ) + ( $Year / 400 )), 7 )
  27. $D1 = Mod(( 8 - $D ), 7 )
  28. $P2 = Mod(( 70003 + $P ), 7 )
  29. $X  = Mod(( 70004 - $D - $P ), 7 ) + 1
  30. $E  = $P + $X
  31. If $E < 11
  32. 	$ED = $E + 21
  33. 	$EM = "March"
  34. Else
  35. 	$ED = $E - 10
  36. 	$EM = "April"
  37. EndIf
  38. Select
  39. 	Case $Year < @YEAR
  40. 		$IS = "was"
  41. 	Case $Year = @YEAR
  42. 		$IS = "is"
  43. 	Case 1
  44. 		$IS = "will be"
  45. EndSelect
  46.  
  47. ; Display the result
  48. ? "In $Year Easter Day $IS $EM $ED"
  49. ?
  50.  
  51. ; MOD function divides $Op1 by $Op2 and returns the remainder
  52. Function Mod($Op1,$Op2)
  53. 	$Mod = $Op1 - $Op2 * ( $Op1 / $Op2 )
  54. EndFunction
  55.  
  56. ; End of main program
  57. Exit 0
  58.  
  59.  
  60. :Syntax
  61. ? "Easter.kix,  Version 1.00"
  62. ? "Calculate the date of Easter Day for the specified year."
  63. ?
  64. ? "Usage:  KIX32  EASTER.KIX  [ $$YEAR=year ]"
  65. ?
  66. ? "Where:  year should be within the range of 1752 through 3000"
  67. ?
  68. ? "Written by Rob van der Woude"
  69. ? "http://www.robvanderwoude.com"
  70. ?
  71. ? "Based on the instructions found at"
  72. ? "Simon Kershaw's " + Chr(34) + "KEEPING THE FEAST" + Chr(34)
  73. ? "http://www.oremus.org/liturgy/etc/ktf/app/easter.html"
  74. ?
  75. Exit 1
  76.  

page last modified: 2024-02-26; loaded in 0.0192 seconds