Tcl Source Code

View Ticket
Login
Ticket UUID: 1567838
Title: Clock Creep using [after] on Windows
Type: Bug Created on: 2006-09-29 15:44:18
Submitter: ccdrbrg Assigned to: kennykb
Subsystem: 03. Timer Events Severity:
Priority: 5 Medium Last modified: 2026-10-22 17:19:32
Status: Closed Closed by: serhiy.storchaka
Resolution: Fixed Closed on: 2026-10-21 11:01:37
Version: None
Description:
System:
Windows XP SP2 running tcl/tk 8.4.1 from cygwin.

Posted on comp.lang.tcl by ccdrbrg (Thurs, Sep 28 2006
9:07 am)

I have written a simple ISO 8601 format clock display
(source below).

I have noticed the time value will creep ahead of the
system time by as
much as 30 seconds each day running.  I do not
understand why.  I
believe [clock seconds] queries the system time and is
evaluated each
time the after event is triggered.  The fact that the
displayed time
gets ahead of the system time is strange.

Any help would be much appreciated.

Chad

System:
Windows XP running tcl/tk 8.4.1 from cygwin.

Source:

variable date;

proc iso8601date {  } {
  global date;

  set seconds [clock seconds];
  set date [clock format ${seconds} -gmt 1 -format
{%Y-%m-%dT%TZ}];

  after 500 iso8601date;

};

iso8601date;

package require Tk;

wm protocol . WM_DELETE_WINDOW { exit };
wm title . "ISO8601 Date";

label .l -textvariable date -font {Arial 12 bold};
pack .l  -padx 20;

wm resizable . 0 0;

bind .l <Double-Button-1> {
  clipboard clear;
  clipboard append [.l cget -text]; 
};



Reply from Kevin Kenny (Thurs, Sep 28 2006 9:18 pm)

There's something gone wrong with the high-resolution
timer and the
way we synchronize that to the system clock.

Please log a bug on this at SourceForge.  It may be a
few weeks before
I can give it a proper look, because I have travel
coming up.
User Comments:
serhiy.storchaka added on 2026-10-21 11:01:37:

This was a calibration problem of the Windows high-resolution clock. It has been reworked since: [b6fc234ef3] (ticket [b87ad7e914], in 8.6.7) fixed time drifts and jumps caused by Tcl_GetTime() calls disturbing the calibration data, and [f6637d3dd8] (in 8.6.10) reworked the calibration cycle for smoother drifting toward the system time. Both are in all maintained versions. Not reproduced by me; please reopen if it still happens with 8.6.10 or later.