BugFix Posted October 6, 2005 Share Posted October 6, 2005 This is an extract from my 'eternal' calendar, that was only useable for germans.The function realise the Easter date from any year you want in Gregorian Calendar between 1583 and 2999.Note: The function include another UDF [ _Div($a, $ ], I've posted here.expandcollapse popup#include <math.au3> ;=============================================================================== ; ; Description: returns the date of easter in specified year ; between 1583 and 2999 ; Parameter(s): $year ; ; Return Value(s): On Success - easterdate ; On Failure - -1 ; Author(s): BugFix (bug_fix@web.de) ; Note(s): ; ;=============================================================================== Func _easter($year) ;Determination Easter with formula by C. F. Gauss ;Ermittlung Ostern (Osterformel C. F. Gauss) If $year > 1582 And $year < 3000 Then $a = Mod($year,19) $b = Mod($year,4) $c = Mod($year,7) $H1 = _Div($year,100); _Div($a, $b) is a userdefined function $H2 = _Div($year,400); Int($year / 100) give the same output $N = 4 + $H1 - $H2 $M = 15 + $H1 - $H2 - _Floor(_Div((8 * $H1 + 13),25)) $d = Mod((19 * $a + $M),30) $e = Mod((2 * $b + 4 * $c + 6 * $d + $N),7) If $d + $e = 35 Then $Easter = 50 Else If $d = 28 And $e =6 And $a > 10 Then $Easter = 49 Else $Easter = 22 + $d + $e EndIf EndIf If $Easter < 32 Then $EasterDay = $Easter $EasterMonth = "03" Else $EasterDay = $Easter - 31 $EasterMonth = "04" EndIf If $EasterDay < 10 Then $EasterDay = "0" & $Easterday EndIf $EasterDate = $year & "/" & $EasterMonth & "/" & $EasterDay ; $EasterDate = $EasterDay & "." & $EasterMonth & "." & $year german notation Else $EasterDate = -1; input year is out of range EndIf Return $EasterDate EndFunc;==>_easter()with regards BugFixmy_func.au3 Best Regards BugFix Link to comment Share on other sites More sharing options...
peethebee Posted October 7, 2005 Share Posted October 7, 2005 Hi! Good one. Did not test it, but I have not seen it on the forums so far. Good job, peethebee vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvGerman Forums: http://www.autoit.deGerman Help File: http://autoit.de/hilfe vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Link to comment Share on other sites More sharing options...
abberration Posted November 27, 2021 Share Posted November 27, 2021 I know this is an old post, but I found it useful. I added some functionality. I added two optional parameters. Param1: Year to query.Param2: What parts and their order to be returned (YMD/DMY/MYD/etc - you do not even need all 3, you can return MD or even just the M or D). To skip this parameter and configure Param3, you can use: Default, -1 or "".Param3: The delimiter (/, -, ., etc.). If no parameters are entered at all, the current year is assumed. If you do not enter Param2 or Param3, the default output will be Y/M/D. Your commented line for German notation gave me the idea to make the output more flexible. The 2nd messagebox example would be the German notation. The code should explain itself: expandcollapse popup#include <Array.au3> MsgBox(0, "", _easter()) ; year/month/day MsgBox(0, "", _easter(2022, "DMY", ".")) ; day.month.year MsgBox(0, "", _easter(2022, "MDY", "-")) ; month-day-year MsgBox(0, "", _easter(2022, "MD", "|")) ; month|day Local $array[71] $j = 0 For $i = 1980 To 2050 $array[$j] = _easter($i) $j += 1 Next _ArrayDisplay($array) ;=============================================================================== ; ; Description: returns the date of easter in specified year ; between 1583 and 2999 ; ; Parameter(s): $year ; ; Return Value(s): On Success - easterdate ; On Failure - -1 ; Author(s): BugFix (bug_fix@web.de) - Original Author ; abberration - Updated ; ; Note(s): Original UDF: ; https://www.autoitscript.com/forum/topic/16639-function-_easter/?tab=comments#comment-114398 ; ;=============================================================================== Func _easter($year = @YEAR, $sUserString = "YMD", $cUserDelim = "/") If $year > 1582 And $year < 3000 Then $a = Mod($year,19) $b = Mod($year,4) $c = Mod($year,7) $H1 = Int($year/100) $H2 = Int($year/400) $N = 4 + $H1 - $H2 $M = 15 + $H1 - $H2 - Floor(Int((8 * $H1 + 13)/25)) $d = Mod((19 * $a + $M),30) $e = Mod((2 * $b + 4 * $c + 6 * $d + $N),7) If $d + $e = 35 Then $Easter = 50 Else If $d = 28 And $e =6 And $a > 10 Then $Easter = 49 Else $Easter = 22 + $d + $e EndIf EndIf If $Easter < 32 Then $EasterDay = $Easter $EasterMonth = "3" Else $EasterDay = $Easter - 31 $EasterMonth = "4" EndIf Assign("y", $year) Assign("m", $EasterMonth) Assign("d", $EasterDay) If $sUserString = Default OR $sUserString = -1 OR $sUserString = "" Then $sUserString = "YMD" $aUserString = StringSplit($sUserString, "") Local $EasterDate For $i = 1 To $aUserString[0] $EasterDate &= (($aUserString[$i]="y")?StringFormat("%04i", Eval($aUserString[$i])):StringFormat("%02i", Eval($aUserString[$i]))) & (($i < $aUserString[0])?$cUserDelim:Null) Next Else $EasterDate = -1; input year is out of range EndIf Return $EasterDate EndFunc;==>_easter() Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now