Top |
You can get the current time, either as a Unix timestamp (seconds since 1970) or as a broken-out structure of time elements (year, month, day, hour, minute, second).
The system clock is not guaranteed to line up with timer events (see Timer Events). Timer events may be delivered late according to the system clock.
void
glk_current_time (glktimeval_t *time
);
The current Unix time is stored in the structure time
. (The argument may not
be NULL
.) This is the number of seconds since the beginning of 1970 (UTC).
The first two values in the structure should be considered a single
signed 64-bit number. This allows the glktimeval_t to
store a reasonable range of values in the future and past. The high_sec
value will remain zero until sometime in 2106. If your computer is running in
1969, perhaps due to an unexpected solar flare, then high_sec
will be
negative.
The third value in the structure represents a fraction of a second, in
microseconds (from 0 to 999999). The resolution of the glk_current_time()
call is platform-dependent; the microsec
value may not be updated
continuously.
glsi32
glk_current_simple_time (glui32 factor
);
If dealing with 64-bit values is awkward, you can also get the current time
as a lower-resolution 32-bit value. This is simply the Unix time divided by
the factor
argument (which must not be zero). For example, if factor is 60,
the result will be the number of minutes since 1970 (rounded towards negative
infinity). If factor is 1, you will get the Unix time directly, but the value
will be truncated starting some time in 2038.