<literal>tin</literal> points to
and saves the result into the variable that <literal>tout</literal> points
to.
</para>
<para>
Upon success, the function returns 0 and a negative value if an
error occurred.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</sect2>
<sect2 id="ecpg-pgtypes-interval">
<title>The interval Type</title>
<para>
The interval type in C enables your programs to deal with data of the SQL
type interval. See <xref linkend="datatype-datetime"/> for the equivalent
type in the <productname>PostgreSQL</productname> server.
</para>
<para>
The following functions can be used to work with the interval type:
<variablelist>
<varlistentry id="pgtypesintervalnew">
<term><function>PGTYPESinterval_new</function></term>
<listitem>
<para>
Return a pointer to a newly allocated interval variable.
<synopsis>
interval *PGTYPESinterval_new(void);
</synopsis>
</para>
</listitem>
</varlistentry>
<varlistentry id="pgtypesintervalfree">
<term><function>PGTYPESinterval_free</function></term>
<listitem>
<para>
Release the memory of a previously allocated interval variable.
<synopsis>
void PGTYPESinterval_free(interval *intvl);
</synopsis>
</para>
</listitem>
</varlistentry>
<varlistentry id="pgtypesintervalfromasc">
<term><function>PGTYPESinterval_from_asc</function></term>
<listitem>
<para>
Parse an interval from its textual representation.
<synopsis>
interval *PGTYPESinterval_from_asc(char *str, char **endptr);
</synopsis>
The function parses the input string <literal>str</literal> and returns a
pointer to an allocated interval variable.
At the moment ECPG always parses
the complete string and so it currently does not support to store the
address of the first invalid character in <literal>*endptr</literal>.
You can safely set <literal>endptr</literal> to NULL.
</para>
</listitem>
</varlistentry>
<varlistentry id="pgtypesintervaltoasc">
<term><function>PGTYPESinterval_to_asc</function></term>
<listitem>
<para>
Convert a variable of type interval to its textual representation.
<synopsis>
char *PGTYPESinterval_to_asc(interval *span);
</synopsis>
The function converts the interval variable that <literal>span</literal>
points to into a C char*. The output looks like this example:
<literal>@ 1 day 12 hours 59 mins 10 secs</literal>.
The result must be freed with <function>PGTYPESchar_free()</function>.
</para>
</listitem>
</varlistentry>
<varlistentry id="pgtypesintervalcopy">
<term><function>PGTYPESinterval_copy</function></term>
<listitem>
<para>
Copy a variable of type interval.
<synopsis>
int PGTYPESinterval_copy(interval *intvlsrc, interval *intvldest);
</synopsis>
The function copies the interval variable that <literal>intvlsrc</literal>
points to into the variable that <literal>intvldest</literal> points to. Note
that you need to allocate the memory for the destination variable
before.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</sect2>
<sect2 id="ecpg-pgtypes-decimal">
<title>The decimal Type</title>
<para>
The decimal type is similar to the numeric type. However it is limited to
a maximum precision of 30 significant digits. In contrast to the numeric
type which can be created on the heap only, the decimal type can be
created either on the stack or on the heap (by means of the functions
<function>PGTYPESdecimal_new</function> and
<function>PGTYPESdecimal_free</function>).
There are a lot of other functions that deal with the decimal type in the
<productname>Informix</productname>