czardas logo World Wide Web Consortium w3schools AutoIt logo SciTE logo AutoIt Central knoppix logo php official website Medecins Sans Frontieres Free Internet Radio Stations

Algorithm by David Hodges

The following calculation for Easter was written by David Hodges and is derived by refining the "Butcher's Ecclesiastical Calendar" rule. The original was written in Visual Basic and can be found at http://www.gmarts.org/index.php?go=415#EasterHodges

; #FUNCTION# ======================================================================================
; Name...........: _DateEaster
; Description ...: Calculates Easter Sunday for a given year.
; Syntax.........: _DateEaster($iYr)
; Parameters ....: $iYr    - The year used to calculate Easter
; Return values .: Success - Easter in the format YYYY/MM/DD
;                  Failure - Returns an empty string and sets @error = 1
; Author ........: David Hodges, (conversion to AutoIt by czardas)
; Remarks .......: Applies to the revised calculation in the Gregorian calendar from 1583 to 4099 AD
; Example .......; Yes
; ==================================================================================================


Func _DateEaster($iYr)
    If StringIsInt($iYr) = 0 Or $iYr < 1583 Or $iYr > 4099 Then Return SetError(1, 0, "")

    Local $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $iDy, $iMth
    $a = Int($iYr / 100)
    $b = Mod($iYr, 100)
    $c = Int(3 * ($a + 25) / 4)
    $d = Mod(3 * ($a + 25), 4)
    $e = Int(8 * ($a + 11) / 25)
    $f = Mod(5 * $a + $b, 19)
    $g = Mod((19 * $f + $c - $e), 30)
    $h = Int((11 * $g + $f) / 319)
    $i = Int((60 * (5 - $d) + $b) / 4)
    $j = Mod(60 * (5 - $d) + $b, 4)
    $k = Mod(2 * $i - $j - $g + $h, 7)
    $iDy = Mod($g - $h + $k + 114, 31) + 1
    $iMth = Int(($g - $h + $k + 114) / 31)

    If $iDy < 10 Then $iDy = String("0" & $iDy)
    Return $iYr & "/0" & $iMth & "/" & $iDy
EndFunc

Example

Save the above code as 'EasterHodges.au3', and then run the code below in SciTE editor.

#include 'EasterHodges.au3'

Local $EasterSunday = _DateEaster(@YEAR)
If @error Then Exit
ConsoleWrite($EasterSunday & @CRLF)




Rain Oksvort's Photo Gallery

Besides spending many hours writing computer code, many members of the AutoIt community also excel in artistic creativity. I would like to express special thanks to Rain Oksvort for contributing the time lapse sequence on the right. Rain, also known as E1M1 on the AutoIt Forums, is currently studying at gymnasium.

Please visit Rain Oksvort's photo gallery, which contains many beautiful high resolution photos. All the photos were taken with a Pentax X70 digital camera, within a 200 km radius of Rain's home town - Rapla in Estonia.

 
Clouds by Rain Oksvort 2010