Jump to content

Time Calcs Advice Please


Recommended Posts

Hello everyone,

Please can some one give me some advice. I have two log files that are both changing depending on the test that is being run. I have used timestamp to mark the file test sequence. The files are log1 and log2, both have a timestamp written hh:mm:ss at each line in the file. So far I have read the last line in the file since it is updating during testing and I have two text strings that I am stripping out the time string using string handling expressions and the text strings are stored in $time1 and $time2.

What I want to do is subtract the two times as a numeric operation and test the difference to make sure the times are within a tolerance of a maximum difference of 5 mins.

Can anyone point me at the right command to do this or offer any useful pointers to a autoit newbie please.

many thanks in advance

Link to comment
Share on other sites

Thank you Andreik can I ask for a few more pointers or advice.

So taking my two time strings hh:mm:ss for $Time1 and $Time2 do I need to add on year, month and date with / and space before I can compare the time strings ?

eg. $iDateCalc = _DateDiff( 'n',@YEAR & "/" & @MONTH & "/" & @DAY & " " & $Time1,_NowCalc())

Have a look in help file at function _DateDiff()

Link to comment
Share on other sites

Thank you Andreik can I ask for a few more pointers or advice.

So taking my two time strings hh:mm:ss for $Time1 and $Time2 do I need to add on year, month and date with / and space before I can compare the time strings ?

eg. $iDateCalc = _DateDiff( 'n',@YEAR & "/" & @MONTH & "/" & @DAY & " " & $Time1,_NowCalc())

Thanks Andreik,

I got this working and I can develop my script further good advice.

Here is my test script after yoour advice

#include <Date.au3>

$sTime1 = _NowCalc()

MsgBox( 4096, "", "Time Now: " & $sTime1 )

Sleep(5000)

$sTime2 = (@YEAR & "/" & @MON & "/" & @MDAY & " " & _NowTime() )

MsgBox( 4096, "", "Time Next: " & $sTime2 )

; Calculated the number of seconds difference

$iDateCalc = _DateDiff( 's',$sTime1,$sTime2 )

MsgBox( 4096, "", "Time Difference: " & $iDateCalc )

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...