Qp0zSetTimeofDay()--Set Software Clock


  Syntax
 #include <sys/time.h>

 int Qp0zSetTimeofDay (struct timeval *tp,
                       struct timezone *tzp);

  Service Program Name: QP0ZSETC

  Default Public Authority: *USE

  Threadsafe: Yes

The Qp0zSetTimeofDay() function sets the software clock to the time contained in the timeval structure pointed to by tp. If tzp is not NULL, the time zone information is also set.

The software clock maintains a time that can be set independently of the system clock. It is not integrated with the system and will be removed in a future release. The settimeofday() function should be used instead.


Parameters

tp
(Input) A pointer to a timeval structure that contains the time in seconds and microseconds since 1 January 1970, 00:00:00 UTC (epoch-1970).

tzp
(Input) A pointer to a timezone structure that contains the local time zone (measured in minutes west of Greenwich) and a flag that, if nonzero, indicates daylight saving time applies locally during the appropriate part of the year.

Authorities and Locks

QSYS/QP0ZXCPA Service Program Authority
*USE

Return Value


Error Conditions

If Qp0zSetTimeofDay() 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.


Usage Notes

If the value of the environment variable QIBM_USE_SFWCLK is "N", Qp0zSetTimeofDay() calls settimeofday() to adjust the system clock.


Related Information


Example

The following example sets the software clock.

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 now;
    int rc;

    time.tv_sec=866208142;
    time.tv_usec=290944;

    rc=Qp0zSetTimeofDay(&now, NULL);
    if(rc==0) {
        printf("Qp0zSetTimeofDay() successful.\n");
    }
    else {
        printf("Qp0zSetTimeofDay() failed, "
        "errno = %d\n",errno);
        return -1;
    }

    return 0;
}

Example Output

Qp0zSetTimeofDay() successful.


API introduced: V5R3

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