Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1164

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/tools/qdatetime.cpp:1667 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QDateTime Class</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QDateTime Class Reference</h1>

<p>The QDateTime class provides date and time functions.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qdatetime-h.html">qdatetime.h</a>&gt;</tt>
<p><a href="qdatetime-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QDateTime"><b>QDateTime</b></a> ()</div></li>
<li><div class=fn><a href="#QDateTime-2"><b>QDateTime</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;date )</div></li>
<li><div class=fn><a href="#QDateTime-3"><b>QDateTime</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;date, const&nbsp;QTime&nbsp;&amp;&nbsp;time )</div></li>
<li><div class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</div></li>
<li><div class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</div></li>
<li><div class=fn>QDate <a href="#date"><b>date</b></a> () const</div></li>
<li><div class=fn>QTime <a href="#time"><b>time</b></a> () const</div></li>
<li><div class=fn>void <a href="#setDate"><b>setDate</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;date )</div></li>
<li><div class=fn>void <a href="#setTime"><b>setTime</b></a> ( const&nbsp;QTime&nbsp;&amp;&nbsp;time )</div></li>
<li><div class=fn>void <a href="#setTime_t"><b>setTime_t</b></a> ( uint&nbsp;secsSince1Jan1970UTC )</div></li>
<li><div class=fn>QString <a href="#toString-2"><b>toString</b></a> ( Qt::DateFormat&nbsp;f = Qt::TextDate ) const</div></li>
<li><div class=fn>QString <a href="#toString"><b>toString</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;format ) const</div></li>
<li><div class=fn>QDateTime <a href="#addDays"><b>addDays</b></a> ( int&nbsp;ndays ) const</div></li>
<li><div class=fn>QDateTime <a href="#addMonths"><b>addMonths</b></a> ( int&nbsp;nmonths ) const</div></li>
<li><div class=fn>QDateTime <a href="#addYears"><b>addYears</b></a> ( int&nbsp;nyears ) const</div></li>
<li><div class=fn>QDateTime <a href="#addSecs"><b>addSecs</b></a> ( int&nbsp;nsecs ) const</div></li>
<li><div class=fn>int <a href="#daysTo"><b>daysTo</b></a> ( const&nbsp;QDateTime&nbsp;&amp;&nbsp;dt ) const</div></li>
<li><div class=fn>int <a href="#secsTo"><b>secsTo</b></a> ( const&nbsp;QDateTime&nbsp;&amp;&nbsp;dt ) const</div></li>
<li><div class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QDateTime&nbsp;&amp;&nbsp;dt ) const</div></li>
<li><div class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const&nbsp;QDateTime&nbsp;&amp;&nbsp;dt ) const</div></li>
<li><div class=fn>bool <a href="#operator-lt"><b>operator&lt;</b></a> ( const&nbsp;QDateTime&nbsp;&amp;&nbsp;dt ) const</div></li>
<li><div class=fn>bool <a href="#operator-lt-eq"><b>operator&lt;=</b></a> ( const&nbsp;QDateTime&nbsp;&amp;&nbsp;dt ) const</div></li>
<li><div class=fn>bool <a href="#operator-gt"><b>operator&gt;</b></a> ( const&nbsp;QDateTime&nbsp;&amp;&nbsp;dt ) const</div></li>
<li><div class=fn>bool <a href="#operator-gt-eq"><b>operator&gt;=</b></a> ( const&nbsp;QDateTime&nbsp;&amp;&nbsp;dt ) const</div></li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class=fn>QDateTime <a href="#currentDateTime"><b>currentDateTime</b></a> ()</div></li>
<li><div class=fn>QDateTime <a href="#fromString"><b>fromString</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;s, Qt::DateFormat&nbsp;f = Qt::TextDate )</div></li>
</ul>
<h2>Related Functions</h2>
<ul>
<li><div class=fn>QDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QDateTime&nbsp;&amp;&nbsp;dt )</div></li>
<li><div class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QDateTime&nbsp;&amp;&nbsp;dt )</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QDateTime class provides date and time functions.
<p> 

