Tcl 9.1/Tk9.1 Documentation > Tcl C API, version 9.1a1 > GetTime

Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

NAME
Tcl_GetMonotonicTime, Tcl_GetTime, Tcl_SetTimeProc, Tcl_QueryTimeProc — get date and time
SYNOPSIS
#include <tcl.h>
long long
Tcl_GetMonotonicTime()
Tcl_GetTime(timePtr)
Tcl_SetTimeProc(getProc, scaleProc, clientData)
Tcl_QueryTimeProc(getProcPtr, scaleProcPtr, clientDataPtr)
ARGUMENTS
DESCRIPTION
VIRTUALIZED TIME
SEE ALSO
KEYWORDS

NAME

Tcl_GetMonotonicTime, Tcl_GetTime, Tcl_SetTimeProc, Tcl_QueryTimeProc — get date and time

SYNOPSIS

#include <tcl.h>
long long
Tcl_GetMonotonicTime()
Tcl_GetTime(timePtr)
Tcl_SetTimeProc(getProc, scaleProc, clientData)
Tcl_QueryTimeProc(getProcPtr, scaleProcPtr, clientDataPtr)

ARGUMENTS

Tcl_Time *timePtr (out)
Points to memory in which to store the date and time information.

Tcl_GetTimeProc getProc (in)
Pointer to handler function replacing Tcl_GetTime's access to the OS.

Tcl_ScaleTimeProc scaleProc (in)
Pointer to handler function for the conversion of time delays in the virtual domain to real-time.

void *clientData (in)
Value passed through to the two handler functions.

Tcl_GetTimeProc *getProcPtr (out)
Pointer to place the currently registered get handler function into.

Tcl_ScaleTimeProc *scaleProcPtr (out)
Pointer to place the currently registered scale handler function into.

void **clientDataPtr (out)
Pointer to place the currently registered pass-through value into.

DESCRIPTION

The Tcl_GetMonotonicTime function returns the current monotonic time. The unit is micro-seconds. Only time differences are defined. The timer value 0 may be the epoc but may also be the start-up of the system.

The value is contiguous but may jump due to timer virtualization or sleep mode.

The precision is system dependent and not guaranteed to be micro-second precise.

The Tcl_GetTime function retrieves the current time as a Tcl_Time structure in memory the caller provides. This structure has the following definition:

typedef struct {
    long long sec;
    long usec;
} Tcl_Time;

On return, the sec member of the structure is filled in with the number of seconds that have elapsed since the epoch: the epoch is the point in time of 00:00 UTC, 1 January 1970. This number does not count leap seconds; an interval of one day advances it by 86400 seconds regardless of whether a leap second has been inserted.

The usec member of the structure is filled in with the number of microseconds that have elapsed since the start of the second designated by sec.

This command uses the system wall clock and is not contiguous by definition. It may have large jumps in short time, specially if the system is awaked from sleep mode.

VIRTUALIZED TIME

The Tcl_SetTimeProc and Tcl_QueryTimeProc are not supported since TCL 9.1. They call a Tcl_Panic.

SEE ALSO

clock, timer

KEYWORDS

date, time
Copyright © 2001 Kevin B. Kenny <kennykb(at)acm.org>.