
#include-once
;===============================================================================
;								Contents
;	_DateToNorm()
;		Convert date ( YYYY/MM/DD ) to german notation ( DD.MM.YYYY )
;	_NowNormDate()
;		Output current date in german notation ( DD.MM.YYYY )
;	_Easter()
;		Returns the date of easter in specified year between 1583 and 2999
;	_WeekDay()
;		Determination weekday from any date, Formula by Christian Zeller
;	_Div()
;		Give the integer part of an division by using the same notation
;		like function 'Mod($a, $b)'
;
;===============================================================================

#include <math.au3>

;===============================================================================
;
; Function Name:   	_DateToNorm()
;
; Description:      Convert date ( YYYY/MM/DD ) to german notation ( DD.MM.YYYY )
;
; Parameter:		$date(YYYY/MM/DD)
;
; Return Value:		(DD.MM.YYYY)
;
;===============================================================================
Func _DateToNorm($date)
	Return StringMid($date,9) & "." & StringMid($date,6,2) & "." & StringMid($date,1,4)
EndFunc

;===============================================================================
;
; Function Name:   	_NowNormDate()
;
; Description:      Output current date in german notation ( DD.MM.YYYY )
;
; Parameter:		Non
;
; Return Value:		(DD.MM.YYYY)
;
;===============================================================================
Func _NowNormDate()
	Return ( @MDAY & "." & @MON & "." & @YEAR )
EndFunc

;===============================================================================
;
; Function Name:   	_Easter()
;
; 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 and sets @ERROR = 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
		SetError(1)
	EndIf
	Return $EasterDate
EndFunc	;==>_easter()

;===============================================================================
;
; Function Name:   	_WeekDay()
;
; Description:     	Determination weekday from any date
;					Formula by Christian Zeller
;
; Parameter:		$day, $mon, $year (as integer)
;
; Return Value:		Weekday
;
; Author(s):        BugFix (bug_fix@web.de)
;
; It works correct for Gregorian calendar (1583 - 8201)
;===============================================================================
Func _WeekDay($day, $month, $year)
		$leap = 0
		If _DateIsLeapYear($year) Then			;check leapyear
			$leap = 1
		EndIf
		$D = $day
		;check february date and correct if out of range
		If $month = 2 and $D > 28 Then			
			If $leap = 0 Then
				$D = 28				
			Else
				$D = 29
			EndIf
			; as alternative - do'nt correct and give failure
			;SetError(1)
			;Return -1
		EndIf
		;check 30-day months and correct if out of range
		If ($month = 4 Or $month = 6 Or $month = 9 Or $month = 11) And $D > 30 Then
			$D = 30
			; as alternative - do'nt correct and give failure
			;SetError(1)
			;Return -1
		EndIf		
		$C = Int($year/100)						;determination century
		$Y = Mod($year, 100)					;determination year
		
		If $month < 3 Then						;Jan. and Feb. be among to last year(century)
			If $Y = 0 Then						
				$Y = 99
				$C =$C -1
			Else
				$Y = $Y - 1	
			EndIf
		EndIf
			
		Select
		Case $month > 2							;old latin calendar begins with month 'march'
			$M = $month-2
		Case Else
			$M = $month+10
		EndSelect
		
		; Zeller's formula:
		$W = Mod((_Floor(2.6*$M-0.2)+$D+$Y+(_Floor($Y/4))+(_Floor($C/4))-2*$C), 7)
		
		; If $W is negativ , you must be add 7 , so that $W will be positiv. 
		; This number is equivalent to weekday.
		If $W < 0 Then
			$W = $W + 7
		EndIf
		
		Select
		Case $W = 0				
			$WeekDay = "Sonntag"		; Sunday
		Case $W = 1
			$WeekDay = "Montag"			; Monday
		Case $W = 2
			$WeekDay = "Dienstag"		; Tuesday
		Case $W = 3
			$WeekDay = "Mittwoch"		; Wednesday
		Case $W = 4
			$WeekDay = "Donnerstag"		; Thursday
		Case $W = 5
			$WeekDay = "Freitag"		; Friday
		Case $W = 6
			$WeekDay = "Sonnabend"		; Saturday
		EndSelect		
		Return $WeekDay
EndFunc	;==>_WeekDay

;===============================================================================
;
; Function Name:   	_Div()
;
; Description:     	Give the integer part of an division
;
; Syntax:          	_Div(value1, value2)
;
; Parameter(s):    	value1	= dividend
;                  	value2 	= divisor
;
;===============================================================================
Func _Div($a, $b)
	Return Int($a / $b)
EndFunc	;==>_Div

