Search the Community
Showing results for tags 'between'.
-
it recomended to use the builten function _DateDiff hello autoit team i made a simple function to help me get the difference between to date i liked to share it with you the paramatrs of this function is firstdate and lastedate the two params is as the following year/month/day hours:minuts:seconds here is the function #include <date.au3> func _dateBetween($s_firstDate, $s_lastDate = default) if not (StringRegExp($s_firstDate, "((\d{4})\/(\d{2})\/(\d{2})\s(\d{2})\:(\d{2})\:(\d{2}))", 0) = 1) then Return SetError(1, 0, 0) if $s_lastDate = default then $s_lastDate = @year & "/" & @mon & "/" & @mday & " " & @hour & ":" & @min & ":" & @sec if not (StringRegExp($s_lastDate, "((\d{4})\/(\d{2})\/(\d{2})\s(\d{2})\:(\d{2})\:(\d{2}))", 0) = 1) then Return SetError(2, 0, 0) local $a_FirstSplitDate = StringSplit(StringRegExpReplace($s_firstDate, "((.*)\s(.*))", "$2"), "/", 2) local $a_FirstSplitTime = StringSplit(StringRegExpReplace($s_firstDate, "((.*)\s(.*))", "$3"), ":", 2) local $a_lastSplitDate = StringSplit(StringRegExpReplace($s_lastDate, "((.*)\s(.*))", "$2"), "/", 2) local $a_LastSplitTime = StringSplit(StringRegExpReplace($s_lastDate, "((.*)\s(.*))", "$3"), ":", 2) local $i_firstDateValue = _DateToDayValue($a_FirstSplitDate[0], $a_FirstSplitDate[1], $a_FirstSplitDate[2]) local $i_LastDateValue = _DateToDayValue($a_LastSplitDate[0], $a_LastSplitDate[1], $a_LastSplitDate[2]) if $i_firstDateValue > $i_LastDateValue then Return SetError(3, 0, 0) local $i_totalDays = $i_LastDateValue-$i_firstDateValue if not ($i_totalDays = 0) then if $a_FirstSplitTime[0] <= $a_lastSplitTime[0] then $i_totalDays += 1 $a_lastSplitTime[0] -= $a_FirstSplitTime[0] elseIf $a_FirstSplitTime[0] > $a_lastSplitTime[0] then if $i_totalDays > 0 then $i_totalDays -= 1 $a_FirstSplitTime[0] -= $a_lastSplitTime[0] endIf endIf endIf local $i_totalYears = 0 if $i_totalDays >= 365 then While $i_totalDays >= 365 $i_totalYears += 1 $i_totalDays -= 365 Wend endIf local $i_TotalMonths = 0 if $i_totalDays >= 30 then While $i_totalDays >= 30 $i_totalMonths += 1 $i_totalDays -= 30 Wend endIf local $i_totalWeeks = 0 if $i_totalDays >= 7 then While $i_totalDays >= 7 $i_totalWeeks += 1 $i_totalDays -= 7 Wend endIf $i_totalSeconds = ((($a_FirstSplitTime[0]*60)*60)+($a_FirstSplitTime[1]*60)+($a_FirstSplitTime[2]))-((($a_lastSplitTime[0]*60)*60)+($a_lastSplitTime[1]*60)+($a_LastSplitTime[2])) local $minus = "" if $i_totalSeconds < 0 then $minus = "-" $i_totalSeconds = StringReplace($i_totalSeconds, "-", "") endIf local $i_totalHours = 0 if $i_totalSeconds >= 3600 then While $i_totalSeconds >= 3600 $i_totalHours += 1 $i_totalSeconds -= 3600 Wend endIf local $i_totalminuts = 0 if $i_totalSeconds >= 60 then While $i_totalSeconds >= 60 $i_totalminuts += 1 $i_totalSeconds -= 60 Wend endIf local $a_arrayReturn[7] $a_arrayReturn[0] = $i_totalYears $a_arrayReturn[1] = $i_totalMonths $a_arrayReturn[2] = $i_totalWeeks $a_arrayReturn[3] = $i_totalDays $a_arrayReturn[4] = $minus & $i_totalHours $a_arrayReturn[5] = $minus & $i_totalminuts $a_arrayReturn[6] = $minus & $i_totalSeconds return $a_arrayReturn endFunc here is an example $a_calc = _dateBetween("2015/02/12 23:00:05", "2030/02/12 23:25:50") msgBox(64, "result", StringFormat("the difference is : %i years and %i months and %i weeks and %i days and %i hours and %i minuts and %i seconds", $a_calc[0], $a_calc[1], $a_calc[2], $a_calc[3], $a_calc[4], $a_calc[5], $a_calc[6])) am waiting for your comments with my greetings
- 4 replies
-
- date
- calculator
-
(and 3 more)
Tagged with:
-
Hey everyone I'm stuck with this regular expression, for matching a iso standard version what I want to do is match the text in green: ISO 11784:1996/Amd.2:2010(E) there is also others that look like this: ISO 11789:1999(E), and without the (E) part, Só I did this one (?i)ISO.+?[\d-]+:(?:\d+/Amd.+?:)?[\d-]+(?:\(\w\))* to match both cases but doesn't ignore the text in red Can somebody point out what I'm doing wrong here?
-
hey guys, anyone knows how to write a string between two other strings like for example: To write AbzhdfX_d between ElseIf $sVideoLink1 = " and " then _IEAction ($oA, "click"), Simpler: to write a between b and c ,but automatically
-
Just A Problem don't know how to name it^^
RaiNote posted a topic in AutoIt General Help and Support
Well Hello, I currently a bit sad because i can't find anywhere in helpfiles and google away in autoit to check if a number between another number is the same as 4 variables which is checking if the main variable got the same princip of looking >.<.( I really can't explain it at all) Case $Send2Box $ReadText2Box = GuictrlRead($Text2Box) _GUICtrlEdit_AppendText($Console, $ReadText2Box & @CRLF) If $ReadText2Box = '/ping ' & $ip1 & '.' & $ip2 & '.' & $ip3 & '.' & $ip4 Then $IP = StringRight('/ping ', 1) $Ping = Ping($IP) _GUICtrlEdit_AppendText($Console,'Ping is: ' & $Ping & 'ms') GUICtrlSetData($Text2Box,'') EndIfNext try to explain ^-^ i want to check if the text in the inputbox($Text2Box which is read from $ReadText2Box) the same looking like a ip but with a '/ping ' before and i don't know how to make the variables to check this.. and getting after it checked that it is truly a IP to ping it and send it to $Console to display the ms I hope i could explained it anyway to understand it(if i write more i am getting more confused) Thanks to everyone who try's to help me -
Hi everyone I trying for more than a hour to get this regular expression right, what I want to do is grab multiple strings inside a table/div on a webpage the problem is to put this to check multiple times for the expressions to capture between (in the example " and "</table") In this example I'm trying to get all the topic names listed on first page of "General Help and Support" from Autoit forum's but limiting the search/capture between '<table class="ipb_table topic_list hover_rows " summary="Topics In This Forum "General Help and Support"" id="forum_table">' and '</table>' (I don't know how to paste this tidy, if some one experienced in the mater can share the secret I'll be grateful ) #include <Array.au3> $pg = InetRead("http://www.autoitscript.com/forum/forum/2-general-help-and-support/",1) If $pg <> '' Then $exp = '(?i)<table class="ipb_table topic_list hover_rows " summary="Topics In This Forum "General Help and Support"" id="forum_table">.*?'& _ '(?:<a itemprop="url" id=".*?" href=".*?" title="(.*?) - started .*?" class="topic_title">)*?.*?</table>' $aTopics = StringRegExp(BinaryToString($pg),String($exp),3) ConsoleWrite(@error&@LF) _ArrayDisplay($aTopics) Else ConsoleWrite("Cannot DL the page"&@LF) EndIf Exit EDIT: Code updated, forgot to add 'BinaryToString' to $pg var
- 12 replies
-
- stringregexp
- div
- (and 5 more)