VelvetElvis Posted July 21, 2011 Share Posted July 21, 2011 Ran into the _FTP_ListToArrayEx() date bug. The documentation says the function returns yyyy/mm/dd hh:mm:ss, but it actually returns yyyy/dd/mm hh:mm:ss., according to the bug report hereI'm not clear how to code around this, so that when it's fixed in an upcoming release, it doesn't break my code where it compares this function date with a date variable. Can someone give me some ideas how to cope with this? Thanks. Link to comment Share on other sites More sharing options...
sleepydvdr Posted July 21, 2011 Share Posted July 21, 2011 I have a fix for you. Download this modified Date.au3 file and go to C:\Program Files\AutoIt3\Include folder and replace it. If you want to see what I did, open it in Scite and go to line 1954. The line under it is the original line. http://www.digifract.com/VB/date.zip The FTP function you are using uses the Date.au3 to format the string, so that's what I concentrated on. Here's the code I used to test it: #include <date.au3> $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC) MsgBox(0, "", "Current date/time .: " & _Date_Time_FileTimeToStr($tFile, 0)) MsgBox(0, "", "Current date/time .: " & _Date_Time_FileTimeToStr($tFile, 1)) #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
VelvetElvis Posted July 21, 2011 Author Share Posted July 21, 2011 Thanks a bunch for the code, but the problem is, this may be running on other machines, in uncompiled form. I'd really like to know how to handle this bug within my own app. It wasn't clear to me when the fix will be implemented. Can you (or anyone else) tell me how to deal with this without patching AutoIt? Here's what I'd like to do: Use @AutoItVersion with two different date parsing routines. This is preferable to me. Problem with this is I don't know what version the fix will finally be in so I can write the IF statement, e.g. If @AutoItVersion > "3.3.6.1" ; How do I know if this fix will be in the next release? Link to comment Share on other sites More sharing options...
sleepydvdr Posted July 22, 2011 Share Posted July 22, 2011 Something line this would work. You would have to set $originalDate to the date that is output from the function. #include <array.au3> $originalDate = "2011/21/07 08:03:04" $originalTime = StringRight($originalDate, 8) $dateOnly = StringLeft($originalDate, 10) $dateArray = StringSplit($dateOnly, "/") $newDate = $dateArray[1] & "/" & $dateArray[3] & "/" & $dateArray[2] & " " & $originalTime MsgBox(0, "", $newDate) #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
VelvetElvis Posted July 22, 2011 Author Share Posted July 22, 2011 Something line this would work. You would have to set $originalDate to the date that is output from the function. #include <array.au3> $originalDate = "2011/21/07 08:03:04" $originalTime = StringRight($originalDate, 8) $dateOnly = StringLeft($originalDate, 10) $dateArray = StringSplit($dateOnly, "/") $newDate = $dateArray[1] & "/" & $dateArray[3] & "/" & $dateArray[2] & " " & $originalTime MsgBox(0, "", $newDate) Thank you Vegan for taking the time. The only problem with this is if the next version of AutoIt fixes this function (as it appears they will.) Then this will fail, when the date pulled from _FTP_ListToArrayEx, changes (from yyyy/dd/mm to yyyy/mm/dd). Once I put this .au3 version of the app out, I don't want to worry about revisiting it. I guess what I need is something like this pseudocode: If <broken version of Autoit> then <your modified code> Else <normal date handling code> EndIf I just don't know how to write the "If" statement. Link to comment Share on other sites More sharing options...
sleepydvdr Posted July 22, 2011 Share Posted July 22, 2011 There are lots of ways to handle the code. Here are a few: @AutoItVersion or FileReadLine("C:\Program Files\AutoIt3\Include\Date.au3", 1954) or You could modify the line in the current Date.au3 to append a character to the beginning or end of the string. When you get the result, check for that character and if it exists, trim it from the string. If it doesn't exist, then run the code that reformats the string. However, none of these are 100% guaranteed since it is not guaranteed it will be fixed in the next AutoIt version. And it's not even guaranteed that the next version of AutoIt will function the same way or return the same date format. Your best bet is make two sections in your script and comment out the section not being used today (so you can come back to it later if needed). Then compile the executable. Compiled versions won't change no matter what version of AutoIt you have installed. Later on, if AutoIt changes, you will still have quick access to fix the future version with the commented section. #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
VelvetElvis Posted July 22, 2011 Author Share Posted July 22, 2011 There are lots of ways to handle the code. Here are a few:@AutoItVersionorFileReadLine("C:\Program Files\AutoIt3\Include\Date.au3", 1954)or You could modify the line in the current Date.au3 to append a character to the beginning or end of the string. When you get the result, check for that character and if it exists, trim it from the string. If it doesn't exist, then run the code that reformats the string.However, none of these are 100% guaranteed since it is not guaranteed it will be fixed in the next AutoIt version. And it's not even guaranteed that the next version of AutoIt will function the same way or return the same date format. Your best bet is make two sections in your script and comment out the section not being used today (so you can come back to it later if needed). Then compile the executable. Compiled versions won't change no matter what version of AutoIt you have installed. Later on, if AutoIt changes, you will still have quick access to fix the future version with the commented section.OK. Again, thanks very much for your help. Link to comment Share on other sites More sharing options...
ProgAndy Posted July 22, 2011 Share Posted July 22, 2011 (edited) In 3.3.7.0 the bug is fixed. If you really need compatibility for 3.3.6.1 and 3.3.7.0, then copy the fixed functions to your script and rename them (please keep the Author-comments) Edited July 22, 2011 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
VelvetElvis Posted July 22, 2011 Author Share Posted July 22, 2011 In 3.3.7.0 the bug is fixed. If you really need compatibility for 3.3.6.1 and 3.3.7.0, then copy the fixed functions to your script and rename them (please keep the Author-comments)I finally got my ability to run the beta fixed. Was looking forward to using the beta for this particular app. Unfortunately, I get a failure with _FTP_ListToArrayEx with the beta.Thanks for the great suggestion. I'm going to post the _FTP_ListToArrayEx problem in a new post, and hopefully be able to just use the beta. 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