;=====================================================================================================
;	Beginn Code																						 ;
;=====================================================================================================

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
;
; Osterformel (Gauss)
;      a = Jahr mod 19
;     b = Jahr mod 4
;     c = Jahr mod 7
;    H1 = Jahr div 100
;    H2 = Jahr div 400
;     N = 4 + H1 - H2
;     M = 15 + H1 - H2 - [(8 * H1 + 13) div 25]
;     d = (19 * a + M) mod 30
;     e = (2 * b + 4 * c + 6 * d + N) mod 7
; wenn d + e = 35, dann ostern = 50
; wenn d = 28 und e = 6 und a > 10, dann ostern = 49
; in allen anderen Fällen: ostern = 22 + d + e
; ostern: Ostersonntag als Märzdatum
;
; ----------------------------------------------------------------------------

#include <GuiConstants.au3>
#include <Date.au3>
#include <math.au3>


GuiCreate("Wochen- und Feiertagsbestimmung", 680, 485,(@DesktopWidth-680)/2, (@DesktopHeight-485)/2 )
GUISetBkColor (0xFFFACD)
$L_Header = GuiCtrlCreateLabel("Bestimmen Sie den Wochentag ! (gültig: 1583 - 8201)", 200, 10, 280, 20)
GUICtrlSetColor($L_Header,0xFF0000)
$L_CurrDate = GuiCtrlCreateLabel(_NowNormDate(),620,10,60,20)

;Gruppe Optionsfelder zur Datumsauswahl
$Group_T = GuiCtrlCreateGroup("Tag", 15, 25, 650, 60)
$R1 = GuiCtrlCreateRadio("01", 20, 45, 30, 15)
GUICtrlSetState($R1,$gui_checked)
$R2 = GuiCtrlCreateRadio("02", 60, 45, 30, 15)
$R3 = GuiCtrlCreateRadio("03", 100, 45, 30, 15)
$R4 = GuiCtrlCreateRadio("04", 140, 45, 30, 15)
$R5 = GuiCtrlCreateRadio("05", 180, 45, 30, 15)
$R6 = GuiCtrlCreateRadio("06", 220, 45, 30, 15)
$R7 = GuiCtrlCreateRadio("07", 260, 45, 30, 15)
$R8 = GuiCtrlCreateRadio("08", 300, 45, 30, 15)
$R9 = GuiCtrlCreateRadio("09", 340, 45, 30, 15)
$R10 = GuiCtrlCreateRadio("10", 380, 45, 30, 15)
$R11 = GuiCtrlCreateRadio("11", 420, 45, 30, 15)
$R12 = GuiCtrlCreateRadio("12", 460, 45, 30, 15)
$R13 = GuiCtrlCreateRadio("13", 500, 45, 30, 15)
$R14 = GuiCtrlCreateRadio("14", 540, 45, 30, 15)
$R15 = GuiCtrlCreateRadio("15", 580, 45, 30, 15)
$R16 = GuiCtrlCreateRadio("16", 20, 60, 30, 15)
$R17 = GuiCtrlCreateRadio("17", 60, 60, 30, 15)
$R18 = GuiCtrlCreateRadio("18", 100, 60, 30, 15)
$R19 = GuiCtrlCreateRadio("19", 140, 60, 30, 15)
$R20 = GuiCtrlCreateRadio("20", 180, 60, 30, 15)
$R21 = GuiCtrlCreateRadio("21", 220, 60, 30, 15)
$R22 = GuiCtrlCreateRadio("22", 260, 60, 30, 15)
$R23 = GuiCtrlCreateRadio("23", 300, 60, 30, 15)
$R24 = GuiCtrlCreateRadio("24", 340, 60, 30, 15)
$R25 = GuiCtrlCreateRadio("25", 380, 60, 30, 15)
$R26 = GuiCtrlCreateRadio("26", 420, 60, 30, 15)
$R27 = GuiCtrlCreateRadio("27", 460, 60, 30, 15)
$R28 = GuiCtrlCreateRadio("28", 500, 60, 30, 15)
$R29 = GuiCtrlCreateRadio("29", 540, 60, 30, 15)
$R30 = GuiCtrlCreateRadio("30", 580, 60, 30, 15)
$R31 = GuiCtrlCreateRadio("31", 620, 60, 30, 15)

$Group_M = GuiCtrlCreateGroup("Monat", 15, 100, 255, 60)
$R1m = GuiCtrlCreateRadio("01", 20, 120, 30, 15)
GUICtrlSetState($R1m,$gui_checked)
$R2m = GuiCtrlCreateRadio("02", 60, 120, 30, 15)
$R3m = GuiCtrlCreateRadio("03", 100, 120, 30, 15)
$R4m = GuiCtrlCreateRadio("04", 140, 120, 30, 15)
$R5m = GuiCtrlCreateRadio("05", 180, 120, 30, 15)
$R6m = GuiCtrlCreateRadio("06", 220, 120, 30, 15)
$R7m = GuiCtrlCreateRadio("07", 20, 135, 30, 15)
$R8m = GuiCtrlCreateRadio("08", 60, 135, 30, 15)
$R9m = GuiCtrlCreateRadio("09", 100, 135, 30, 15)
$R10m = GuiCtrlCreateRadio("10", 140, 135, 30, 15)
$R11m = GuiCtrlCreateRadio("11", 180, 135, 30, 15)
$R12m = GuiCtrlCreateRadio("12", 220, 135, 30, 15)

