Modify

Opened 11 years ago

Closed 11 years ago

#2967 closed Bug (Fixed)

Error in function __EventLog_DecodeTime

Reported by: landfillmail@… Owned by: guinness
Milestone: 3.3.13.20 Component: AutoIt
Version: 3.3.12.0 Severity: None
Keywords: EventLog DecodeTime PM AM Cc:

Description

The function EventLog_DecodeTime in EventLog.au3 report a wrong date when at noon. Instead of reporting 12:00 AM the function return 00:00 AM. Maybe it's desired like that but I have search why the hour was wrong a long time :)

Code:

Func __EventLog_DecodeTime($iEventTime)
	Local $tInt64 = DllStructCreate("int64")
	Local $pInt64 = DllStructGetPtr($tInt64)
	Local $tFileTime = DllStructCreate($tagFILETIME, $pInt64)
	DllStructSetData($tInt64, 1, ($iEventTime * 10000000) + 116444736000000000)
	Local $tLocalTime = _Date_Time_FileTimeToLocalFileTime($tFileTime)
	Local $tSystTime = _Date_Time_FileTimeToSystemTime($tLocalTime)
	Local $iHours = DllStructGetData($tSystTime, "Hour")
	Local $iMinutes = DllStructGetData($tSystTime, "Minute")
	Local $iSeconds = DllStructGetData($tSystTime, "Second")
	Local $sAMPM = "AM"
	If $iHours > 11 Then
		$sAMPM = "PM"
		$iHours = $iHours - 12
	EndIf
	Return StringFormat("%02d:%02d:%02d %s", $iHours, $iMinutes, $iSeconds, $sAMPM)
EndFunc   ;==>__EventLog_DecodeTime

I suggess to remplace with:

Func __EventLog_DecodeTime($iEventTime)
	Local $tInt64 = DllStructCreate("int64")
	Local $pInt64 = DllStructGetPtr($tInt64)
	Local $tFileTime = DllStructCreate($tagFILETIME, $pInt64)
	DllStructSetData($tInt64, 1, ($iEventTime * 10000000) + 116444736000000000)
	Local $tLocalTime = _Date_Time_FileTimeToLocalFileTime($tFileTime)
	Local $tSystTime = _Date_Time_FileTimeToSystemTime($tLocalTime)
	Local $iHours = DllStructGetData($tSystTime, "Hour")
	Local $iMinutes = DllStructGetData($tSystTime, "Minute")
	Local $iSeconds = DllStructGetData($tSystTime, "Second")
	Return StringFormat("%02d:%02d:%02d", $iHours, $iMinutes, $iSeconds)
EndFunc   ;==>__EventLog_DecodeTime

Attachments (0)

Change History (2)

comment:1 by guinness, 11 years ago

Well noon should be 12:00 PM, not 12:00 AM.

I think this is a better suggestion.

#include <Date.au3>

Local $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, "00", @MIN, @SEC)
Local $tSystTime = _Date_Time_FileTimeToSystemTime(DllStructGetPtr($tFile))
Local $iHours = DllStructGetData($tSystTime, "Hour")
Local $iMinutes = DllStructGetData($tSystTime, "Minute")
Local $iSeconds = DllStructGetData($tSystTime, "Second")
Local $sAMPM = "AM"
If $iHours >= 12 Then
	$sAMPM = "PM"
	If $iHours > 12 Then $iHours -= 12
Else
	If $iHours = 0 Then $iHours = 12
EndIf

ConsoleWrite(StringFormat("%02d:%02d:%02d %s", $iHours, $iMinutes, $iSeconds, $sAMPM) & @CRLF)


comment:2 by guinness, 11 years ago

Milestone: 3.3.13.20
Owner: set to guinness
Resolution: Fixed
Status: newclosed

Fixed by revision [11182] in version: 3.3.13.20

Modify Ticket

Action
as closed The owner will remain guinness.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.