;==============================================================
; Name...........: _TimeDOS_ToString
; Description ...: Decodes the DOS date and time into a string.
; Syntax.........: _TimeDOS_ToString($i_TimeStamp, $s_Format, $sTimeZone, $i_MaxLen)
; Parameters ....: $i_TimeStamp - The number containing the DOS time.
; $s_Format - A format string to convert the timestamp to (default - '%d/%m/%Y %H:%M:%S').
; $sTimeZone - A string specifying the time zone: 'localtime' or 'gmtime' (default - 'localtime').
; $i_MaxLen - Maximum length of the string to be returned (default - 255).
; Return values .: Success - Formatted string with the decoded Date and Time.
; Failure - Empty string and sets the @error flag to non-zero.
; Author ........: Rob Saunders
; Modified.......: Garry_Galler
;==============================================================
Func _TimeDOS_ToString($i_TimeStamp, $s_Format, $sTimeZone='localtime', $i_MaxLen = 255)
Local $struct_Time, $ptr_Time, $av_Time, $av_StrfTime
If Not IsNumber($i_TimeStamp) Then
Return SetError(1,-1,'')
EndIf
If $s_Format = -1 Or $s_Format = '' Then
$s_Format='%d/%m/%Y %H:%M:%S'
EndIf
$ptr_Time = DllCall('CrtDll.dll', 'ptr:cdecl', $sTimeZone, 'long*', $i_TimeStamp)
If @error Then
Return SetError(@error,-2,'')
EndIf
$av_StrfTime = DllCall('CrtDll.dll', 'int:cdecl', 'strftime', _
'str', '', _
'int', $i_MaxLen, _
'str', $s_Format, _
'ptr', $ptr_Time[0])
If (@error) Or Not (IsArray($av_StrfTime)) Then
Return SetError(@error,-3, '')
EndIf
Return $av_StrfTime[1]
EndFunc