$L_MsgTag = GUICtrlCreateLabel("",340,100,200,20)
GUICtrlSetColor($L_MsgTag,0xFF0000)
$L_Year = GuiCtrlCreateLabel("Jahr", 340, 122, 40, 20)
$But_minus = GUICtrlCreateButton("-",406,123,15,15)
$But_plus = GUICtrlCreateButton("+",468,123,15,15)
$Inp_Year = GUICtrlCreateInput(StringMid(_NowCalcDate(),1,4), 425, 120, 40, 20)
$But_Start = GuiCtrlCreateButton("Start", 615, 105, 50, 20)
$But_Ende = GUICtrlCreateButton("Ende",615,145,50,20)
$L_LeapYear = GUICtrlCreateLabel("",500,122,80,20)
$L_WeekDay = GuiCtrlCreateLabel("Wochentag:", 340, 145, 90, 20)
$L_WDayName = GuiCtrlCreateLabel("", 417, 145, 90, 20)
$L_Feiertage = GUICtrlCreateLabel("Die Feiertage dieses Jahres", 265, 175, 150, 20)
$L_Fix = GUICtrlCreateLabel("Unveränderlich:", 70, 200, 90, 20)
$L_Variabel = GUICtrlCreateLabel("Veränderlich (gültig: 1583 - 2999):", 380, 200, 170,20)
GUICtrlSetColor($L_Feiertage,0xFF0000)
GUICtrlSetColor($L_Fix,0xFF0000)
GUICtrlSetColor($L_Variabel,0xFF0000)
GUICtrlSetColor($L_LeapYear,0x0000FF)
GUICtrlSetColor($L_WDayName,0xFF0000)
; Fixe Feiertage:
$L_Neuj = GUICtrlCreateLabel("Neujahr", 80, 220, 90, 20)				
$L_NeujDat = GUICtrlCreateLabel("01.01.", 230, 220, 70, 20)
$WD_N = GUICtrlCreateLabel("",275,220,60,20)
$L_3K = GUICtrlCreateLabel("Heilige Drei Könige", 80, 235, 110, 20)
$L_3KDat = GUICtrlCreateLabel("06.01.", 230, 235, 70, 20)
$WD_3K = GUICtrlCreateLabel("",275,235,60,20)
$L_Val = GUICtrlCreateLabel("Valentinstag", 80, 250, 110, 20)
$L_ValDat = GUICtrlCreateLabel("14.02.", 230, 250,70,20)
$WD_Val = GUICtrlCreateLabel("",275,250,60,20)
$L_Mai = GUICtrlCreateLabel("Maifeiertag",80,265,110,20)
$L_MaiDat = GUICtrlCreateLabel("01.05.",230,265,70,20)
$WD_Mai = GUICtrlCreateLabel("",275,265,60,20)
$L_Einheit =GUICtrlCreateLabel("Tag der Deutschen Einheit",80,280,145,20)
$L_EinheitDat =GUICtrlCreateLabel("03.10.",230,280,70,20)
$WD_Einheit = GUICtrlCreateLabel("",275,280,60,20)
$L_Ref = GUICtrlCreateLabel("Reformationstag",80,295,145,20)
$L_RefDat = GUICtrlCreateLabel("31.10.",230,295,70,20)
$WD_Ref = GUICtrlCreateLabel("",275,295,60,20)
$L_Aller = GUICtrlCreateLabel("Allerheiligen",80,310,145,20)
$L_AllerDat = GUICtrlCreateLabel("01.11.",230,310,70,20)
$WD_Aller = GUICtrlCreateLabel("",275,310,60,20)
$L_HlA = GUICtrlCreateLabel("Heiligabend",80,325,145,20)
$L_HlADat = GUICtrlCreateLabel("24.12.",230,325,70,20)
$WD_Heil = GUICtrlCreateLabel("",275,325,60,20)
$L_1WT = GUICtrlCreateLabel("1. Weihnachtsfeiertag",80,340,145,20)
$L_1WTDat = GUICtrlCreateLabel("25.12.",230,340,70,20)
$WD_1W = GUICtrlCreateLabel("",275,340,60,20)
$L_2WT = GUICtrlCreateLabel("2. Weihnachtsfeiertag",80,355,145,20)
$L_2WTDat = GUICtrlCreateLabel("26.12.",230,355,70,20)
$WD_2W = GUICtrlCreateLabel("",275,355,60,20)
$L_Sil = GUICtrlCreateLabel("Silvester",80,370,145,20)
$L_SilDat = GUICtrlCreateLabel("31.12.",230,370,70,20)
$WD_Sil = GUICtrlCreateLabel("",275,370,60,20)

