Re: Clock Display using After



I have compared times between the Windows time.exe program and cygwin's
/usr/bin/date.
Both agree.

As was pointed out, the time is evaluated with each after event.
Any latency would delay the refresh, but not yield a cumulative error.

Besides, any latency would result in the displayed time lagging the
system time - which is not the case.


Chad


Bruce Hartweg wrote:
ccdrbrg@xxxxxxxxx wrote:
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.


first, feel free to remove every ";" below - they are not needed.

the code should work fine, you are asking for the time each iteration
so it shouldn't drift. You mention you are running under cygwin on a windows
system, could it be that the cygwin system timer is the one that's drifting?
try typing date in a cygwin shell and see if it agrees with your script time
or the Windows clock time.

Bruce


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];
};


.


Quantcast