﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
465	"_DateTimeSplit() results cause erroneous calc results when ""Seconds"" is missing"	cbruce	Gary	"I believe that the _DateTimeSplit() function is behaving incorrectly.

AutoIT allows us to use DateTime values that do NOT include ""Seconds"" in our calculations.  But if you use such DateTime values in _DateAdd(), you get erroneous results.

Example:

{{{
$x = _DateAdd( 'h', 1, ""2008/01/01 01:00"")
}}}

Results in a value of ""2008/01/01 01:59"" instead of ""2008/01/01 02:00"".

The problem lies in the _DateTimeSplit() function, which is inserting ""-1"" into Time fields when there is missing input.

I believe the correct behavior should be to insert ""0"" into the Time fields in this condition.

{{{
Func _DateTimeSplit($sDate, ByRef $asDatePart, ByRef $iTimePart)
	Local $sDateTime
	Local $x
	; split the Date and Time portion
	$sDateTime = StringSplit($sDate, "" T"")
	; split the date portion
	If $sDateTime[0] > 0 Then $asDatePart = StringSplit($sDateTime[1], ""/-."")
	; split the Time portion
	If $sDateTime[0] > 1 Then
		$iTimePart = StringSplit($sDateTime[2], "":"")
		If UBound($iTimePart) < 4 Then ReDim $iTimePart[4]
	Else
		Dim $iTimePart[4]
	EndIf
	; Ensure the arrays contain 4 values
	If UBound($asDatePart) < 4 Then ReDim $asDatePart[4]
	; update the array to contain numbers not strings
	For $x = 1 To 3
		If StringIsInt($asDatePart[$x]) Then
			$asDatePart[$x] = Number($asDatePart[$x])
		Else
			$asDatePart[$x] = -1
		EndIf
		If StringIsInt($iTimePart[$x]) Then
			$iTimePart[$x] = Number($iTimePart[$x])
		Else
;	=============  PROBLEM  =================
			$iTimePart[$x] = -1
;	=============  PROBLEM  =================
;	=============  CHANGE  =================
			$iTimePart[$x] = 0
;	=============  CHANGE  =================
		EndIf
	Next
	Return (1)
EndFunc   ;==>_DateTimeSplit
}}}
"	Bug	closed	3.2.13.6	Standard UDFs	3.2.12.1	None	Fixed	Date DateTimeSplit	
