314 lines
7.9 KiB
HTML
314 lines
7.9 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
||
|
<title>Qp0zCvtToMITime()-Convert Timeval Structure to _MI_Time</title>
|
||
|
<!-- Begin Header Records ========================================== -->
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<!-- Change History: -->
|
||
|
<!-- YYMMDD USERID Change description -->
|
||
|
<!-- CVTTOMIT SCRIPT A converted by B2H R4.1 (346) (CMS) by KENTALA -->
|
||
|
<!-- at RCHVMW2 on 7 Oct 1998 at 12:07:10 -->
|
||
|
<!-- This file has undergone html cleanup on 1/28/02 by JET -->
|
||
|
<!-- End Header Records -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<!-- Java sync-link -->
|
||
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
||
|
</script>
|
||
|
|
||
|
<a name="Top_Of_Page"></a>
|
||
|
|
||
|
<h2>Qp0zCvtToMITime()-Convert Timeval Structure to _MI_Time</h2>
|
||
|
|
||
|
<div class="box" style="width: 60%;">
|
||
|
<br>
|
||
|
Syntax:<br>
|
||
|
|
||
|
<pre>
|
||
|
#include <qp0z1170.h>
|
||
|
|
||
|
int Qp0zCvtToMITime (_MI_Time <strong>to</strong>,
|
||
|
const struct timeval *<strong>from</strong>,
|
||
|
int <strong>option</strong>);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
<br>
|
||
|
Service Program Name: QP0ZCPA<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: Yes<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
<br>
|
||
|
<p>The <strong>Qp0zCvtToMITime()</strong> function converts a UNIX-type
|
||
|
timestamp (or a timestamp offset), represented by a timeval structure, to a
|
||
|
corresponding _MI_Time data type. 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:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li>Timestamps that are later than or equal to 1 January 1970, 00:00:00 UTC
|
||
|
(epoch-1970) and less than 19 January 2038, 03:14:08 UTC.</li>
|
||
|
|
||
|
<li>Timestamp offsets that are greater than or equal to 0 and less than 2,147,483,648
|
||
|
seconds.</li>
|
||
|
</ul>
|
||
|
|
||
|
<p><strong>Note:</strong> 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 <a href="unix13.htm">
|
||
|
Header Files for UNIX-Type Functions</a>) for the file and member name of each
|
||
|
header file.<br>
|
||
|
</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>to</strong></dt>
|
||
|
|
||
|
<dd>(Output) The _MI_Time data type to contain the converted timestamp (or
|
||
|
timestamp offset).<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>from</strong></dt>
|
||
|
|
||
|
<dd>(Input) The address of the timeval structure to be converted.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>option</strong></dt>
|
||
|
|
||
|
<dd>(Input) The conversion option.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<p>The <strong>option</strong> parameter must be one of the following
|
||
|
constants:</p>
|
||
|
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>QP0Z_CVTTIME_TO_OFFSET</strong></dt>
|
||
|
|
||
|
<dd>Do the conversion as a timestamp offset, not factoring in the UTC offset
|
||
|
from the current time zone of the job or epoch-1970.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>QP0Z_CVTTIME_TO_TIMESTAMP</strong></dt>
|
||
|
|
||
|
<dd>Do the conversion as a timestamp, factoring in the UTC offset from
|
||
|
the current time zone of the job and epoch-1970.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>QP0Z_CVTTIME_FACTOR_EPOCH_ONLY</strong></dt>
|
||
|
|
||
|
<dd>Do the conversion as a timestamp, but factor in epoch-1970 only.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>QP0Z_CVTTIME_FACTOR_UTCOFFSET_ONLY</strong></dt>
|
||
|
|
||
|
<dd>Do the conversion as a timestamp, but factor in the UTC offset from the
|
||
|
current time zone of the job only.</dd>
|
||
|
</dl>
|
||
|
|
||
|
|
||
|
<br>
|
||
|
<h3>Authorities and Locks</h3>
|
||
|
|
||
|
<p>None.</p>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Return Value</h3>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="15 85" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>0</em></td>
|
||
|
<td align="left" valign="top"><strong>Qp0zCvtToMITime()</strong> was
|
||
|
successful. The value referenced by the <strong>to</strong> parameter is the
|
||
|
converted timestamp (or timestamp offset).</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-1</em></td>
|
||
|
<td align="left" valign="top"><strong>Qp0zCvtToMITime()</strong> was not
|
||
|
successful. The <em>errno</em> variable is set to indicate the error.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Error Conditions</h3>
|
||
|
|
||
|
<p>If <strong>Qp0zCvtToMITime()</strong> is not successful, <em>errno</em>
|
||
|
usually indicates one of the following errors. Under some conditions, <em>
|
||
|
errno</em> could indicate an error other than those listed here.</p>
|
||
|
|
||
|
<dl>
|
||
|
<dt><em>[EINVAL]</em></dt>
|
||
|
|
||
|
<dd>The value specified for the argument is not correct.
|
||
|
|
||
|
<p>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.</p>
|
||
|
|
||
|
<p>An argument value is not valid, out of range, or NULL.</p>
|
||
|
</dd>
|
||
|
|
||
|
<dt><em>[EFAULT]</em></dt>
|
||
|
|
||
|
<dd>The address used for an argument is not correct.
|
||
|
|
||
|
<p>In attempting to use an argument in a call, the system detected an address
|
||
|
that is not valid.</p>
|
||
|
|
||
|
<p>While attempting to access a parameter passed to this function, the system
|
||
|
detected an address that is not valid.</p>
|
||
|
</dd>
|
||
|
|
||
|
<dt><em>[ERANGE]</em></dt>
|
||
|
|
||
|
<dd>A range error occurred.
|
||
|
|
||
|
<p>The value of an argument is too small, or a result too large.</p>
|
||
|
</dd>
|
||
|
|
||
|
<dt><em>[EUNKNOWN]</em></dt>
|
||
|
|
||
|
<dd>Unknown system state.
|
||
|
|
||
|
<p>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.</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Error Messages</h3>
|
||
|
|
||
|
<p>None.</p>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Usage Notes</h3>
|
||
|
|
||
|
<ol type="1">
|
||
|
<li><strong>Qp0zCvtToMITime()</strong>, when called with <strong>
|
||
|
option</strong> equal to QP0Z_CVTTIME_TO_OFFSET, will convert the number of
|
||
|
seconds and microseconds given in the <strong>from</strong> parameter to an
|
||
|
equivalent machine timestamp offset, similar to what the mitime() API
|
||
|
does.</li>
|
||
|
|
||
|
<li><strong>Qp0zCvtToMITime()</strong>, when called with <strong>
|
||
|
option</strong> equal to QP0Z_CVTTIME_TO_TIMESTAMP, will convert the number of
|
||
|
seconds and microseconds given in the <strong>from</strong> parameter to an
|
||
|
equivalent machine timestamp.</li>
|
||
|
</ol>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Related Information</h3>
|
||
|
|
||
|
<ul>
|
||
|
<li>The <<strong>qp0z1170.h</strong>> file (see <a href="unix13.htm">
|
||
|
Header Files for UNIX-Type Functions</a>)</li>
|
||
|
|
||
|
<li><a href="cvttotv.htm">Qp0zCvtToTimeval() - Convert_MI_Time to Timeval
|
||
|
Structure</a></li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Example</h3>
|
||
|
|
||
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
||
|
for information pertaining to code examples.</p>
|
||
|
<p>The following example converts a timestamp:</p>
|
||
|
|
||
|
<pre>
|
||
|
#include <qp0z1170.h>
|
||
|
#include <stdio.h>
|
||
|
#include <errno.h>
|
||
|
|
||
|
int main(int argc, char *argv[])
|
||
|
{
|
||
|
_MI_Time mt;
|
||
|
struct timeval tv;
|
||
|
int rc;
|
||
|
|
||
|
tv.tv_sec=867422292;
|
||
|
tv.tv_usec=52992;
|
||
|
|
||
|
printf("timeval timestamp: %u.%06u\n",
|
||
|
tv.tv_sec, tv.tv_usec);
|
||
|
rc = Qp0zCvtToMITime(mt, &tv,
|
||
|
QP0Z_CVTTIME_TO_TIMESTAMP);
|
||
|
|
||
|
if(rc==0) {
|
||
|
printf("mi timestamp: %08X%08X\n",
|
||
|
*((unsigned *)&mt[0]),
|
||
|
*((unsigned *)&mt[4]));
|
||
|
}
|
||
|
else {
|
||
|
printf("Qp0zCvtToMITime() failed, errno = %d\n",
|
||
|
errno);
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<strong>Example Output:</strong>
|
||
|
|
||
|
<pre>
|
||
|
timeval timestamp: 867422292.052992
|
||
|
mi timestamp: 7B7E9425EAC00000
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
<hr>
|
||
|
API introduced: V4R2
|
||
|
|
||
|
<hr>
|
||
|
<center>
|
||
|
<table cellpadding="2" cellspacing="2">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
||
|
"misc1.htm">Miscellaneous APIs</a> | <a href="aplist.htm">APIs by
|
||
|
category</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</center>
|
||
|
</body>
|
||
|
</html>
|
||
|
|