Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for easter2.kix

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

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

page last uploaded: 2017-04-06, 13:33