Sign in to follow this
Followers
0
-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By nacerbaaziz
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
-
By ergo
CronToTime.au3 UDF converts a Unix Cron expression into a DateTime string.
On Unix systems a Cron expression made of five fields separated by blanks/tabs followed by a shell command to execute.
e.g. 15-30 2,3,4,5 29 1-12 0-6 reboot
+------------- minute (0 - 59)
¦ +------------- hour (0 - 23)
¦ ¦ +------------- day of month (1 - 31)
¦ ¦ ¦ +------------- month (1 - 12)
¦ ¦ ¦ ¦ +------------- day of week (0 - 6) (Sunday to Saturday, 7 is also Sunday)
¦ ¦ ¦ ¦ ¦ +------------- some shell command
¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ ¦ ¦ ¦ ¦
* * * * * reboot
(In this UDF the 6th field has no meaning and no influence on the result).
For more information see https://en.wikipedia.org/wiki/Cron
Finds the next event of the specified Cron expression, starting from current UTC/GMT.
_pce_findNextTimeUTC($sCronExp [, $bForwardSearch = True [, $minutesOffset = 0]]])
Finds the next event of the specified Cron expression. If $sDateTime is not set, local time will be used.
_pce_findNextTime($sCronExp [, $bForwardSearch = True [, $sDateTime = "" [, $minutesOffset = 0]]])
Convert names in usable Cron expression values. e.g. "15-30 2,3,4,5 29 July-December Mo-Su" to "15-30 2,3,4,5 29 7-12 1-7"
_pce_convertNames( $sCronExp )
See the include for details.
New version on GitHub: https://github.com/seizu/CronToTime
-
By ur
I have an exe with name "erwin Data Modeler r9.7 (32-bit)_2332.exe"
THe lat 4 digits 2332 may vary and also the version number r9.7 also might vary.
So, how to write a generic expression so that the exe can be picked from the current directory {with any version (9.7 or anything) and any build number (2332 or anything)}
Thanks in Advance
-
By Reizvoller
Howdy!
I am trying to do something a little whacky but here's the function that's kicking back an error.
I am fairly sure I am overlooking a simple error but I am not seeing it.
Func mouseSpot () Global $mouseSpot = MouseGetPos() ConsoleWrite ($mouseSpot[0] & ", " & $mouseSpot[1] & @CRLF) FileWriteLine ("mouseGrabs.txt" , "MouseClick ('"'primary'"' , $mouseSpot[0] , $mouseSpot[1], 1, 10)" ) EndFunc The error displays as this
Any thoughts?
Thanks!
-Reiz
-