<p> A QDateTime object contains a calendar date and a clock time (a
"datetime"). It is a combination of the <a href="qdate.html">QDate</a> and <a href="qtime.html">QTime</a> classes. It
can read the current datetime from the system clock. It provides
functions for comparing datetimes and for manipulating a datetime by
adding a number of seconds, days, months or years.
<p> A QDateTime object is typically created either by giving a date and
time explicitly in the constructor, or by using the static function
<a href="#currentDateTime">currentDateTime</a>(), which returns a QDateTime object set to the system
clock's time. The date and time can be changed with <a href="#setDate">setDate</a>() and
<a href="#setTime">setTime</a>(). A datetime can also be set using the <a href="#setTime_t">setTime_t</a>() function,
which takes a POSIX-standard "number of seconds since 00:00:00 on
January 1, 1970" value. The <a href="#fromString">fromString</a>() function returns a QDate
given a string and a date format which is used to interpret the date
within the string.
<p> The <a href="#date">date</a>() and <a href="#time">time</a>() functions provide access to the date and time
parts of the datetime. The same information is provided in textual
format by the <a href="#toString">toString</a>() function.
<p> QDateTime provides a full set of operators to compare two QDateTime
objects where smaller means earlier and larger means later.
<p> You can increment (or decrement) a datetime by a given number of
seconds using <a href="#addSecs">addSecs</a>() or days using <a href="#addDays">addDays</a>(). Similarly you can
use <a href="#addMonths">addMonths</a>() and <a href="#addYears">addYears</a>(). The <a href="#daysTo">daysTo</a>() function returns the
number of days between two datetimes, and sectTo() returns the
number of seconds between two datetimes.
<p> The range of a datetime object is constrained to the ranges of the
<a href="qdate.html">QDate</a> and <a href="qtime.html">QTime</a> objects which it embodies.
<p> <p>See also <a href="qdate.html">QDate</a>, <a href="qtime.html">QTime</a>, <a href="qdatetimeedit.html">QDateTimeEdit</a> and <a href="time.html">Time and Date</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QDateTime"></a>QDateTime::QDateTime ()
</h3>

<p> Constructs a null datetime (i.e. null date and null time).  A null
datetime is invalid, since the date is invalid.
<p> <p>See also <a href="#isValid">isValid</a>().

<h3 class=fn><a name="QDateTime-2"></a>QDateTime::QDateTime ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;date )
</h3>
Constructs a datetime with date <em>date</em> and null time (00:00:00.000).

<h3 class=fn><a name="QDateTime-3"></a>QDateTime::QDateTime ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;date, const&nbsp;<a href="qtime.html">QTime</a>&nbsp;&amp;&nbsp;time )
</h3>
Constructs a datetime with date <em>date</em> and time <em>time</em>.

<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="addDays"></a>QDateTime::addDays ( int&nbsp;ndays ) const
</h3>
Returns a QDateTime object containing a datetime <em>ndays</em> days later
than the datetime of this object (or earlier if <em>ndays</em> is
negative).
<p> <p>See also <a href="#daysTo">daysTo</a>(), <a href="#addMonths">addMonths</a>(), <a href="#addYears">addYears</a>() and <a href="#addSecs">addSecs</a>().

<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="addMonths"></a>QDateTime::addMonths ( int&nbsp;nmonths ) const
</h3>
Returns a QDateTime object containing a datetime <em>nmonths</em> months later
than the datetime of this object (or earlier if <em>nmonths</em> is
negative).
<p> <p>See also <a href="#daysTo">daysTo</a>(), <a href="#addDays">addDays</a>(), <a href="#addYears">addYears</a>() and <a href="#addSecs">addSecs</a>().

<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="addSecs"></a>QDateTime::addSecs ( int&nbsp;nsecs ) const
</h3>
Returns a QDateTime object containing a datetime <em>nsecs</em> seconds
later than the datetime of this object (or earlier if <em>nsecs</em> is
negative).
<p> <p>See also <a href="#secsTo">secsTo</a>(), <a href="#addDays">addDays</a>(), <a href="#addMonths">addMonths</a>() and <a href="#addYears">addYears</a>().

<p>Example: <a href="listviews-example.html#x1205">listviews/listviews.cpp</a>.
<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="addYears"></a>QDateTime::addYears ( int&nbsp;nyears ) const
</h3>
Returns a QDateTime object containing a datetime <em>nyears</em> years later
than the datetime of this object (or earlier if <em>nyears</em> is
negative).
<p> <p>See also <a href="#daysTo">daysTo</a>(), <a href="#addDays">addDays</a>(), <a href="#addMonths">addMonths</a>() and <a href="#addSecs">addSecs</a>().

<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="currentDateTime"></a>QDateTime::currentDateTime ()<tt> [static]</tt>
</h3>
Returns the current datetime, as reported by the system clock.
<p> <p>See also <a href="qdate.html#currentDate">QDate::currentDate</a>() and <a href="qtime.html#currentTime">QTime::currentTime</a>().

<p>Example: <a href="listviews-example.html#x1206">listviews/listviews.cpp</a>.
<h3 class=fn><a href="qdate.html">QDate</a> <a name="date"></a>QDateTime::date () const
</h3>

<p> Returns the date part of the datetime.
<p> <p>See also <a href="#setDate">setDate</a>() and <a href="#time">time</a>().