$L_Advent = GUICtrlCreateLabel("Adventstage:",185,420,80,20)
GUICtrlSetColor($L_Advent,0xFF0000)
$L_1Adv = GUICtrlCreateLabel("1. Advent",80,440,60,20)
$L_1AdvDat = GUICtrlCreateLabel("",90,460,40,20)
$L_2Adv = GUICtrlCreateLabel("2. Advent",150,440,60,20)
$L_2AdvDat = GUICtrlCreateLabel("",160,460,40,20)
$L_3Adv = GUICtrlCreateLabel("3. Advent",220,440,60,20)
$L_3AdvDat = GUICtrlCreateLabel("",230,460,40,20)
$L_4Adv = GUICtrlCreateLabel("4. Advent",290,440,60,20)
$L_4AdvDat = GUICtrlCreateLabel("",300,460,40,20)
GUICtrlSetColor($L_1AdvDat,0x0000ff)
GUICtrlSetColor($L_2AdvDat,0x0000ff)
GUICtrlSetColor($L_3AdvDat,0x0000ff)
GUICtrlSetColor($L_4AdvDat,0x0000ff)
; Variable Feiertage:
$L_WFast  = GUICtrlCreateLabel("Weiberfastnacht",390,220,145,20)		
$L_WFastDate  = GUICtrlCreateLabel("",550,220,70,20)
$L_Ros  = GUICtrlCreateLabel("Rosenmontag",390,235,145,20)
$L_RosDat  = GUICtrlCreateLabel("",550,235,70,20)
$L_Fast  = GUICtrlCreateLabel("Fastnacht",390,250,145,20)
$L_FastDat  = GUICtrlCreateLabel("",550,250,70,20)
$L_Asch  = GUICtrlCreateLabel("Aschermittwoch",390,265,145,20)
$L_AschDat  = GUICtrlCreateLabel("",550,265,70,20)
$L_GrDo  = GUICtrlCreateLabel("Gründonnerstag",390,280,145,20)
$L_GrDoDat  = GUICtrlCreateLabel("",550,280,70,20)
$L_Kar  = GUICtrlCreateLabel("Karfreitag",390,295,145,20)
$L_KarDat  = GUICtrlCreateLabel("",550,295,70,20)
$L_OSa  = GUICtrlCreateLabel("Ostersamstag",390,310,145,20)
$L_OSaDat  = GUICtrlCreateLabel("",550,310,70,20)
$L_OSo  = GUICtrlCreateLabel("Ostersonntag",390,325,145,20)
$L_OSoDat  = GUICtrlCreateLabel("",550,325,70,20)
$L_OMo  = GUICtrlCreateLabel("Ostermontag",390,340,145,20)
$L_OMoDat  = GUICtrlCreateLabel("",550,340,70,20)
$L_HiFa  = GUICtrlCreateLabel("Christi Himmelfahrt",390,355,145,20)
$L_HiFaDat  = GUICtrlCreateLabel("",550,355,70,20)
$L_Mutter = GUICtrlCreateLabel("Muttertag",390,370,145,20)
$L_MutterDat  = GUICtrlCreateLabel("",550,370,70,20)	
$L_PfSo  = GUICtrlCreateLabel("Pfingstsonntag",390,385,145,20)
$L_PfSoDat  = GUICtrlCreateLabel("",550,385,70,20)
$L_PfMo  = GUICtrlCreateLabel("Pfingstmontag",390,400,145,20)
$L_PfMoDat  = GUICtrlCreateLabel("",550,400,70,20)
$L_Fro  = GUICtrlCreateLabel("Fronleichnam",390,415,145,20)
$L_FroDat  = GUICtrlCreateLabel("",550,415,70,20)
$L_Ernte  = GUICtrlCreateLabel("Erntedankfest",390,430,145,20)
$L_ErnteDat  = GUICtrlCreateLabel("",550,430,70,20)
$L_BuB  = GUICtrlCreateLabel("Buß- und Bettag",390,445,145,20)
$L_BuBDat  = GUICtrlCreateLabel("",550,445,70,20)
$L_TotSo = GUICtrlCreateLabel("Totensonntag",390,460,145,20)
$L_TotSoDat = GUICtrlCreateLabel("",550,460,70,20)

