1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
''' <summary>
''' caclulates date of easter sunday in given year
''' </summary>
''' <param name="year">year date has to be in</param>
''' <returns>date of easter sunday</returns>
Public Shared Function Easter(ByVal year As Integer) As DateTime
Dim _month As Integer
Dim _day As Integer
Dim _moon As Integer
Dim _epact As Integer
Dim _sunday As Integer
Dim _gold As Integer
Dim _century As Integer
Dim _corx As Integer
Dim _corz As Integer
' The Golden Number of the year in the 19 year Metonic Cycle:
_gold = (year Mod 19) + 1
' Calculate the Century:
_century = (year \ 100) + 1
' Number of years in which leap year was dropped in order
' to keep in step with the sun:
_corx = (3 * _century) \ 4 - 12
' Special correction to syncronize Easter with moon's orbit:
_corz = (8 * _century + 5) \ 25 - 5
' Find Sunday:
_sunday = (5 * year) \ 4 - _corx - 10
' ^ evtl. long To prevent overflow at year 6554
' Set Epact - specifies occurrence of full moon:
_epact = (11 * _gold + 20 + _corz - _corx) Mod 30
If _epact < 0 Then
_epact += 30
End If
If (((_epact = 25) AndAlso (_gold > 11)) OrElse (_epact = 24)) Then
_epact += 1
End If
' Find Full Moon:
_moon = 44 - _epact
If _moon < 21 Then
_moon += 30
End If
' Advance to Sunday:
_moon += 7 - ((_sunday + _moon) Mod 7)
If (_moon > 31) Then
_month = 4
_day = _moon - 31
Else
_month = 3
_day = _moon
End If
Return New DateTime(year, _month, _day)
End Function
|