Software Clock APIs

The Software Clock is a system facility that determines the current Universal Coordinated Time (UTC) in seconds and microseconds since 1 January 1970, 00:00:00 (epoch-1970), and allows for time zone and daylight savings time information to be stored and retrieved. The current time is determined by keeping an internal 'time-delta', which is an offset from the machine clock (accessible via the mattod() API). When gettimeofday() is called to retrieve the software clock time, the time returned is calculated by taking the current machine time, subtracting the QUTCOFFSET system value, then adding the internal time-delta.

Calling the settimeofday() API sets or changes the time-delta (and optionally the time zone and the daylight savings time information), but does not affect the machine clock or the QUTCOFFSET system value. The adjtime() API slowly changes the time-delta, but does not affect the machine clock either. Adjustments are made at a rate of approximately 1 second of adjustment for every 100 seconds of elapsed time.

Most system components do not base their timestamps on the software clock, but use the machine clock instead.

Software Clock APIs--Summary

Figure 1-1 lists the software clock functions and what they do.

Figure 1-1. Software Clock Functions
Function Description
adjtime() Adjust software clock
gettimeofday() Get current software clock time
settimeofday() Set current software clock time

Note: These functions use header (include) files from the library QSYSINC, which is optionally installable. Make sure QSYSINC is installed on your system before using any of the functions. See for the file and member name of each header file.


Top | UNIX-Type APIs | APIs by category


[Information Center Home Page | Feedback ] [Legal | AS/400 Glossary]