Modify

Opened 16 years ago

Closed 16 years ago

#465 closed Bug (Fixed)

_DateTimeSplit() results cause erroneous calc results when "Seconds" is missing

Reported by: cbruce Owned by: Gary
Milestone: 3.2.13.6 Component: Standard UDFs
Version: 3.2.12.1 Severity: None
Keywords: Date DateTimeSplit Cc:

Description

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

Attachments (0)

Change History (3)

comment:1 Changed 16 years ago by Gary

  • Resolution set to No Bug
  • Status changed from new to closed

The help file doesn't state the seconds are optional

"Input date in the format YYYY/MM/DD[ HH:MM:SS]"

Either put in all the time or no time.

Now if Jos wishes to make the seconds optional then it would need to be changed.

As it stands now it is not a bug.

comment:2 Changed 16 years ago by Gary

  • Resolution No Bug deleted
  • Status changed from closed to reopened

Shoot looked at the add function not the split function, so yes it is a bug and it'll be fixed.

comment:3 Changed 16 years ago by Gary

  • Milestone set to 3.2.13.6
  • Resolution set to Fixed
  • Status changed from reopened to closed

Fixed in version: 3.2.13.6

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.

Add Comment

Modify Ticket

Action
as closed The owner will remain Gary.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.