GuiSetState()
While 1
	$msg = GuiGetMsg()
	If $msg = $But_minus Then
		GUICtrlSetData($Inp_Year,GUICtrlRead($Inp_Year)-1)
	EndIf
	If $msg = $But_plus Then
		GUICtrlSetData($Inp_Year,GUICtrlRead($Inp_Year)+1)
	EndIf	
	If $msg = $But_Start Then
		GUICtrlSetData($L_MsgTag,"")
		GUICtrlSetData($L_LeapYear,"")
		GUICtrlSetData($L_WFastDate,"")
		GUICtrlSetData($L_RosDat,"")
		GUICtrlSetData($L_FastDat,"")
		GUICtrlSetData($L_AschDat,"")
		GUICtrlSetData($L_GrDoDat,"")
		GUICtrlSetData($L_KarDat,"")
		GUICtrlSetData($L_OSaDat,"")
		GUICtrlSetData($L_OSoDat,"")
		GUICtrlSetData($L_OMoDat,"")
		GUICtrlSetData($L_HiFaDat,"")
		GUICtrlSetData($L_PfSoDat,"")
		GUICtrlSetData($L_MutterDat,"")
		GUICtrlSetData($L_PfMoDat,"")
		GUICtrlSetData($L_FroDat,"")
		GUICtrlSetData($L_ErnteDat,"")
		GUICtrlSetData($L_TotSoDat,"")
		GUICtrlSetData($L_BuBDat,"")
		GUICtrlSetData($L_WDayName, "")
		GUICtrlSetData($WD_N,"")
		GUICtrlSetData($WD_3K,"")
		GUICtrlSetData($WD_Val,"")
		GUICtrlSetData($WD_Mai,"")
		GUICtrlSetData($WD_Einheit,"")
		GUICtrlSetData($WD_Ref,"")
		GUICtrlSetData($WD_Aller,"")
		GUICtrlSetData($WD_Heil,"")
		GUICtrlSetData($WD_1W,"")
		GUICtrlSetData($WD_2W,"")
		GUICtrlSetData($WD_Sil,"")
		GUICtrlSetData($L_1AdvDat,"")
		GUICtrlSetData($L_2AdvDat,"")
		GUICtrlSetData($L_3AdvDat,"")
		GUICtrlSetData($L_4AdvDat,"")

		$day1 = GUICtrlRead($R1)
		$day2 = GUICtrlRead($R2)
		$day3 = GUICtrlRead($R3)
		$day4 = GUICtrlRead($R4)
		$day5 = GUICtrlRead($R5)
		$day6 = GUICtrlRead($R6)
		$day7 = GUICtrlRead($R7)
		$day8 = GUICtrlRead($R8)
		$day9 = GUICtrlRead($R9)
		$day10 = GUICtrlRead($R10)
		$day11 = GUICtrlRead($R11)
		$day12 = GUICtrlRead($R12)
		$day13 = GUICtrlRead($R13)
		$day14 = GUICtrlRead($R14)
		$day15 = GUICtrlRead($R15)
		$day16 = GUICtrlRead($R16)
		$day17 = GUICtrlRead($R17)
		$day18 = GUICtrlRead($R18)
		$day19 = GUICtrlRead($R19)
		$day20 = GUICtrlRead($R20)
		$day21 = GUICtrlRead($R21)
		$day22 = GUICtrlRead($R22)
		$day23 = GUICtrlRead($R23)
		$day24 = GUICtrlRead($R24)
		$day25 = GUICtrlRead($R25)
		$day26 = GUICtrlRead($R26)
		$day27 = GUICtrlRead($R27)
		$day28 = GUICtrlRead($R28)
		$day29 = GUICtrlRead($R29)
		$day30 = GUICtrlRead($R30)
		$day31 = GUICtrlRead($R31)	

		$mon1 = GUICtrlRead($R1m)
		$mon2 = GUICtrlRead($R2m)
		$mon3 = GUICtrlRead($R3m)
		$mon4 = GUICtrlRead($R4m)
		$mon5 = GUICtrlRead($R5m)
		$mon6 = GUICtrlRead($R6m)
		$mon7 = GUICtrlRead($R7m)
		$mon8 = GUICtrlRead($R8m)
		$mon9 = GUICtrlRead($R9m)
		$mon10 = GUICtrlRead($R10m)
		$mon11 = GUICtrlRead($R11m)
		$mon12 = GUICtrlRead($R12m)
		
		Select
		Case $day1 = 1
			$D = 1
		Case $day2 = 1
			$D = 2	
		Case $day3 = 1
			$D = 3
		Case $day4 = 1
			$D = 4		
		Case $day5 = 1
			$D = 5
		Case $day6 = 1
			$D = 6	
		Case $day7 = 1
			$D = 7
		Case $day8 = 1
			$D = 8	
		Case $day9 = 1
			$D = 9
		Case $day10 = 1
			$D = 10	
		Case $day11 = 1
			$D = 11
		Case $day12 = 1
			$D = 12	
		Case $day13 = 1
			$D = 13
		Case $day14 = 1
			$D = 14		
		Case $day15 = 1
			$D = 15
		Case $day16 = 1
			$D = 16	
		Case $day17 = 1
			$D = 17
		Case $day18 = 1
			$D = 18	
		Case $day19 = 1
			$D = 19
		Case $day20 = 1
			$D = 20	
		Case $day21 = 1
			$D = 21
		Case $day22 = 1
			$D = 22	
		Case $day23 = 1
			$D = 23
		Case $day24 = 1
			$D = 24		
		Case $day25 = 1
			$D = 25
		Case $day26 = 1
			$D = 26	
		Case $day27 = 1
			$D = 27
		Case $day28 = 1
			$D = 28	
		Case $day29 = 1
			$D = 29
		Case $day30 = 1
			$D = 30			
		Case $day31 = 1
			$D = 31
		EndSelect
		
		Select
		Case $mon1 = 1
			$mon = 1
		Case $mon2 = 1
			$mon = 2	
		Case $mon3 = 1
			$mon = 3
		Case $mon4 = 1
			$mon = 4
		Case $mon5 = 1
			$mon = 5
		Case $mon6 = 1
			$mon = 6
		Case $mon7 = 1
			$mon = 7
		Case $mon8 = 1
			$mon = 8
		Case $mon9 = 1
			$mon = 9
		Case $mon10 = 1
			$mon = 10
		Case $mon11 = 1
			$mon = 11
		Case $mon12 = 1
			$mon = 12
		EndSelect

		$year = GUICtrlRead($Inp_Year)			;Eingegebenes Jahr(JJJJ)
		$Schalt = 0
		If _DateIsLeapYear($year) Then			;Überprüfung Schaltjahr
			$Schalt = 1
			GUICtrlSetData($L_LeapYear,"Schaltjahr")
		EndIf		
		If $mon = 2 and $D > 28 Then			;Überprüfung/Korrektur Februardatum
			If $Schalt = 0 Then
				$D = 28	
				GUICtrlSetState($R28,$gui_checked)
			Else
				$D = 29
				GUICtrlSetState($R29,$gui_checked)
			EndIf
			GUICtrlSetData($L_MsgTag,"'Tag' für Berechnung auf "& $D & " korrigiert!")
		EndIf
		If ($mon = 4 Or $mon = 6 Or $mon = 9 Or $mon = 11 ) And $D > 30 Then
			$D = 30
			GUICtrlSetData($L_MsgTag,"'Tag' für Berechnung auf "& $D & " korrigiert!")
			GUICtrlSetState($R30,$gui_checked)
		EndIf		
		$C = Int($year/100)						;Bestimmung Jahrhundert
		$J = Mod($year, 100)					;Bestimmung Jahr
		
		If $mon < 3 Then						;Jan und Feb gehören zum Vorjahr(hundert)
			If $J = 0 Then						
				$J = 99
				$C =$C -1
			Else
				$J = $J - 1	
			EndIf
		EndIf
			
		Select
		Case $mon > 2							;Altrömische Zeitrechnung beginnt im März
			$M = $mon-2
		Case Else
			$M = $mon+10
		EndSelect
		
		$W = Mod((_Floor(2.6*$M-0.2)+$D+$J+(_Floor($J/4))+(_Floor($C/4))-2*$C), 7)
		
		; Ist das Ergebnis negativ , so addiert man 7 hinzu, so dass eine positive Zahl entsteht. 
		; Diese Zahl entspricht dann dem Wochentag.
		If $W < 0 Then
			$W = $W + 7
		EndIf
		
		If $year > 1582 And $year < 8202 Then
			Select
			Case $W = 0				
				GUICtrlSetData($L_WDayName, "Sonntag")
			Case $W = 1
				GUICtrlSetData($L_WDayName, "Montag")
			Case $W = 2
				GUICtrlSetData($L_WDayName, "Dienstag")
			Case $W = 3
				GUICtrlSetData($L_WDayName, "Mittwoch")
			Case $W = 4
				GUICtrlSetData($L_WDayName, "Donnerstag")
			Case $W = 5
				GUICtrlSetData($L_WDayName, "Freitag")
			Case $W = 6
				GUICtrlSetData($L_WDayName, "Sonnabend")
			EndSelect
		EndIf
		
		GUICtrlSetData($WD_N,_WeekDay(1,1,$year))	
		GUICtrlSetData($WD_3K,_WeekDay(6,1,$year))
		GUICtrlSetData($WD_Val,_WeekDay(14,2,$year))
		GUICtrlSetData($WD_Mai,_WeekDay(1,5,$year))
		GUICtrlSetData($WD_Einheit,_WeekDay(3,10,$year))
		GUICtrlSetData($WD_Ref,_WeekDay(31,10,$year))
		GUICtrlSetData($WD_Aller,_WeekDay(1,11,$year))
		GUICtrlSetData($WD_Heil,_WeekDay(24,12,$year))
		GUICtrlSetData($WD_1W,_WeekDay(25,12,$year))
		GUICtrlSetData($WD_2W,_WeekDay(26,12,$year))
		GUICtrlSetData($WD_Sil,_WeekDay(31,12,$year))
		GUICtrlSetColor($WD_N,0x0000ff)
		GUICtrlSetColor($WD_3K,0x0000ff)
		GUICtrlSetColor($WD_Val,0x0000ff)
		GUICtrlSetColor($WD_Mai,0x0000ff)
		GUICtrlSetColor($WD_Einheit,0x0000ff)
		GUICtrlSetColor($WD_Ref,0x0000ff)
		GUICtrlSetColor($WD_Aller,0x0000ff)
		GUICtrlSetColor($WD_Heil,0x0000ff)
		GUICtrlSetColor($WD_1W,0x0000ff)
		GUICtrlSetColor($WD_2W,0x0000ff)
		GUICtrlSetColor($WD_Sil,0x0000ff)
		
		;Ermittlung Ostern und abhängige Feiertage (Osterformel Gauss)
		If $year > 1582 And $year < 3000 Then		
			$aa = Mod($year,19)
			$bb = Mod($year,4)
			$cc = Mod($year,7)
			$H1 = _Div($year,100)
			$H2 = _Div($year,400)
			$N = 4 + $H1 - $H2
			$MM = 15 + $H1 - $H2 - _Floor(_Div((8 * $H1 + 13),25))
			$dd = Mod((19 * $aa + $MM),30)
			$ee = Mod((2 * $bb + 4 * $cc + 6 * $dd + $N),7)
			If $dd + $ee = 35 Then
				$Easter = 50
			Else
				If $dd = 28 And $ee =6 And $aa > 10 Then
					$Easter = 49
				Else
					$Easter = 22 + $dd + $ee
				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
		
			If $year < 1900 Then			;Datumsoperationen nur mgl. wenn > 1900 , Jahr wird konvertiert
				$RestJahr = Mod($year,100)
				If $Schalt = 1 Then				
					if $RestJahr < 10 Then
						$RestJahr = "0" & $RestJahr
					EndIf
					$Tempyear = 20 & $RestJahr
				Else				
					if $RestJahr < 10 Then
						$RestJahr = "0" & $RestJahr
					EndIf		
					$Tempyear = 19 & $RestJahr
				EndIf
				$EasterDate = $Tempyear&"/"&$EasterMonth&"/"&$EasterDay
			Else
				$EasterDate = $year&"/"&$EasterMonth&"/"&$EasterDay
			EndIf		
			$WFastDate = _DateAdd( 'd',-52,$EasterDate)
			$RosDat = _DateAdd( 'd',-48,$EasterDate)
			$FastDat = _DateAdd( 'd',-47,$EasterDate)		
			$AschDat = _DateAdd( 'd',-46,$EasterDate)
			$GrDoDat = _DateAdd( 'd',-3,$EasterDate)
			$KarDat = _DateAdd( 'd',-2,$EasterDate)
			$OSaDat = _DateAdd( 'd',-1,$EasterDate)
			$OSoDat = $EasterDate
			$OMoDat = _DateAdd( 'd',1,$EasterDate)
			$HiFaDat = _DateAdd( 'd',39,$EasterDate)
			$PfSoDat = _DateAdd( 'd',49,$EasterDate)
			$PfMoDat = _DateAdd( 'd',50,$EasterDate)
			$FroDat = _DateAdd( 'd',60,$EasterDate)
		
			;Umstellen auf TT.MM.JJJJ
			$WFastDate = StringMid($WFastDate,9)&"."&StringMid($WFastDate,6,2)&"."&$year
			$RosDat = StringMid($RosDat,9)&"."&StringMid($RosDat,6,2)&"."&$year
			$FastDat = StringMid($FastDat,9)&"."&StringMid($FastDat,6,2)&"."&$year		
			$AschDat = StringMid($AschDat,9)&"."&StringMid($AschDat,6,2)&"."&$year
			$GrDoDat = StringMid($GrDoDat,9)&"."&StringMid($GrDoDat,6,2)&"."&$year
			$KarDat = StringMid($KarDat,9)&"."&StringMid($KarDat,6,2)&"."&$year
			$OSaDat = StringMid($OSaDat,9)&"."&StringMid($OSaDat,6,2)&"."&$year		
			$OSoDat = StringMid($OSoDat,9)&"."&StringMid($OSoDat,6,2)&"."&$year
			$OMoDat = StringMid($OMoDat,9)&"."&StringMid($OMoDat,6,2)&"."&$year
			$HiFaDat = StringMid($HiFaDat,9)&"."&StringMid($HiFaDat,6,2)&"."&$year
			$PfSoDat = StringMid($PfSoDat,9)&"."&StringMid($PfSoDat,6,2)&"."&$year
			$PfMoDat = StringMid($PfMoDat,9)&"."&StringMid($PfMoDat,6,2)&"."&$year
			$FroDat = StringMid($FroDat,9)&"."&StringMid($FroDat,6,2)&"."&$year
			
			;Ermitteln nicht von Ostern abhängiger, veränderlicher Feiertage
			
			;Muttertag = 2. Sonntag im Mai ABER wenn Pfingsten = 2.Sonntag im Mai dann ist Muttertag am 1. Sonntag
			;Der 2. Sonntag kann nur zw. dem 8. u. 14.5. liegen
			For $maitag = 8 To 14
				If _Weekday($maitag,5,$year) = "Sonntag" Then
					If $maitag < 10 Then
						$maitag = "0" & $maitag
					EndIf					
					$MutterDat = $maitag & "." & "05." & $year
					If $MutterDat = $PfSoDat Then
						$MutterDat = _DateAdd( 'd', -7, $year&"/05/"&$maitag)
						$MutterDat = _DateToNorm($MutterDat)
					EndIf
					ExitLoop
				EndIf
			Next			

			;Erntedankfest 1. Sonntag im Oktober (zw. 1. u. 7.10.)
			For $oktobertag = 1 To 7
				If _Weekday($oktobertag,10,$year) = "Sonntag" Then
					$oktobertag = "0" & $oktobertag
					$ErnteDat = $oktobertag & "." & "10." & $year
					ExitLoop
				EndIf
			Next

			;4.Advent = Sonntag vor 25.12. (zw. 18. u. 24.12.)
			For $deztag = 18 To 24
				If _Weekday($deztag,12,$year) = "Sonntag" Then
					$4AdvDat = $year & "/12/" & $deztag
					$3AdvDat = _DateAdd( 'd', -7, $4AdvDat)
					$2AdvDat = _DateAdd( 'd', -14, $4AdvDat)
					$1AdvDat = _DateAdd( 'd', -21, $4AdvDat)
					$TotSoDat = _DateAdd( 'd', -28, $4AdvDat)
					$BuBDat = _DateAdd( 'd', -32, $4AdvDat)
					ExitLoop
				EndIf
			Next
			$4AdvDat = StringMid(_DateToNorm($4AdvDat),1,6)
			$3AdvDat = StringMid(_DateToNorm($3AdvDat),1,6)
			$2AdvDat = StringMid(_DateToNorm($2AdvDat),1,6)
			$1AdvDat = StringMid(_DateToNorm($1AdvDat),1,6)
			$TotSoDat = _DateToNorm($TotSoDat)
			$BuBDat = _DateToNorm($BuBDat)

			GUICtrlSetData($L_WFastDate, $WFastDate)
			GUICtrlSetData($L_RosDat, $RosDat)
			GUICtrlSetData($L_FastDat, $FastDat)
			GUICtrlSetData($L_AschDat, $AschDat)
			GUICtrlSetData($L_GrDoDat, $GrDoDat)
			GUICtrlSetData($L_KarDat, $KarDat)
			GUICtrlSetData($L_OSaDat, $OSaDat)
			GUICtrlSetData($L_OSoDat, $OSoDat)
			GUICtrlSetData($L_OMoDat, $OMoDat)
			GUICtrlSetData($L_HiFaDat, $HiFaDat)
			GUICtrlSetData($L_MutterDat,$MutterDat)
			GUICtrlSetData($L_PfSoDat, $PfSoDat)
			GUICtrlSetData($L_PfMoDat, $PfMoDat)
			GUICtrlSetData($L_FroDat, $FroDat)
			GUICtrlSetData($L_ErnteDat, $ErnteDat)
			GUICtrlSetData($L_TotSoDat, $TotSoDat)
			GUICtrlSetData($L_BuBDat, $BuBDat)
			GUICtrlSetData($L_1AdvDat,$1AdvDat)
			GUICtrlSetData($L_2AdvDat,$2AdvDat)
			GUICtrlSetData($L_3AdvDat,$3AdvDat)
			GUICtrlSetData($L_4AdvDat,$4AdvDat)			
		EndIf
		
	EndIf
	Select
	Case $msg = $GUI_EVENT_CLOSE
		ExitLoop
	Case $msg = $But_Ende
		ExitLoop	
	EndSelect
WEnd
Exit

;=====================================================================================================
;	Ende Code																						 ;
;=====================================================================================================