Dans ce sujet, jchd nous explique que l'utilisation des macros @MIN et @SEC pour horodater un fichier peut créer un horodatage incohérent ou complètement décalé dans le temps (voir ce message) ...
Puis il explique :
Afin d'éviter ce genre de désagrément, voici une fonction qui permet de contourner le problème.jchd a écrit :Donc si on est à la seconde 59 et 999ms, on peut capter @SEC = 59 puis au moment où l'interpréteur parvient à @MIN, récupérer la minute suivante.
Code : Tout sélectionner
; #FUNCTION# ====================================================================================================================
; Name...........: _GetTimestamp_Date_Time
; Description ...: Returns the current Date and time without a possible gap.
; Syntax.........: _GetTimestamp_Date_Time($sType)
; Parameters ....: $sType - one the following:
; |1 - Return the date and time in string format YYYY.MM.DD HH:MM:SS
; |2 - Return the date and time - Array with the following format:
; |[0] - Month
; |[1] - Day
; |[2] - Year
; |[3] - Hour
; |[4] - Minute
; |[5] - Second
; Return values .: Success - Returns the current date and time in string format or array format.
; Author ........: Tlem
; Modified.......:
; Remarks .......: Other functions can give a gap time due to this possibility:
; @SEC=59 and @MSEC=999 when capturing @MIN and then capturing @SEC (that can be 0 !!!).
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _GetTimestamp_Date_Time($sType = 1)
If $sType < 1 Or $sType > 2 Then $sType = 1
Local $iYear = @YEAR
Local $iMon = @MON
Local $iMday = @MDAY
Local $iHour = @HOUR
Local $iMin = @MIN
Local $iSec = @SEC
If ($iMin <> @MIN) Then
$iYear = @YEAR
$iMon = @MON
$iMday = @MDAY
$iHour = @HOUR
$iMin = @MIN
$iSec = @SEC
EndIf
If $sType = 1 Then
Return $iYear & "/" & $iMon & "/" & $iMday & " " & $iHour & ":" & $iMin & ":" & $iSec
Else
Local $aDateTime[6] = [$iMon, $iMday, $iYear, $iHour, $iMin, $iSec]
Return $aDateTime
EndIf
EndFunc ;==>_GetTimestamp_Date_Time