Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#1276 closed Bug (Fixed)

_TicksToTime() displayed seconds increment at wrong time

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


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 Changed 14 years ago by Andrew

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 Changed 14 years ago by Valik

  • Milestone set to
  • Owner set to Valik
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [5376] in version:

comment:3 Changed 14 years ago by Valik

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)

ConsoleWrite("No variation." & @CRLF)

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

as closed The owner will remain Valik.

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

Note: See TracTickets for help on using tickets.