adjtime()--Adjust System Clock


  Syntax
 #include <sys/time.h>

 int adjtime (struct timeval *delta,
              struct timeval *olddelta);

  Service Program Name: QWCTZUTC

  Default Public Authority: *USE

  Threadsafe: Yes

The adjtime() function makes small adjustments to the system clock, either slowing it down or speeding it up by the time specified in the delta parameter up to a maximum of two hours. If delta is negative, the clock is slowed down by incrementing it more slowly than normal until the correction is complete. If delta is positive, the clock is sped up by incrementing it more quickly than normal until the correction is complete. If olddelta is not NULL, the amount of time still to be corrected from a previous adjtime() call is returned in the structure it points to.


Parameters

delta
(Input)

A pointer to a timeval structure that contains the amount of time for adjusting the clock.

olddelta
(Output)

A pointer to a timeval structure that contains the amount of time still to be corrected from a previous call to adjtime().


Authorities and Locks

Special Authority
*ALLOBJ


Return Value



Error Conditions

If adjtime() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.


Error Messages

None.


Related Information


Example

The following example initiates a system clock adjustment.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include <sys/time.h>
#include <stdio.h>
#include <errno.h>

int main(int argc, char *argv[])
{
    struct timeval adj, old;
    int rc;

    /* Speed up the clock by 1.5 seconds. */
    adj.tv_sec=1;
    adj.tv_usec=500000;

    rc=adjtime(&adj, &old);
    if(rc==0) {
        printf("adjtime() successful. "
               "Olddelta = %u.%06u\n",
                old.tv_sec, old.tv_usec);
    }
    else {
        printf("adjtime() failed, errno = %d\n",errno);
        return -1;
    }

    return 0;
}
Example Output:
adjtime() successful. Olddelta = 0.000000


API introduced: V4R2

[ Back to top | UNIX-Type APIs | APIs by category ]