Jump to content

Time counting issue


topten
 Share

Go to solution Solved by Jewtus,

Recommended Posts

Which is the best algo of time counting?

For example I get innitial time of counting @HOUR @MIN . Say I have 17:45. For some time the script will need to sleep for X minutes and then continue on its work. Say I have 120 minutes of sleep or 210 minutes of sleep. Which is the best algo of calculating the time of script to continue?

 

Great thanx in advance!

Link to comment
Share on other sites

LOL, I calculated the new time. Here's the code anyway.

;

Local $sNewTime = TimeInterval("17:45", "09:16")
MsgBox(0, "", $sNewTime)

Func TimeInterval($sCurrentTime, $sInterval)
    Local $aHH_MM = StringSplit($sCurrentTime, ":"), $aTimeAdd = StringSplit($sInterval, ":")
    If Not (IsArray($aHH_MM) And IsArray($aTimeAdd)) Then Return SetError(1)
    If $aHH_MM[0] <> 2 Or $aTimeAdd[0] <> 2 Then Return SetError(2)

    Local $iHours = $aHH_MM[1] + $aTimeAdd[1], $iMins = $aHH_MM[2] + $aTimeAdd[2]
    If $iMins > 59 Then $iHours += 1
    $iHours = Mod($iHours, 24)
    $iMins = Mod($iMins, 60)

    Return StringFormat("%02i:%02i", $iHours, $iMins)
EndFunc
Edited by czardas
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...