DaProgrammer Posted July 20, 2007 Share Posted July 20, 2007 Did Some1 write a Func that checks if a date has expired (AKA: has been; old) ? i can write 1 of my own i gess, but i was just wondering if some1 saw anything of the kind ? Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 20, 2007 Share Posted July 20, 2007 Hi, for what? Parameter date and days and then return if expired? So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
DaProgrammer Posted July 20, 2007 Author Share Posted July 20, 2007 (edited) Hi, for what? Parameter date and days and then return if expired? So long, Mega i have a Date : "19/02/2007" & Time : "12:01:53" i need to check against the PC clock to see if this Moment Has happend or is in the future. EDIT : i found this but it doesnt work :? any1 knows why ? If _DateDiff("s", IniRead2($i2, "Year") & "/" & IniRead2($i2, "Month") & "/" & IniRead2($i2, "Day") & "[" & IniRead2($i2, "Hour") & ":" & IniRead2($i2, "Minute") & ":00]", @YEAR & "/" & @MON & "/" & @MDAY & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "]") > 0 Then Lunch() Edited July 20, 2007 by DaProgrammer Link to comment Share on other sites More sharing options...
DW1 Posted July 20, 2007 Share Posted July 20, 2007 (edited) This should get you started _NowCalc ( ) : Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS EDIT: You need to use the "#Include <Date.au3>" Edited July 20, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DaProgrammer Posted July 20, 2007 Author Share Posted July 20, 2007 (edited) This should get you started _NowCalc ( ) : Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS EDIT: You need to use the "#Include <Date.au3>" ty, its easier this way. now why does this doesnt work : If _DateDiff( 's',$Input_Year & "/" & $Input_Month & "/" & $Input_Day & " " & $Input_Hour & ":" & $Input_Min & ":00",_NowCalc()) > 0 Then Return this wont work either : If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then Return Edited July 20, 2007 by DaProgrammer Link to comment Share on other sites More sharing options...
DW1 Posted July 20, 2007 Share Posted July 20, 2007 if its a gui input, you need to use this syntax: GUICtrlRead( $Input_Year ) AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DaProgrammer Posted July 20, 2007 Author Share Posted July 20, 2007 OK now it works when its clean program like this : #include <Date.au3> $Input_Day = 15 $Input_Hour = 12 $Input_Min = 12 $Input_Month = 06 $Input_Year = 2006 If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then MsgBox(0,"",_NowCalc()) but inside Function it doesnt why ? Func Save() If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then Return Link to comment Share on other sites More sharing options...
DaProgrammer Posted July 20, 2007 Author Share Posted July 20, 2007 (edited) if its a gui input, you need to use this syntax: GUICtrlRead( $Input_Year ) dammit LOL how did i forgot u have no idea how imberesed i feel right now EDIT : Got it to work Edited July 20, 2007 by DaProgrammer Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 20, 2007 Share Posted July 20, 2007 (edited) Where are $Input_Year and the others declared? Are the local to another function or are they parameters? You need to make sure that the correct value cascades through the program.Edit: Ok, nevermind. Edited July 20, 2007 by Richard Robertson Link to comment Share on other sites More sharing options...
Developers Jos Posted July 20, 2007 Developers Share Posted July 20, 2007 (edited) OK now it works when its clean program like this : #include <Date.au3> $Input_Day = 15 $Input_Hour = 12 $Input_Min = 12 $Input_Month = 06 $Input_Year = 2006 If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then MsgBox(0,"",_NowCalc()) but inside Function it doesnt why ? Func Save() If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then ReturnJust try to do some debugging when you are programming and it doesn't work as expected. Put MsgBox() or ConsoleWrite statement in your code to check the exact content of variables ... (avoid this guessing game) Also no need for the string() function in there ... Edited July 20, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
DW1 Posted July 20, 2007 Share Posted July 20, 2007 LOL, as long as it works AutoIt3 Online Help Link to comment Share on other sites More sharing options...
SpookMeister Posted July 20, 2007 Share Posted July 20, 2007 (edited) I made this a while back... does it suit your needs? ;You must #include <date.au3> ;Returns the age of a file in days Func _FileAge($FilePathAndName) $iToday = _DateToDayValue (@YEAR, @MON, @MDAY) $iTime = FileGetTime($FilePathAndName,0,0) $iJulian = _DateToDayValue($iTime[0], $iTime[1], $iTime[2]) $iAge = $iToday - $iJulian If $iAge < 0 Then $iAge = 0 Return ($iAge) EndFunc Edited July 20, 2007 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 20, 2007 Share Posted July 20, 2007 Hi, or easy way: #include<date.au3> Global $date = "2006/02/19 12:01:53" MsgBox(0,"",_checkDate($date)) Func _checkDate($date) If $date < _NowCalc() Then Return 1; past If $date = _NowCalc() Then Return 2 If $date > _NowCalc() Then Return 3; future EndFunc ;==>_checkDate So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 20, 2007 Share Posted July 20, 2007 Hi, or easy way: #include<date.au3> Global $date = "2006/02/19 12:01:53" MsgBox(0,"",_checkDate($date)) Func _checkDate($date) If $date < _NowCalc() Then Return 1; past If $date = _NowCalc() Then Return 2 If $date > _NowCalc() Then Return 3; future EndFunc ;==>_checkDate So long, MegaGood idea, but I would go with returns of 0, 1, and 2, which makes it easier to use with: If _checkDate() Then... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now