
LaurentC
Active Members-
Posts
32 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
LaurentC's Achievements
-
Yes = the same code algorithm than _FileGetTimeDST() that I propose in my previous post, but 5 years ago : https://www.autoitscript.com/forum/topic/205935-filegettime-uses-an-improper-tzdst-shift-at-todays-date/page/2/?tab=comments#comment-1483426 I just coded, additionally, all the FileGetTime() options with the returned string for my usage @hifi55 proposes also FileSetTimeExt() ! and all explanations Nice π
-
Hi I've discovered today there was an AutoIt ticket 6 years ago ! FileGetTime out by exactly one hour : https://www.autoitscript.com/trac/autoit/ticket/3139 The ticket was classified as 'No bug' ! And I think AutoIt is right !! The FileGetTime() function is conformed to Microsoftβs implementation !!! That why I mean this is an AutoIt documentation issue (if we can say that, of course ; -) As a new user of FileGettime(), I have started a new subject, because there was no DST warning inside FileGetTime() Help that just replicates the Microsoft behavior not aligned to W10 behavior : a warning as explained in Microsoft documentation... Regards
-
Excellent ! Yes, there are many happy philosophers here ! π And $Dead = False again with Heaven ! Hey, I'm discovering I just about to go into Forum Heaven ! Members --> Active Members 20 posts : Active Members - Members with more than 20 posts have additional rights No adverts Slightly more generous attachment and PM limits Access to the Chat forum Ability to upload files to the Downloads section Yes π ! See your God's men software 1.0 post now π
-
Hi I have tried to code a kind of "UDF"... π What do you think of this _FileGetTimeDST() alternative ? Regards ; ; https://www.autoitscript.com/forum/topic/205935-filegettime-uses-an-improper-tzdst-shift-at-todays-date/ ; https://docs.microsoft.com/en-us/windows/win32/sysinfo/file-times ; ; Debug à commenter pour le Build F7 d'un *.EXE ;#include "..\..\Dbug\_Dbug.au3" ; À commenter si usage de _Dbug.au3 et à décommenter pour le Build F7 d'un *.EXE... #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <Constants.au3> #include <file.au3> #include <Date.au3> #include <Array.au3> _ArrayDisplay(_FileGetTimeDST("TEST 20190115_180000.txt")) MsgBox(0, "TEST 20190115_180000.txt", "Returned string = " & _FileGetTimeDST("TEST 20190115_180000.txt", 0, 1)) _ArrayDisplay(_FileGetTimeDST("TEST 20190715_180000.txt")) MsgBox(0, "TEST 20190715_180000.txt", "Returned string = " & _FileGetTimeDST("TEST 20190715_180000.txt", 0, 1)) #cs Title: _FileGetTimeDST() = FileGetTime() alternative for DST Filename: N/A = Inline code in autoitscript.com forum Description: Get file date & time taking into account the DST shift with your Windows local TZ /!\ Windows local TZ only : no use of the real geolocation information in a file as EXIF inside a photo The date & time returned are thus compliant with W7/W10 Windows File Explorer new display rule for files properties... Author: LaurentC Version: 1.0 Date: 06/06/2021 Requirements: AutoIt 3.3.14.5, Developed/Tested on W10 20H2 French Uses: Constants.au3, file.au3, Date.au3, Array.au3 Usage : _FileGetTimeDST ( filename [, option = 0 [, format = 0]] ) Parameters filename: The path to the file or directory to check option: [optional] Flag to indicate which timestamp $FT_MODIFIED (0) = Last modified (default) $FT_CREATED (1) = Created $FT_ACCESSED (2) = Last accessed Constants are defined in FileConstants.au3 format: [optional] to specify type of return $FT_ARRAY (0) = return an array (default) $FT_STRING (1) = return a string YYYYMMDDHHMMSS Constants are defined in FileConstants.au3 #ce Func _FileGetTimeDST($filename, $option = 0, $format = 0) If Not FileExists($filename) Then Return SetError(1, 0, "Unable to find file") If $option < 0 Or $option > 2 Then Return SetError(2, 0, "Bad option value") If $format < 0 Or $format > 1 Then Return SetError(3, 0, "Bad format value") Local $hFile = _WinAPI_CreateFile($filename, 2) If $hFile = 0 Then Return SetError(3, 0, "Unable to open file") Local $tFileTime = _Date_Time_GetFileTime($hFile) _WinAPI_CloseHandle($hFile) if $option = 0 Then $tFileTime = $tFileTime[2] ; Date Modified if $option = 1 Then $tFileTime = $tFileTime[0] ; Date Created if $option = 2 Then $tFileTime = $tFileTime[1] ; Date Accessed Local $localStr $localStr = _Date_Time_FileTimeToStr($tFileTime,1) ; Returns yyyy/mm/dd hh:mm:ss ;MsgBox(0, "", "_Date_Time_GetFileTime : " & $localStr) Local $tSystemTime = _Date_Time_FileTimeToSystemTime($tFileTime) $localStr = _Date_Time_SystemTimeToDateTimeStr($tSystemTime,1) ; Returns yyyy/mm/dd hh:mm:ss ;MsgBox(0, "", "_Date_Time_FileTimeToSystemTime : " & $localStr) Local $tLocalTime = _Date_Time_SystemTimeToTzSpecificLocalTime($tSystemTime) $localStr = _Date_Time_SystemTimeToDateTimeStr($tLocalTime,1) ; Returns yyyy/mm/dd hh:mm:ss ;MsgBox(0, "", "_Date_Time_SystemTimeToTzSpecificLocalTime : " & $localStr) ; Use the standard FileSetTime format : YYYYMMDDhhmmss $localStr = StringRegExpReplace($localStr,"^(....)/(..)/(..) (..):(..):(..)$","\1\2\3\4\5\6") ;MsgBox(0, "", "_Date_Time_SystemTimeToTzSpecificLocalTime : " & $localStr) Local $tLocalFileTime = _Date_Time_SystemTimeToFileTime($tLocalTime) Local $localArray = _Date_Time_FileTimeToArray($tLocalFileTime) Local $localSwitchYear = $localArray[2] $localArray[2] = $localArray[1] $localArray[1] = $localArray[0] $localArray[0] = $localSwitchYear _ArrayDelete($localArray, 7) _ArrayDelete($localArray, 6) ;_ArrayDisplay($localArray) If $format = 0 Then Return($localArray) Else Return($localStr) EndIf EndFunc ; _FileGetTimeDST()
-
Hi Jos You're 10x times faster than me I can't compete ; -) Well I have tried your proposal, but it does not fix my DST issue in all cases, because on one of my files, it goes to 18h, and with the other to 17h... As promised, I have developed my own code that I insert inside your above example I have followed Microsoft documentation recommendations below and it works for me π My test code at this point implements only options $FT_MODIFIED (0) and $FT_STRING (1) I use for FileGetTime()... Regards #include <Date.au3> #include <Array.au3> _ArrayDisplay(_FileGetTimeDST("TEST 20190115_180000.txt", 2, 1)) _ArrayDisplay(_FileGetTimeDST("TEST 20190715_180000.txt", 2, 1)) Func _FileGetTimeDST($iFilename, $iOption = 0, $iFormat = 0) If Not FileExists($iFilename) Then Return SetError(1, 0, "File not found") If $iOption < 0 Or $iOption > 2 Then Return SetError(2, 0, "Wrong open parameter value") If $iFormat < 0 Or $iFormat > 1 Then Return SetError(3, 0, "Wrong Format parameter value") Local $hFile = _WinAPI_CreateFile($iFilename, 2) If $hFile = 0 Then _WinAPI_ShowError("ERROR: _WinAPI_CreateFile open " & $iFilename) MsgBox(0, "Error", "ERROR: _WinAPI_CreateFile open " & $iFilename) Exit EndIf Local $aTime = _Date_Time_GetFileTime($hFile) _WinAPI_CloseHandle($hFile) $aTime = $aTime[2] Local $tSystem = _Date_Time_FileTimeToSystemTime($aTime) Local $tLocal = _Date_Time_SystemTimeToTzSpecificLocalTime($tSystem) Local $LocalStr = _Date_Time_SystemTimeToDateTimeStr($tLocal,1) ; Returns yyyy/mm/dd hh:mm:ss ; Use the standard FileGetTime format : YYYYMMDDHHMMSS $LocalStr = StringRegExpReplace($LocalStr,"^(....)/(..)/(..) (..):(..):(..)$","\1\2\3\4\5\6") MsgBox(0, "", "_Date_Time_SystemTimeToTzSpecificLocalTime : " & $LocalStr) Return $LocalStr EndFunc ;==>_FileGetTimeDST