Thursday, June 9, 2011

Visual Basic Function to get Eastern Orthodox Easter for a Year

From http://www.smart.net/~mmontes/ortheast.html#ALG
Function getEasterDate(year As Integer) As Date
    
    Dim GoldenNum As Integer
    Dim daysToPaschalFullMoon As Integer
    Dim weekdayOfPaschalFullMoon As Integer
    Dim numDaysFrom21ToPaschalFullMoon As Integer
    Dim EasterMonth As Integer
    Dim EasterDay As Integer
    
    GoldenNum = year Mod 19
    daysToPaschalFullMoon = (19 * GoldenNum + 15) Mod 30
    weekdayOfPaschalFullMoon = (year + year / 4 + daysToPaschalFullMoon) Mod 7
    numDaysFrom21ToPaschalFullMoon = daysToPaschalFullMoon - weekdayOfPaschalFullMoon
    EasterMonth = 3 + (numDaysFrom21ToPaschalFullMoon + 40) / 44
    EasterDay = numDaysFrom21ToPaschalFullMoon + 28 - 31 * (EasterMonth / 4) + 13

    getEasterDate = DateSerial(year, EasterMonth, EasterDay)
    
End Function

No comments:

Post a Comment