Jump to content

Pancake Tuesday + Mothers Day


JohnOne
 Share

Recommended Posts

When is the next pancake Tuesday?

#include <Date.au3>

$YAY = _PancakeTuesday()

MsgBox(0, "Pancake Teusday", $YAY) ;year/month/day

Func _PancakeTuesday()
    For $iYe = @YEAR To @YEAR + 1
        For $iMon = 3 To 4
            For $iDa = 1 To 31
                If $iMon <> 4 And $iMon <> 3 Then ContinueLoop 2
                If $iMon = 3 And $iDa < 22 Then ContinueLoop
                If _IsEasterSunday($iDa, $iMon, $iYe) Then
                    $tmp = _DateAdd('w', -6, $iYe & "/" & $iMon & "/" & $iDa)
                    $PancakeTuesday = _DateAdd('D', -5, $tmp)
                    Return $PancakeTuesday
                EndIf
            Next
        Next
    Next
EndFunc   ;==>_PancakeTuesday

Func _IsEasterSunday($iday, $imonth, $iyear)
    ;http://www.autoitscript.com/forum/topic/120126-iseastersunday/#entry834668

    If $iyear < 1 Or $iyear > 9999 Then
        Return False
        Exit
    EndIf

    $a = Mod($iyear, 19)
    $b = Mod($iyear, 4)
    $c = Mod($iyear, 7)
    $d = Mod(19 * $a + 24, 30)
    $e = Mod(2 * $b + 4 * $c + 6 * $d + 5, 7)
    $sunday = 22 + $d + $e
    $month = 3

    If $sunday > 31 Then
        $month = 4
        $sunday -= 31
    EndIf

    If $iday = $sunday And $imonth = $month Then
        Return True
    Else
        Return False
    EndIf

EndFunc   ;==>_IsEasterSunday

:*

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

MsgBox(0, "Pancake Tuesday", $YAY) ;year/month/day

It's a typo.

Edited by DatMCEyeBall

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Link to comment
Share on other sites

MsgBox(0, "Pancake Tuesday", $YAY) ;year/month/day

It's a typo.

Yes. not important though.

Awesome, I love pancakes. This is just the kind of script I need to combine with _LochNessMonsterCase() to make a UDF for ages 5 and upwards. :)

Me too, roll on nom nom :)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

A lot of these days can be calculated via Easter it seems.

Mothers Day (Mothering Sunday - UK)

#include <Date.au3>

$YAY = _MothersDay()

MsgBox(0, "Mothers Day", $YAY) ;year/month/day

Func _MothersDay()
    For $iYe = @YEAR To @YEAR + 1
        For $iMon = 3 To 4
            For $iDa = 1 To 31
                If _IsEasterSunday($iDa, $iMon, $iYe) Then
                    $mothersDay = _DateAdd('w', -3, $iYe & "/" & $iMon & "/" & $iDa)
                    Return $mothersDay
                EndIf
            Next
        Next
    Next
EndFunc   ;==>_MothersDay

Func _IsEasterSunday($iday, $imonth, $iyear)
    ;http://www.autoitscript.com/forum/topic/120126-iseastersunday/#entry834668

    If $iyear < 1 Or $iyear > 9999 Then
        Return False
        Exit
    EndIf

    $a = Mod($iyear, 19)
    $b = Mod($iyear, 4)
    $c = Mod($iyear, 7)
    $d = Mod(19 * $a + 24, 30)
    $e = Mod(2 * $b + 4 * $c + 6 * $d + 5, 7)
    $sunday = 22 + $d + $e
    $month = 3

    If $sunday > 31 Then
        $month = 4
        $sunday -= 31
    EndIf

    If $iday = $sunday And $imonth = $month Then
        Return True
    Else
        Return False
    EndIf

EndFunc   ;==>_IsEasterSunday
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Moms Day US is a little easier.

#include <Date.au3>

$YAY = _MothersDayUSA()

MsgBox(0, "Mothers Day USA", $YAY) ;year/month/day

Func _MothersDayUSA()
    For $iYe = @YEAR + 2 To @YEAR + 3
        $iMon = 5
        For $iDa = 1 To 30
            $DateToDayOfWeek = _DateToDayOfWeek($iYe, $iMon, $iDa)
            If _DateDayOfWeek($DateToDayOfWeek) == "Sunday" Then
                $mothersDayUSA = _DateAdd('w', 1, $iYe & "/" & $iMon & "/" & $iDa)
                Return $mothersDayUSA
            EndIf
        Next
    Next
EndFunc   ;==>_MothersDayUSA

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...