1
+ function Calculate-Computus ([int ]$Year , [switch ]$Servois ) {
2
+
3
+ # Year's position on the 19 year metonic cycle
4
+ $a = $Year % 19
5
+
6
+ # Century index
7
+ $k = [Math ]::Floor($Year / 100 )
8
+
9
+ # Shift of metonic cycle, add a day offset every 300 years
10
+ $p = [Math ]::Floor((13 + 8 * $k ) / 25 )
11
+
12
+ # Correction for non-observed leap days
13
+ $q = [Math ]::Floor($k / 4 )
14
+
15
+ # Correction to starting point of calculation each century
16
+ $M = (15 - $p + $k - $q ) % 30
17
+
18
+ # Number of days from March 21st until the full moon
19
+ $d = (19 * $a + $M ) % 30
20
+
21
+ # Returning if user wants value for Servois' table
22
+ if ($Servois ) {
23
+ return ((21 + $d ) % 31 ).ToString()
24
+ }
25
+
26
+ # Finding the next Sunday
27
+ # Century-based offset in weekly calculation
28
+ $N = (4 + $k - $q ) % 7
29
+
30
+ # Correction for leap days
31
+ $b = $Year % 4
32
+ $c = $Year % 7
33
+
34
+ # Days from d to next Sunday
35
+ $e = (2 * $b + 4 * $c + 6 * $d + $N ) % 7
36
+
37
+ # Historical corrections for April 26 and 25
38
+ if (($d -eq 29 -and $e -eq 6 ) -or ($d -eq 28 -and $e -eq 6 -and $a -gt 10 )) {
39
+ $e = -1
40
+ }
41
+
42
+ # Determination of the correct month for Easter
43
+ if (22 + $d + $e -gt 31 ) {
44
+ return " April " + ($d + $e - 9 )
45
+ }
46
+ else {
47
+ return " March " + (22 + $d + $e )
48
+ }
49
+ }
50
+
51
+
52
+ # Here, we will output the date of the Paschal full moon
53
+ # (using Servois notation), and Easter for 2020-2030
54
+
55
+ Write-Host " The following are the dates of the Paschal full moon (using Servois" ,
56
+ " notation) and the date of Easter for 2020-2030 AD:"
57
+ Write-Host " Year`t Servois number`t Easter"
58
+ foreach ($year in 2020 .. 2030 ) {
59
+ Write-Host " $year `t $ ( Calculate- Computus $year - Servois) `t`t $ ( Calculate- Computus $year ) "
60
+ }
0 commit comments