<h3 class=fn>int <a name="daysTo"></a>QDateTime::daysTo ( const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt ) const
</h3>
Returns the number of days from this datetime to <em>dt</em> (which is
negative if <em>dt</em> is earlier than this datetime).
<p> <p>See also <a href="#addDays">addDays</a>() and <a href="#secsTo">secsTo</a>().

<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="fromString"></a>QDateTime::fromString ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;s, <a href="qt.html#DateFormat-enum">Qt::DateFormat</a>&nbsp;f = Qt::TextDate )<tt> [static]</tt>
</h3>
Returns the QDateTime represented by the string <em>s</em>, using the format
<em>f</em>, or an invalid datetime if this is not possible.
<p> Note that Qt::LocalDate cannot be used here.
<p> Note for Qt::TextDate: It is recommended to use the English short
month names (e.g. Jan). Localized month names may also be used, but
they depend on the user's locale settings.

<h3 class=fn>bool <a name="isNull"></a>QDateTime::isNull () const
</h3>

<p> Returns TRUE if both the date and the time are null; otherwise returns
FALSE. A null datetime is invalid.
<p> <p>See also <a href="qdate.html#isNull">QDate::isNull</a>() and <a href="qtime.html#isNull">QTime::isNull</a>().

<h3 class=fn>bool <a name="isValid"></a>QDateTime::isValid () const
</h3>

<p> Returns TRUE if both the date and the time are valid; otherwise
returns FALSE.
<p> <p>See also <a href="qdate.html#isValid">QDate::isValid</a>() and <a href="qtime.html#isValid">QTime::isValid</a>().

<h3 class=fn>bool <a name="operator!-eq"></a>QDateTime::operator!= ( const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt ) const
</h3>
Returns TRUE if this datetime is different from <em>dt</em>; otherwise
returns FALSE.
<p> <p>See also <a href="#operator-eq-eq">operator==</a>().

<h3 class=fn>bool <a name="operator-lt"></a>QDateTime::operator&lt; ( const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt ) const
</h3>
Returns TRUE if this datetime is earlier than <em>dt</em>, otherwise returns FALSE.

<h3 class=fn>bool <a name="operator-lt-eq"></a>QDateTime::operator&lt;= ( const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt ) const
</h3>
Returns TRUE if this datetime is earlier than or equal to <em>dt</em>,
otherwise returns FALSE.

<h3 class=fn>bool <a name="operator-eq-eq"></a>QDateTime::operator== ( const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt ) const
</h3>
Returns TRUE if this datetime is equal to <em>dt</em>; otherwise returns FALSE.
<p> <p>See also <a href="#operator!-eq">operator!=</a>().

<h3 class=fn>bool <a name="operator-gt"></a>QDateTime::operator&gt; ( const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt ) const
</h3>
Returns TRUE if this datetime is later than <em>dt</em>, otherwise returns FALSE.

<h3 class=fn>bool <a name="operator-gt-eq"></a>QDateTime::operator&gt;= ( const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt ) const
</h3>
Returns TRUE if this datetime is later than or equal to <em>dt</em>,
otherwise returns FALSE.

<h3 class=fn>int <a name="secsTo"></a>QDateTime::secsTo ( const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt ) const
</h3>
Returns the number of seconds from this datetime to <em>dt</em> (which is
negative if <em>dt</em> is earlier than this datetime).
<p> Example:
<pre>
    QDateTime dt = QDateTime::<a href="#currentDateTime">currentDateTime</a>();
    QDateTime xmas( QDate(dt.year(),12,24), QTime(17,00) );
    <a href="qapplication.html#qDebug">qDebug</a>( "There are %d seconds to Christmas", dt.<a href="#secsTo">secsTo</a>(xmas) );
  </pre>
 
<p> <p>See also <a href="#addSecs">addSecs</a>(), <a href="#daysTo">daysTo</a>() and <a href="qtime.html#secsTo">QTime::secsTo</a>().

<h3 class=fn>void <a name="setDate"></a>QDateTime::setDate ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;date )
</h3>

<p> Sets the date part of this datetime to <em>date</em>.
<p> <p>See also <a href="#date">date</a>() and <a href="#setTime">setTime</a>().

<h3 class=fn>void <a name="setTime"></a>QDateTime::setTime ( const&nbsp;<a href="qtime.html">QTime</a>&nbsp;&amp;&nbsp;time )
</h3>

<p> Sets the time part of this datetime to <em>time</em>.
<p> <p>See also <a href="#time">time</a>() and <a href="#setDate">setDate</a>().

<h3 class=fn>void <a name="setTime_t"></a>QDateTime::setTime_t ( uint&nbsp;secsSince1Jan1970UTC )
</h3>
Sets the date and time to local time given the number of seconds that
have passed since 00:00:00 on January 1, 1970, Coordinated Universal
Time (UTC). On systems that do not support timezones this function
will behave as if local time were UTC.
<p> Note that Microsoft Windows supports only a limited range of values for
<em>secsSince1Jan1970UTC</em>.

