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 Changed 11 years ago by guinness
comment:2 Changed 11 years ago by guinness
- Milestone set to 3.3.13.20
- Owner set to guinness
- Resolution set to Fixed
- Status changed from new to closed
Fixed by revision [11182] in version: 3.3.13.20
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Note: See
TracTickets for help on using
tickets.

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)