SumTingWong Posted December 3, 2004 Share Posted December 3, 2004 (edited) After noticing a lack of date functions in AutoIT, I have developed the attached dll with the following date functions:Util_DateFormatUtil_TimeFormatUtil_DateDiffUtil_DateAddUtil_DateFormat and Util_TimeFormat are basically wrappers for GetDateFormat and GetTimeFormat. You can find more info on these APIs on MSDN.Util_DateDiff and Util_DateAdd are similar to the equivalent vb script:expandcollapse popupDim $naDllRet $naDllRet = DllCall(@ScriptDir & "\AU3Date.dll", "int", "Util_DateFormat", _ "str", "dddd',' MMMM yyyy", _ "str", "", _ "int", @YEAR, _ "int", @MON, _ "int", @MDAY) If @error = 0 Then MsgBox(4096,'debug:' , '$naDllRet:' & $naDllRet[2]);### Debug MSGBOX EndIf $naDllRet = DllCall(@ScriptDir & "\AU3Date.dll", "int", "Util_TimeFormat", _ "str", "hh:mm:ss tt", _ "str", "", _ "int", @HOUR, _ "int", @MIN, _ "int", @SEC) If @error = 0 Then MsgBox(4096,'debug:' , '$naDllRet:' & $naDllRet[2]);### Debug MSGBOX EndIf $naDllRet = DllCall(@ScriptDir & "\AU3Date.dll", "int", "Util_DateDiff", _ "str", "y", _ "int", @YEAR, _ "int", @MON, _ "int", @MDAY, _ "int", @HOUR, _ "int", @MIN, _ "int", @SEC, _ "int", 1971, _ "int", 4, _ "int", 22, _ "int", 0, _ "int", 0, _ "int", 0) If @error = 0 Then MsgBox(4096,'debug:' , '$naDllRet:' & $naDllRet[0]);### Debug MSGBOX EndIf $naDllRet = DllCall(@ScriptDir & "\AU3Date.dll", "int", "Util_DateAdd", _ "int_ptr", @YEAR, _ "int_ptr", @MON, _ "int_ptr", @MDAY, _ "int_ptr", @HOUR, _ "int_ptr", @MIN, _ "int_ptr", @SEC, _ "str", "y", _ "int", -33) If @error = 0 Then MsgBox(4096,'debug:' , '$naDllRet:' & _ StringFormat("%02d/%02d/%04d %02d:%02d:%02d", _ $naDllRet[3], _ $naDllRet[2], _ $naDllRet[1], _ $naDllRet[4], _ $naDllRet[5], _ $naDllRet[6]));### Debug MSGBOX EndIfValid interval characters for Util_DateDiff and Util_DateAdd are:y = year, M = month, d = month day, h = hour, m = minute, s = secondMSDN link to GetDateFormat for more info on valid date pictures for use with Util_DateFormat and Util_TimeFormat.Test out it and let me know what you think.If people find them useful, I will submit them to Jon.AU3Date.dll Edited December 3, 2004 by pacman Link to comment Share on other sites More sharing options...
Valik Posted December 3, 2004 Share Posted December 3, 2004 Search for "DateNew.au3" Link to comment Share on other sites More sharing options...
SlimShady Posted December 3, 2004 Share Posted December 3, 2004 Search for "DateNew.au3"<{POST_SNAPBACK}>I expect the DLL to work better and faster.Am I wrong? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 3, 2004 Developers Share Posted December 3, 2004 I expect the DLL to work better and faster.Am I wrong?<{POST_SNAPBACK}>Better ? 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...
Valik Posted December 3, 2004 Share Posted December 3, 2004 Better? Doubtful. A good implementation in any language will always be equal. It could be slightly faster. However, I expect that offset some by loading the DLL. Plus, it requires a DLL, and I don't really see date functions going in as built-in functions given that JdeB has such a good library written in AutoIt. Link to comment Share on other sites More sharing options...
SumTingWong Posted December 3, 2004 Author Share Posted December 3, 2004 @JdeB - yours is a very good and complete implementation. Should definitely be a standard AU3 include. I knocked my dll up this morning because I needed the date functions and didn't know about DateNew.au3. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 3, 2004 Developers Share Posted December 3, 2004 @JdeB - yours is a very good and complete implementation. Should definitely be a standard AU3 include.<{POST_SNAPBACK}>The DateNew.au3 is planned to replace the current Date.au3 include.I knocked my dll up this morning because I needed the date functions and didn't know about DateNew.au3.<{POST_SNAPBACK}>No problem, i know that Nutster has Date functions on his ToDo list so they might make it in AutoIt3 at some point in time. Till then, i prefer using an Include over a DLL because it saves me from having to Fileinstall the DLL when the script is compiled and distributed. 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...
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