Modify

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#1276 closed Bug (Fixed)

_TicksToTime() displayed seconds increment at wrong time

Reported by: Andrew Owned by: Valik
Milestone: 3.3.1.6 Component: AutoIt
Version: 3.3.0.0 Severity: None
Keywords: _TicksToTime Cc:

Description

In the _TicksToTime function the value for Seconds is derived by this line...

$iSecs = Round(Mod($iTicks, 60))

causing the displayed seconds to increment at 500 ms. I believe the code should be...

$iSecs = Int(Mod($iTicks, 60))

so seconds only increments at 1000 ms (like a normal clock).

Attachments (0)

Change History (3)

comment:1 by Andrew, 16 years ago

On closer inspection, there is another "Round" at the beginning of the function which determines the rounding for the rest of the function.

The original function...

$iTicks = Round($iTicks / 1000)
$iHours = Int($iTicks / 3600)
$iTicks = Mod($iTicks, 3600)
$iMins = Int($iTicks / 60)
$iSecs = Round(Mod($iTicks, 60))

Should be changed to...

$iTicks = Int($iTicks / 1000); <=== change "Round" to "Int"
$iHours = Int($iTicks / 3600)
$iTicks = Mod($iTicks, 3600)
$iMins = Int($iTicks / 60)
$iSecs = Mod($iTicks, 60); <=== delete "Round", redundant

The function should then behave like a normal clock. Seconds should change only on 1000 ms (not at 500 ms). ie. 999 ms will display 0 sec (as is does on every other clock).

comment:2 by Valik, 16 years ago

Milestone: 3.3.1.6
Owner: set to Valik
Resolution: Fixed
Status: newclosed

Fixed by revision [5376] in version: 3.3.1.6

comment:3 by Valik, 16 years ago

Demonstration script:

#include <Date.au3>

Local Const $nHour = @HOUR, $nMinute = @MIN, $nSeconds = @SEC
Local Const $nTicksStart = _TimeToTicks($nHour, $nMinute, $nSeconds)
Local Const $nTicksEnd = _TimeToTicks($nHour, $nMinute, $nSeconds + 1)

For $nTicks = $nTicksStart To $nTicksEnd - 1
	Local $nHourNew, $nMinuteNew, $nSecondsNew
	_TicksToTime($nTicks, $nHourNew, $nMinuteNew, $nSecondsNew)
	If $nSeconds <> $nSecondsNew Then
		ConsoleWrite("Variation starts at: " & $nTicks - $nTicksStart & @CRLF)
		Exit
	EndIf
Next

ConsoleWrite("No variation." & @CRLF)

Modify Ticket

Action
as closed The owner will remain Valik.

Add Comment


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