Debian Codegraph @

doc/GetTime.3

raw
1 '\"
2 '\" Copyright (c) 2001 Kevin B. Kenny <[email protected]>.
3 '\"
4 '\" See the file "license.terms" for information on usage and redistribution
5 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\"
7 .TH Tcl_GetTime 3 8.4 Tcl "Tcl Library Procedures"
8 .so man.macros
9 .BS
10 .SH NAME
11 Tcl_GetTime, Tcl_SetTimeProc, Tcl_QueryTimeProc \- get date and time
12 .SH SYNOPSIS
13 .nf
14 \fB#include <tcl.h>\fR
15 .sp
16 \fBTcl_GetTime\fR(\fItimePtr\fR)
17 .sp
18 \fBTcl_SetTimeProc\fR(\fIgetProc, scaleProc, clientData\fR)
19 .sp
20 \fBTcl_QueryTimeProc\fR(\fIgetProcPtr, scaleProcPtr, clientDataPtr\fR)
21 .SH ARGUMENTS
22 .AS Tcl_GetTimeProc *getProc in
23 .AP Tcl_Time *timePtr out
24 Points to memory in which to store the date and time information.
25 .AP Tcl_GetTimeProc getProc in
26 Pointer to handler function replacing \fBTcl_GetTime\fR's access to the OS.
27 .AP Tcl_ScaleTimeProc scaleProc in
28 Pointer to handler function for the conversion of time delays in the
29 virtual domain to real-time.
30 .AP ClientData clientData in
31 Value passed through to the two handler functions.
32 .AP Tcl_GetTimeProc *getProcPtr out
33 Pointer to place the currently registered get handler function into.
34 .AP Tcl_ScaleTimeProc *scaleProcPtr out
35 Pointer to place the currently registered scale handler function into.
36 .AP ClientData *clientDataPtr out
37 Pointer to place the currently registered pass-through value into.
38 .BE
39 .SH DESCRIPTION
40 .PP
41 The \fBTcl_GetTime\fR function retrieves the current time as a
42 \fITcl_Time\fR structure in memory the caller provides. This
43 structure has the following definition:
44 .PP
45 .CS
46 typedef struct Tcl_Time {
47 long \fIsec\fR;
48 long \fIusec\fR;
49 } \fBTcl_Time\fR;
50 .CE
51 .PP
52 On return, the \fIsec\fR member of the structure is filled in with the
53 number of seconds that have elapsed since the \fIepoch:\fR the epoch
54 is the point in time of 00:00 UTC, 1 January 1970. This number does
55 \fInot\fR count leap seconds \- an interval of one day advances it by
56 86400 seconds regardless of whether a leap second has been inserted.
57 .PP
58 The \fIusec\fR member of the structure is filled in with the number of
59 microseconds that have elapsed since the start of the second
60 designated by \fIsec\fR. The Tcl library makes every effort to keep
61 this number as precise as possible, subject to the limitations of the
62 computer system. On multiprocessor variants of Windows, this number
63 may be limited to the 10- or 20-ms granularity of the system clock.
64 (On single-processor Windows systems, the \fIusec\fR field is derived
65 from a performance counter and is highly precise.)
66 .SS "VIRTUALIZED TIME"
67 .PP
68 The \fBTcl_SetTimeProc\fR function registers two related handler functions
69 with the core. The first handler function is a replacement for
70 \fBTcl_GetTime\fR, or rather the OS access made by
71 \fBTcl_GetTime\fR. The other handler function is used by the Tcl
72 notifier to convert wait/block times from the virtual domain into real
73 time.
74 .PP
75 The \fBTcl_QueryTimeProc\fR function returns the currently registered
76 handler functions. If no external handlers were set then this will
77 return the standard handlers accessing and processing the native time
78 of the OS. The arguments to the function are allowed to be NULL; and
79 any argument which is NULL is ignored and not set.
80 .PP
81 The signatures of the handler functions are as follows:
82 .PP
83 .CS
84 typedef void \fBTcl_GetTimeProc\fR(
85 Tcl_Time *\fItimebuf\fR,
86 ClientData \fIclientData\fR);
87 typedef void \fBTcl_ScaleTimeProc\fR(
88 Tcl_Time *\fItimebuf\fR,
89 ClientData \fIclientData\fR);
90 .CE
91 .PP
92 The \fItimebuf\fR fields contain the time to manipulate, and the
93 \fIclientData\fR fields contain a pointer supplied at the time the handler
94 functions were registered.
95 .PP
96 Any handler pair specified has to return data which is consistent between
97 them. In other words, setting one handler of the pair to something assuming a
98 10-times slowdown, and the other handler of the pair to something assuming a
99 two-times slowdown is wrong and not allowed.
100 .PP
101 The set handler functions are allowed to run the delivered time backwards,
102 however this should be avoided. We have to allow it as the native time can run
103 backwards as the user can fiddle with the system time one way or other. Note
104 that the insertion of the hooks will not change the behavior of the Tcl core
105 with regard to this situation, i.e. the existing behavior is retained.
106 .SH "SEE ALSO"
107 clock(n)
108 .SH KEYWORDS
109 date, time