Code: Select all
;GameNtt
Gui, New, ,A Program To Find The Day Of Any Date
Gui, Add, Text, ,Example Date Is 24/09/2022, Where 24 Is The Date, 09 Is The Month, 2022 Is The Year
Gui, Add, Text, ,Enter The Date
Gui, Add, Edit, vDate
Gui, Add, Text, ,Enter The Month
Gui, Add, Edit, vOMonth
Gui, Add, Text, ,Enter The Year In Atleast Four Digits
Gui, Add, Edit, vOYear
Gui, Add, Button, default xm, OK
Gui, Show
Return
ButtonOK:
Gui, Submit
if(OMonth == 1)
{
Month := 11
Year := OYear-1
}
if(OMonth == 2)
{
Month := 12
Year := OYear-1
}
if(OMonth != 1 && OMonth != 2)
{
Month := OMonth-2
Year := OYear
}
YearLen := StrLen(Year)
Decade := SubStr(Year, -1, 2)
Century := SubStr(Year, 1, YearLen-2)
F := Date + (((13*Month)-1)//5) + Decade + (Decade//4) + (Century//4) - (2*Century)
modF := cMod(F,7)
If (modF == 0)
ans := "Sunday"
Else If (modF == 1)
ans := "Monday"
Else If (modF == 2)
ans := "Tuesday"
Else If (modF == 3)
ans := "Wednesday"
Else If (modF == 4)
ans := "Thursday"
Else If (modF == 5)
ans := "Friday"
Else If (modF == 6)
ans := "Saturday"
Else
ans := "invalid"
Gui, New, ,A Program To Find The Day Of Any Date
if(ans == "invalid")
{
Gui, Add, Text, ,The Date Given Is Invalid, Please Try Again :(
Gui, Add, Button, default,Try Again
Gui, Add, Button, ,Exit
Gui, Show
}
Gui, Add, Text, ,%Date%/%OMonth%/%OYear% is a %ans%
Gui, Add, Button, default,Another Date
Gui, Add, Button, ,Exit
Gui, Show
Return
ButtonTryAgain:
Reload
Return
ButtonAnotherDate:
Reload
Return
ButtonExit:
ExitApp
GuiClose:
ExitApp
cMod(dividend, divisor)
{
if(dividend > 0)
{
Return Mod(dividend, divisor)
}
else if(divident < 0)
{
While(dividend < 0)
{
dividend += divisor
}
return Mod(dividend, divisor)
}
else
{
Return 0
}
}
Edit 2 - Added a comment to say that you can change the Gui button to default if you prefer it that way.
Edit 3 - Added a function cMod in case the value of F is negative which is possible due to certain century values (eg: 99) and made this Script support more than 4 digit years. (I have no idea how you would verify that far into the future but go ahead trying to verify.)