Qp0zGetTimeofDay()--Get Current Software Clock Time


  Syntax
 #include <sys/time.h>

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

  Service Program Name: QP0ZCPA

  Default Public Authority: *USE

  Threadsafe: Yes

The Qp0zGetTimeofDay() function retrieves the current software clock time and places it in the timeval structure pointed to by tp. If tzp is not NULL, the time zone information is returned in the timezone structure pointed to by tzp.

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 gettimeofday() function should be used instead.


Parameters

tp
(Output) 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
(Output) 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

None


Return Value

0 Qp0zGetTimeofDay() was successful.

-1 Qp0zGetTimeofDay() was not successful. The errno variable is set to indicate the error.


Error Conditions

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

[EINVAL] An invalid parameter was found.

A parameter passed to this function is not valid.

[EFAULT] The address used for an argument is not correct.

In attempting to use an argument in a call, the system detected an address that is not valid.

While attempting to access a parameter passed to this function, the system detected an address that is not valid.



Error Messages

None.


Usage Notes


Related Information


Example

See Code disclaimer information for information pertaining to code examples.

The following example gets the current software clock time:

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

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

    rc=Qp0zGetTimeofDay(&now, NULL);
    if(rc==0) {
        printf("Qp0zGetTimeofDay() successful.\n");
        printf("time = %u.%06u\n",
                now.tv_sec, now.tv_usec);
    }
    else {
        printf("Qp0zGetTimeofDay() failed, errno = %d\n",
                errno);
        return -1;
    }

    return 0;
}

Example Output:

Qp0zGetTimeofDay() successful.
time = 866208142.290944


API introduced: V5R3
Top | UNIX-Type APIs | APIs by category