Jump to content

Time Difference


Recommended Posts

I know I can't be the only one looking for The time difference on a 9/80 secdual
(ie first week Mon-Thurs 9 hours, Fri 8 hours, second week Mon-Thu 9 hours Friday off)
Any pointer will help ( I have searched the form and haven't found what I want)

Link to comment
Share on other sites

I saw it.  What exactly are you trying to calculate/accomplish?

Maybe this is something to play with.

#include <date.au3>

Local $iYear = 2022
Local $iMonth = 1
Local $iDay = 2

For $i = 2 to 15
    Local $iHours = _Calculate9x80WorkHoursFromDate($iYear, $iMonth, $iDay)
    $sDayOfWeek = _DateDayOfWeek(_DateToDayOfWeek($iYear,$iMonth,$iDay),$DMW_LOCALE_LONGNAME)
    $sDate = StringFormat("%-24s", $iYear & "/" & $iMonth & "/" & $iDay & " (" & $sDayOfWeek & "): " )
    ConsoleWrite($sDate & ((IsNumber($iHours)) ? $iHours & " hours" : $iHours) & @CRLF)
    $iDay += 1

Func _Calculate9x80WorkHoursFromDate($iYear, $iMonth, $iDay)
    ;Determine Day of the Week from Date YYYY MM DD
    $iWeekDay = _DateToDayOfWeek($iYear,$iMonth,$iDay)
    If @error Then Return -1

    Local $iHours = ""
    Switch $iWeekDay
        Case 2 To 5
            ;If Day of the Week is Monday - Thursday, Work hours is 9
            $iHours = 9
        Case 6
            ;If Day of the Week is Friday, Calculate work hours based on Week number - Odd Week's are Off Fridays; Even week's work hours are 8
            $iHours = (Mod(_WeekNumberISO($iYear, $iMonth, $iDay),2)) ? "Off Friday" : 8
        Case Else
            $iHours = "Off day"

    Return $iHours


Edited by spudw2k
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

  • Recently Browsing   0 members

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