1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - 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: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QDateTime Class Reference</h1><br clear="all">
<p>
The QDateTime class provides date and time functions.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qdatetime-h.html">qdatetime.h</a>></code>
<p><a href="qdatetime-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#bdaf1f"><b>QDateTime</b></a>()</div>
<li><div class="fn"><a href="#c0bf92"><b>QDateTime</b></a>(constQDate&)</div>
<li><div class="fn"><a href="#81e8a9"><b>QDateTime</b></a>(constQDate&, constQTime&)</div>
<li><div class="fn">bool<a href="#e6faf8"><b>isNull</b></a>()const</div>
<li><div class="fn">bool<a href="#d150c4"><b>isValid</b></a>()const</div>
<li><div class="fn">QDate<a href="#95d9fc"><b>date</b></a>()const</div>
<li><div class="fn">QTime<a href="#26a349"><b>time</b></a>()const</div>
<li><div class="fn">void<a href="#cd24b6"><b>setDate</b></a>(constQDate&date)</div>
<li><div class="fn">void<a href="#9575ee"><b>setTime</b></a>(constQTime&time)</div>
<li><div class="fn">void<a href="#ccd19b"><b>setTime_t</b></a>(uintsecsSince1Jan1970UTC)</div>
<li><div class="fn">QString<a href="#7bf3f7"><b>toString</b></a>()const</div>
<li><div class="fn">QDateTime<a href="#137f05"><b>addDays</b></a>(intdays)const</div>
<li><div class="fn">QDateTime<a href="#a8711a"><b>addSecs</b></a>(intsecs)const</div>
<li><div class="fn">int<a href="#273101"><b>daysTo</b></a>(constQDateTime&)const</div>
<li><div class="fn">int<a href="#fed98c"><b>secsTo</b></a>(constQDateTime&)const</div>
<li><div class="fn">bool<a href="#02776e"><b>operator==</b></a>(constQDateTime&dt)const</div>
<li><div class="fn">bool<a href="#10d09b"><b>operator!=</b></a>(constQDateTime&dt)const</div>
<li><div class="fn">bool<a href="#740b9b"><b>operator<</b></a>(constQDateTime&dt)const</div>
<li><div class="fn">bool<a href="#a94430"><b>operator<=</b></a>(constQDateTime&dt)const</div>
<li><div class="fn">bool<a href="#39912d"><b>operator></b></a>(constQDateTime&dt)const</div>
<li><div class="fn">bool<a href="#72a050"><b>operator>=</b></a>(constQDateTime&dt)const</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">QDateTime<a href="#7e51ee"><b>currentDateTime</b></a>()</div>
</ul>
<h2>Related Functions</h2>
(Note that these are not member functions.)
<ul>
<li>QDataStream & <a href="qdatetime.html#7f4d12"><b>operator<<</b></a> (QDataStream & s, const QDateTime & dt)
<li>QDataStream & <a href="qdatetime.html#95eee0"><b>operator>></b></a> (QDataStream & s, QDateTime & dt)
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QDateTime class provides date and time functions.
<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 or days.
<p>A QDateTime object is typically created either by giving a date and
time explicitly, or by using the static function currentTime(),
which makes a QDateTime object which contains the system's clock
time.
<p>The <a href="#95d9fc">date</a>() and <a href="#26a349">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="#7bf3f7">toString</a>() function.
<p>QDateTime provides a full set of operators to compare two QDateTime
objects. A datetime is considered smaller than another if it is
earlier than the other.
<p>The datetime a given number of days or seconds later than a given
datetime can be found using the <a href="#137f05">addDays</a>() and <a href="#a8711a">addSecs</a>()
functions. Correspondingly, the number of days or seconds between
two times can be found using the <a href="#273101">daysTo</a>() or <a href="#fed98c">secsTo</a>() functions.
<p>A datetime can also be set using the <a href="#ccd19b">setTime_t</a>() function, which
takes a POSIX-standard "number of seconds since 00:00:00 on January
1, 1970" value.
<p>The limitations regarding range and resolution mentioned in the
QDate and QTime documentation apply for QDateTime also.
<p>See also <a href="qdate.html">QDate</a> and <a href="qtime.html">QTime</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="bdaf1f"></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>See also <a href="#d150c4">isValid</a>().
<h3 class="fn"><a name="c0bf92"></a>QDateTime::QDateTime(const<a href="qdate.html">QDate</a>&date)</h3>
<p>Constructs a datetime with date <em>date</em> and null time (00:00:00.000).
<h3 class="fn"><a name="81e8a9"></a>QDateTime::QDateTime(const<a href="qdate.html">QDate</a>&date, const<a href="qtime.html">QTime</a>&time)</h3>
<p>Constructs a datetime with date <em>date</em> and time <em>time.</em>
<h3 class="fn">QDateTime<a name="137f05"></a>QDateTime::addDays(intndays)const</h3>
<p>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>See also <a href="#273101">daysTo</a>() and <a href="#a8711a">addSecs</a>().
<h3 class="fn">QDateTime<a name="a8711a"></a>QDateTime::addSecs(intnsecs)const</h3>
<p>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>See also <a href="#fed98c">secsTo</a>() and <a href="#137f05">addDays</a>().
<h3 class="fn">QDateTime<a name="7e51ee"></a>QDateTime::currentDateTime() <code>[static]</code></h3>
<p>Returns the current datetime, as reported by the system clock.
<p>See also <a href="qdate.html#90308e">QDate::currentDate</a>() and <a href="qtime.html#6091a9">QTime::currentTime</a>().
<h3 class="fn"><a href="qdate.html">QDate</a><a name="95d9fc"></a>QDateTime::date()const</h3>
<p>Returns the date part of this datetime.
<p>See also <a href="#cd24b6">setDate</a>() and <a href="#26a349">time</a>().
<h3 class="fn">int<a name="273101"></a>QDateTime::daysTo(constQDateTime&dt)const</h3>
<p>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>See also <a href="#137f05">addDays</a>() and <a href="#fed98c">secsTo</a>().
<h3 class="fn">bool<a name="e6faf8"></a>QDateTime::isNull()const</h3>
<p>Returns TRUE if both the date and the time are null. A null date is invalid.
<p>See also <a href="qdate.html#220389">QDate::isNull</a>() and <a href="qtime.html#86c35b">QTime::isNull</a>().
<h3 class="fn">bool<a name="d150c4"></a>QDateTime::isValid()const</h3>
<p>Returns TRUE if both the date and the time are valid.
<p>See also <a href="qdate.html#58f77a">QDate::isValid</a>() and <a href="qtime.html#8b8570">QTime::isValid</a>().
<h3 class="fn">bool<a name="10d09b"></a>QDateTime::operator!=(constQDateTime&dt)const</h3>
<p>Returns TRUE if this datetime is different from <em>dt,</em> or FALSE if
they are equal.
<p>See also <a href="#02776e">operator==</a>().
<h3 class="fn">bool<a name="740b9b"></a>QDateTime::operator<(constQDateTime&dt)const</h3>
<p>Returns TRUE if this datetime is earlier than <em>dt,</em> otherwise FALSE.
<h3 class="fn">bool<a name="a94430"></a>QDateTime::operator<=(constQDateTime&dt)const</h3>
<p>Returns TRUE if this datetime is earlier than or equal to <em>dt,</em>
otherwise FALSE.
<h3 class="fn">bool<a name="02776e"></a>QDateTime::operator==(constQDateTime&dt)const</h3>
<p>Returns TRUE if this datetime is equal to <em>dt,</em> or FALSE if
they are different.
<p>See also <a href="#10d09b">operator!=</a>().
<h3 class="fn">bool<a name="39912d"></a>QDateTime::operator>(constQDateTime&dt)const</h3>
<p>Returns TRUE if this datetime is later than <em>dt,</em> otherwise FALSE.
<h3 class="fn">bool<a name="72a050"></a>QDateTime::operator>=(constQDateTime&dt)const</h3>
<p>Returns TRUE if this datetime is later than or equal to <em>dt,</em>
otherwise FALSE.
<h3 class="fn">int<a name="fed98c"></a>QDateTime::secsTo(constQDateTime&dt)const</h3>
<p>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> <a href="qdatetime.html">QDateTime</a> dt = QDateTime::currentDateTime();
<a href="qdatetime.html">QDateTime</a> x( <a href="qdate.html">QDate</a>(dt.year(),12,24), QTime(17,00) );
<a href="qapplication.html#72e78c">qDebug</a>( "There are %d seconds to Christmas", dt.<a href="#fed98c">secsTo</a>(x) );
</pre>
<p>See also <a href="#a8711a">addSecs</a>(), <a href="#273101">daysTo</a>() and <a href="qtime.html#0b9e38">QTime::secsTo</a>().
<h3 class="fn">void<a name="cd24b6"></a>QDateTime::setDate(const<a href="qdate.html">QDate</a>&date)</h3>
<p>Sets the date part of this datetime.
<p>See also <a href="#95d9fc">date</a>() and <a href="#9575ee">setTime</a>().
<h3 class="fn">void<a name="9575ee"></a>QDateTime::setTime(const<a href="qtime.html">QTime</a>&time)</h3>
<p>Sets the time part of this datetime.
<p>See also <a href="#26a349">time</a>() and <a href="#cd24b6">setDate</a>().
<h3 class="fn">void<a name="ccd19b"></a>QDateTime::setTime_t(uintsecsSince1Jan1970UTC)</h3>
<p>Sets the local date and 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="26a349"></a>QDateTime::time()const</h3>
<p>Returns the time part of this datetime.
<p>See also <a href="#9575ee">setTime</a>() and <a href="#95d9fc">date</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="7bf3f7"></a>QDateTime::toString()const</h3>
<p>Returns the datetime as a string.
<p>The string format is "Sat May 20 03:40:13 1998".
<p>This function uses <a href="qdate.html#70af34">QDate::dayName</a>(), <a href="qdate.html#a81f91">QDate::monthName</a>(), and
<a href="qtime.html#9b4f95">QTime::toString</a>() to generate the string.
<hr><h2>Related Functions</h2>
<h3><a href="qdatastream.html">QDataStream</a> & <a name="7f4d12"></a>operator<< (<a href="qdatastream.html">QDataStream</a> & s, const QDateTime & dt)</h3>
<p>Writes a datetime to the stream.
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
<h3><a href="qdatastream.html">QDataStream</a> & <a name="95eee0"></a>operator>> (<a href="qdatastream.html">QDataStream</a> & s, QDateTime & dt)</h3>
<p>Reads a datetime from the stream.
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 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 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|