| Body: |
I have started working on a calendar and I have decided to figure out calculations to determine various US-based national holidays. Most are simple rules (3rd Monday of XYZ month. Easter isn't. It's based on all kinds of things. (Obviously, none of it made sense to me.)
Fortunately, Google came to the rescue. Through a variety of links, I finally happened across the US Naval Observatory's page, "The Date of Easter" (http://aa.usno.navy.mil/faq/docs/easter.html).
Because that would have been entirely too difficult for my feeble little mind, here's what I copied and created as a VBScript function:
Function GetEasterDate(ByVal y)
'''''''''''''''''''''''''''''''''''''''''''''''''''''
'Credit for function's code to: '
' http://aa.usno.navy.mil/faq/docs/easter.html '
'''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim c, n, k, i, j, l, m, d
c = y \ 100
n = y - 19 * ( y \ 19 )
k = ( c - 17 ) \ 25
i = c - c \ 4 - ( c - k ) \ 3 + 19 * n + 15
i = i - 30 * ( i \ 30 )
i = i - ( i \ 28 ) * ( 1 - ( i \ 28 ) * ( 29 \ ( i + 1 ) ) * ( ( 21 - n ) \ 11 ) )
j = y + y \ 4 + i + 2 - c + c \ 4
j = j - 7 * ( j \ 7 )
l = i - j
m = 3 + ( l + 40 ) \ 44
d = l + 28 - 31 * ( m \ 4 )
GetEasterDate = DateSerial(y, m, d)
End Function
To use it, you would do:
Msgbox GetEasterDate(2003)
Note, I've published a public set of web services for calculating holiday dates for the United States, United Kingdom, Northern Ireland and Scotland. For more information see, HolidayWebService.com. |