Jump to content

Search the Community

Showing results for tags 'sunday;'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hi. For a certain task I need to know, if "today" is a working day (Mo-Fr, and not a Holiday either). Maybe someone else comes across a similar task: ; Autoit v3.3.8.1 #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_LegalCopyright=Rudolf Thilo, IT-Beratung Rudolf Thilo #AutoIt3Wrapper_Res_Language=1031 #AutoIt3Wrapper_Res_Field=email|autoit@ithilo.de #AutoIt3Wrapper_Res_Field=author|Rudolf Thilo (forum: "rudi") #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include-once #include <Date.au3> #include <array.au3> ; Example Call for the function: $Result = CheckWorkingDay("2012/04/08") ; that was Easter Sunday this year If $Result == True Then ConsoleWrite("Working Day" & @LF) Else ConsoleWrite($Result & @LF) EndIf Func CheckWorkingDay($Date = False) ; Function to check, if a Date is a workingday (TRUE), or "Saturday", "Sunday", "Holiday" ; Add / Remove holidays by altering the Array $aHDay ; German National Holidays (Bavaria, predominantly katholic cities) are implemented, also the Easter dependant holidays are included. (Gauss' Easter Formula) ; ;Optional Parameter $Date: If no date value "yyyy/mm/dd" is specified, "today" will be processed ; A validity check for $Date is *NOT* done! ; ; Return value: "True", if "working day" is detected; otherwise: "Saturday", "Sunday" or "Holiday" ; if a Saturday or Sunday is a Holiday as well, "Holiday" is returned. ; important note: As the return value is *NEVER* "False", you have to compare it with "==" instead of "=" !! ; Example: if CheckHoliday() == True then ... ; the statement "if CheckHoliday() then..." will *ALWAYS* be True, so it's useless as well. If $Date = False Then $Date = _NowCalcDate() ; Funktion within a Function Definition is not allowed: So $Date=False in definition, fill in "today" here... Local $Year = StringLeft($Date, 4) ; get the year Local $a, $b, $c, $d, $e, $m, $N, $k, $q If $Year < 1582 Then $Calendar = "julian" ; the retirement of the "Julian Calendar" began 1582. Else $Calendar = "gregorian" ; The use of the "Gegorian Calendar" started 1582. In 1949 China was the last state to introduce the Gregorian Calendar. EndIf $a = Mod($Year, 19) $b = Mod($Year, 4) $c = Mod($Year, 7) $k = Int($Year / 100) $p = Int((8 * $k + 13) / 25) $q = Int($k / 4) Switch $Calendar Case "gregorian" $m = Mod(15 + $k - $p - $q, 30) $N = Mod(4 + $k - $q, 7) Case "julian" $m = 15 $N = 6 EndSwitch $d = Mod(19 * $a + $m, 30) $e = Mod(2 * $b + 4 * $c + 6 * $d + $N, 7) $Shift = 22 + $d + $e ; could have used "21" here, saving the "-1" next line. Then it wouldn't match the Gauss Formula found elswhere in the web. $Easter = _DateAdd("D", $Shift - 1, $Year & "/03/01") ; "-1", because Gauss' Easter Rule returns the "Day-of-March", so we have to start at "-1" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Easter = ' & $Easter & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Local $aHDay[1] _ArrayAdd($aHDay, $Year & "/01/01") ; Neujahr _ArrayAdd($aHDay, $Year & "/01/06") ; Hl. 3 König #region Easter related holidays, Germany _ArrayAdd($aHDay, _DateAdd("D", -2, $Easter)) ; Karfreitag _ArrayAdd($aHDay, $Easter) ; Ostersonntag _ArrayAdd($aHDay, _DateAdd("D", 1, $Easter)) ; Ostermontag _ArrayAdd($aHDay, _DateAdd("D", 39, $Easter)) ; Christi Himmelfahrt _ArrayAdd($aHDay, _DateAdd("D", 49, $Easter)) ; Pfingstsonntag _ArrayAdd($aHDay, _DateAdd("D", 50, $Easter)) ; Pfingstmontag _ArrayAdd($aHDay, _DateAdd("D", 60, $Easter)) ; Fronleichnam #endregion Easter related holidays, Germany _ArrayAdd($aHDay, $Year & "/08/15") ; Mariä Himmelfahrt _ArrayAdd($aHDay, $Year & "/10/03") ; Tag der deutschen Einheit _ArrayAdd($aHDay, $Year & "/11/01") ; Allerheiligen _ArrayAdd($aHDay, $Year & "/12/25") ; 1. Weihnachtsfeiertag _ArrayAdd($aHDay, $Year & "/12/26") ; 2. Weihnachtsfeiertag ; add other national / regional holidays here: Reformationstag, Friedensfest, Buß & Bettag... Local $WorkingDay = True ; Retun value, in case the lines below don't detect Sat, Sun, Holiday. Local $Mon = StringMid($Date, 6, 2) Local $Day = StringRight($Date, 2) Switch _DateToDayOfWeekISO($Year, $Mon, $Day) ; 1 = Monday, 7 = Sunday Case 6 $WorkingDay = "Saturday" Case 7 $WorkingDay = "Sunday" EndSwitch For $i = 1 To UBound($aHDay) - 1 If $Date = $aHDay[$i] Then $WorkingDay = "Holiday" ExitLoop EndIf Next Return $WorkingDay #cs Osterabhängige Tage Rosenmontag: -48 Tage Faschingsdienstag: -47 Tage Karfreitag: -2 Tage Ostermontag: +1 Tag Christi Himmelfahrt: +39 Tage Pfingstsonntag: +49 Tage Pfingstmontag: +50 Tage Fronleichnam: +60 Tage #ce EndFunc ;==>CheckWorkingDay Regards, Rudi.
×
×
  • Create New...