<h3 class=fn><a href="qtime.html">QTime</a> <a name="time"></a>QDateTime::time () const
</h3>

<p> Returns the time part of the datetime.
<p> <p>See also <a href="#setTime">setTime</a>() and <a href="#date">date</a>().

<h3 class=fn><a href="qstring.html">QString</a> <a name="toString"></a>QDateTime::toString ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;format ) const
</h3>  Returns the datetime as a string.  The <em>format</em> parameter determines
the format of the result string.
<p> These expressions may be used for the date:
<p> <ul>
<li> <em>d</em> - the day as number without a leading zero (1-31)
<li> <em>dd</em> - the day as number with a leading zero (01-31)
<li> <em>ddd</em> - the abbrevated day name (Mon - Sun). Uses <a href="qdate.html#shortDayName">QDate::shortDayName</a>().
<li> <em>dddd</em> - the long day name (Monday - Sunday). Uses <a href="qdate.html#longDayName">QDate::longDayName</a>().
<li> <em>M</em> - the month as number without a leading zero (1-12)
<li> <em>MM</em> - the month as number with a leading zero (01-12)
<li> <em>MMM</em> - the abbrevated month name (Jan - Dec). Uses <a href="qdate.html#shortMonthName">QDate::shortMonthName</a>().
<li> <em>MMMM</em> - the long month name (January - December). Uses <a href="qdate.html#longMonthName">QDate::longMonthName</a>().
<li> <em>yy</em> - the year as two digit number (00-99)
<li> <em>yyyy</em> - the year as four digit number (0000-9999)
</ul>
<p> These expressions may be used for the time:
<p> <ul>
<li> <em>h</em> - the hour without a leading zero (0-23 or 1-12 if AM/PM display)
<li> <em>hh</em> - the hour with a leading zero (00-23 or 01-12 if AM/PM display)
<li> <em>m</em> - the minute without a leading zero (0-59)
<li> <em>mm</em> - the minute with a leading zero (00-59)
<li> <em>s</em> - the second whithout a leading zero (0-59)
<li> <em>ss</em> - the second whith a leading zero (00-59)
<li> <em>z</em> - the milliseconds without leading zeroes (0-999)
<li> <em>zzz</em> - the milliseconds with leading zeroes (000-999)
<li> <em>AP</em> - switch to AM/PM display. <em>AP</em> will be replaced by either "AM" or "PM".
<li> <em>ap</em> - switch to AM/PM display. <em>ap</em> will be replaced by either "am" or "pm".
</ul>
<p> All other input characters will be ignored.
<p> Example format Strings (assumed that the QDateTime is 21. May 2001 14:13:09)
<p> <ul>
<li> "dd.MM.yyyy" will result in "21.05.2001"
<li> "ddd MMMM d yy" will result in "Tue May 21 01"
<li> "hh:mm:ss.zzz"  will result in "14:13:09.042"
<li> "h:m:s ap" will result in "2:13:9 pm"
</ul>
<p> <p>See also <a href="qdate.html#toString">QDate::toString</a>() and <a href="qtime.html#toString">QTime::toString</a>().

<p> 
<h3 class=fn><a href="qstring.html">QString</a> <a name="toString-2"></a>QDateTime::toString ( <a href="qt.html#DateFormat-enum">Qt::DateFormat</a>&nbsp;f = Qt::TextDate ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns the datetime as a string.  The <em>f</em> parameter determines
the format of the string.
<p> If <em>f</em> is Qt::TextDate, the string format is "Wed May 20 03:40:13
1998" (using <a href="qdate.html#shortDayName">QDate::shortDayName</a>(), <a href="qdate.html#shortMonthName">QDate::shortMonthName</a>(), and
<a href="qtime.html#toString">QTime::toString</a>() to generate the string).
<p> If <em>f</em> is Qt::ISODate, the string format corresponds to the ISO
8601 specification for representations of dates and times, which is
YYYY-MM-DDTHH:MM:SS.
<p> If <em>f</em> is Qt::LocalDate, the string format depends on the locale
settings of the system.
<p> If the format <em>f</em> is invalid, <a href="#toString">toString</a>() returns a null string.
<p> <p>See also <a href="qdate.html#toString">QDate::toString</a>() and <a href="qtime.html#toString">QTime::toString</a>().

<p> 
<hr><h2>Related Functions</h2>
<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt )
</h3>

Writes the datetime <em>dt</em> to the stream <em>s</em>.
<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.

<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, <a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;dt )
</h3>

Reads a datetime from the stream <em>s</em> into <em>dt</em>.
<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2001
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>