#include <qp0z1170.h> int Qp0zCvtToTimeval (struct timeval *to, const _MI_Time from, int option);
The Qp0zCvtToTimeval() function converts a machine timestamp (or a machine timestamp offset), represented by an _MI_Time data type, to a corresponding structure timeval value. The job's time zone offset from UTC and epoch-1970 are optionally taken into account by this conversion. Only timestamps or timestamp offsets in the following ranges can be converted:
Note: This function uses a header (include) file from the library QSYSINC, which is optionally installable. Make sure QSYSINC is installed on your system before using this function. See Header Files for UNIX-Type Functions) for the file and member name of each header file.
The option parameter must be one of the following constants:
None.
0 | Qp0zCvtToTimeval() was successful. The value referenced by the to parameter is the converted timestamp (or timestamp offset). |
-1 | Qp0zCvtToTimeval() was not successful. The errno variable is set to indicate the error. |
If Qp0zCvtToTimeval() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.
An argument value is not valid, out of range, or NULL.
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.
The value of an argument is too small, or a result too large.
The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated, then retry the operation.
None.
See Code disclaimer information for information pertaining to code examples.
The following example converts a timestamp:
#include <qp0z1170.h> #include <mimchint.h> #include <stdio.h> #include <errno.h> int main(int argc, char *argv[]) { _MI_Time mt; struct timeval tv; int rc; mattod(mt); printf("mi timestamp: %08X%08X\n", *((unsigned *)&mt[0]), *((unsigned *)&mt[4])); rc = Qp0zCvtToTimeval(&tv, mt, QP0Z_CVTTIME_TO_TIMESTAMP); if(rc==0) { printf("timeval timestamp: %u.%06u\n", tv.tv_sec, tv.tv_usec); } else { printf("Qp0zCvtToTimeval() failed, errno = %d\n", errno); return -1; } return 0; }Example Output:
mi timestamp: 7B7E9425EAC00000 timeval timestamp: 867422292.052992
Top | Miscellaneous APIs | APIs by category |