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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
<!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 - QDate 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>QDate Class Reference</h1><br clear="all">
<p>
The QDate class provides date functions.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qdatetime-h.html">qdatetime.h</a>></code>
<p><a href="qdate-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#af2e5f"><b>QDate</b></a>()</div>
<li><div class="fn"><a href="#22e5a6"><b>QDate</b></a>(inty, intm, intd)</div>
<li><div class="fn">bool<a href="#220389"><b>isNull</b></a>()const</div>
<li><div class="fn">bool<a href="#58f77a"><b>isValid</b></a>()const</div>
<li><div class="fn">int<a href="#512725"><b>year</b></a>()const</div>
<li><div class="fn">int<a href="#73a46c"><b>month</b></a>()const</div>
<li><div class="fn">int<a href="#ff0275"><b>day</b></a>()const</div>
<li><div class="fn">int<a href="#3bda2f"><b>dayOfWeek</b></a>()const</div>
<li><div class="fn">int<a href="#67eab9"><b>dayOfYear</b></a>()const</div>
<li><div class="fn">int<a href="#10887a"><b>daysInMonth</b></a>()const</div>
<li><div class="fn">int<a href="#0d58c1"><b>daysInYear</b></a>()const</div>
<li><div class="fn">virtualQString<a href="#a81f91"><b>monthName</b></a>(intmonth)const</div>
<li><div class="fn">virtualQString<a href="#70af34"><b>dayName</b></a>(intweekday)const</div>
<li><div class="fn">QString<a href="#91f47c"><b>toString</b></a>()const</div>
<li><div class="fn">bool<a href="#8ef42d"><b>setYMD</b></a>(inty, intm, intd)</div>
<li><div class="fn">QDate<a href="#6be18c"><b>addDays</b></a>(intdays)const</div>
<li><div class="fn">int<a href="#0ccc6a"><b>daysTo</b></a>(constQDate&)const</div>
<li><div class="fn">bool<a href="#409627"><b>operator==</b></a>(constQDate&d)const</div>
<li><div class="fn">bool<a href="#6be475"><b>operator!=</b></a>(constQDate&d)const</div>
<li><div class="fn">bool<a href="#999556"><b>operator<</b></a>(constQDate&d)const</div>
<li><div class="fn">bool<a href="#df0eb1"><b>operator<=</b></a>(constQDate&d)const</div>
<li><div class="fn">bool<a href="#118a54"><b>operator></b></a>(constQDate&d)const</div>
<li><div class="fn">bool<a href="#9742d2"><b>operator>=</b></a>(constQDate&d)const</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">QDate<a href="#90308e"><b>currentDate</b></a>()</div>
<li><div class="fn">bool<a href="#6d947d"><b>isValid</b></a>(inty, intm, intd)</div>
<li><div class="fn">bool<a href="#923611"><b>leapYear</b></a>(intyear)</div>
</ul>
<h2>Static Protected Members</h2>
<ul>
<li><div class="fn">uint<b>greg2jul</b>(inty, intm, intd)(internal)</div>
<li><div class="fn">void<b>jul2greg</b>(uintjd, int&y, int&m, int&d)(internal)</div>
</ul>
<h2>Related Functions</h2>
(Note that these are not member functions.)
<ul>
<li>QDataStream & <a href="qdate.html#2083cf"><b>operator<<</b></a> (QDataStream & s, const QDate & d)
<li>QDataStream & <a href="qdate.html#2c2644"><b>operator>></b></a> (QDataStream & s, QDate & d)
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QDate class provides date functions.
<p>
A QDate object contains a calendar date, i.e. year, month, and day
numbers in the modern western (Gregorian) calendar. It can read the
current date from the system clock. It provides functions for
comparing dates and for manipulating a date by adding a number of
days.
<p>A QDate object is typically created either by giving the year, month
and day numbers explicitly, or by using the static function
<a href="#90308e">currentDate</a>(), which makes a QDate object which contains the
system's clock date. An explicit date can also be set using
<a href="#8ef42d">setYMD</a>().
<p>The <a href="#512725">year</a>(), <a href="#73a46c">month</a>(), and <a href="#ff0275">day</a>() functions provide access to the year,
month, and day numbers. Also, <a href="#3bda2f">dayOfWeek</a>() and <a href="#67eab9">dayOfYear</a>() functions
are provided. The same information is provided in textual format by
the <a href="#91f47c">toString</a>(), <a href="#70af34">dayName</a>(), and <a href="#a81f91">monthName</a>() functions.
<p>QDate provides a full set of operators to compare two QDate
objects. A date is considered smaller than another if it is earlier
than the other.
<p>The date a given number of days later than a given date can be found
using the <a href="#6be18c">addDays</a>() function. Correspondingly, the number of days
between two dates can be found using the <a href="#0ccc6a">daysTo</a>() function.
<p>The <a href="#10887a">daysInMonth</a>() and <a href="#0d58c1">daysInYear</a>() functions tell how many days
there are in this date's month and year, respectively. The
isLeapYear() function tells whether this date is in a leap year.
<p>Note that QDate may not be used for date calculations for dates in
the remote past, i.e. prior to the introduction of the Gregorian
calendar. This calendar was adopted by England Sep. 14. 1752 (hence
this is the earliest valid QDate), and subsequently by most other
western countries, until 1923.
<p>The end of time is reached around 8000AD, by which time we expect Qt
to be obsolete.
<p>See also <a href="qtime.html">QTime</a> and <a href="qdatetime.html">QDateTime</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="af2e5f"></a>QDate::QDate()</h3>
<p>Constructs a null date. Null dates are invalid.
<p>See also <a href="#220389">isNull</a>() and <a href="#58f77a">isValid</a>().
<h3 class="fn"><a name="22e5a6"></a>QDate::QDate(inty, intm, intd)</h3>
<p>Constructs a date with the year <em>y,</em> month <em>m</em> and day <em>d.</em>
<p><em>y</em> must be in the range 1752-ca. 8000, <em>m</em> must be in the range
1-12, and <em>d</em> must be in the range 1-31. Exception: if <em>y</em> is in
the range 0-99, it is interpreted as 1900-1999.
<p>See also <a href="#58f77a">isValid</a>().
<h3 class="fn">QDate<a name="6be18c"></a>QDate::addDays(intndays)const</h3>
<p>Returns a QDate object containing a date <em>ndays</em> later than the
date of this object (or earlier if <em>ndays</em> is negative).
<p>See also <a href="#0ccc6a">daysTo</a>().
<h3 class="fn">QDate<a name="90308e"></a>QDate::currentDate() <code>[static]</code></h3>
<p>Returns the current date, as reported by the system clock.
<p>See also <a href="qtime.html#6091a9">QTime::currentTime</a>() and <a href="qdatetime.html#7e51ee">QDateTime::currentDateTime</a>().
<h3 class="fn">int<a name="ff0275"></a>QDate::day()const</h3>
<p>Returns the day of the month (1..31) of this date.
<p>See also <a href="#512725">year</a>(), <a href="#73a46c">month</a>() and <a href="#3bda2f">dayOfWeek</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="70af34"></a>QDate::dayName(intweekday)const <code>[virtual]</code></h3>
<p>Returns the name of the <em>weekday.</em>
<p>Weekday 1 == "Mon", day 2 == "Tue" etc.
<p>See also <a href="#91f47c">toString</a>() and <a href="#a81f91">monthName</a>().
<h3 class="fn">int<a name="3bda2f"></a>QDate::dayOfWeek()const</h3>
<p>Returns the weekday (Monday=1 .. Sunday=7) for this date.
<p>See also <a href="#ff0275">day</a>() and <a href="#67eab9">dayOfYear</a>().
<h3 class="fn">int<a name="67eab9"></a>QDate::dayOfYear()const</h3>
<p>Returns the day of the year (1..365) for this date.
<p>See also <a href="#ff0275">day</a>() and <a href="#3bda2f">dayOfWeek</a>().
<h3 class="fn">int<a name="10887a"></a>QDate::daysInMonth()const</h3>
<p>Returns the number of days in the month (28..31) for this date.
<p>See also <a href="#ff0275">day</a>() and <a href="#0d58c1">daysInYear</a>().
<h3 class="fn">int<a name="0d58c1"></a>QDate::daysInYear()const</h3>
<p>Returns the number of days in the year (365 or 366) for this date.
<p>See also <a href="#ff0275">day</a>() and <a href="#10887a">daysInMonth</a>().
<h3 class="fn">int<a name="0ccc6a"></a>QDate::daysTo(constQDate&d)const</h3>
<p>Returns the number of days from this date to <em>d</em> (which is negative
if <em>d</em> is earlier than this date).
<p>Example:
<pre> <a href="qdate.html">QDate</a> d1( 1995, 5, 17 ); // May 17th 1995
<a href="qdate.html">QDate</a> d2( 1995, 5, 20 ); // May 20th 1995
d1.<a href="#0ccc6a">daysTo</a>( d2 ); // returns 3
d2.<a href="#0ccc6a">daysTo</a>( d1 ); // returns -3
</pre>
<p>See also <a href="#6be18c">addDays</a>().
<h3 class="fn">bool<a name="220389"></a>QDate::isNull()const</h3>
<p>Returns TRUE if the date is null. A null date is invalid.
<p>See also <a href="#58f77a">isValid</a>().
<h3 class="fn">bool<a name="58f77a"></a>QDate::isValid()const</h3>
<p>Returns TRUE if this date is valid.
<p>See also <a href="#220389">isNull</a>().
<h3 class="fn">bool<a name="6d947d"></a>QDate::isValid(inty, intm, intd) <code>[static]</code></h3>
<p>Returns TRUE if the specified date (year <em>y,</em> month <em>m</em> and day <em>d)</em> is valid.
<p>Example:
<pre> <a href="#58f77a">QDate::isValid</a>( 2002, 5, 17 ); // TRUE; May 17th 2002 is OK.
<a href="#58f77a">QDate::isValid</a>( 2002, 2, 30 ); // FALSE; Feb 30th does not exist
<a href="#58f77a">QDate::isValid</a>( 2004, 2, 29 ); // TRUE; 2004 is a leap year
<a href="#58f77a">QDate::isValid</a>( 1202, 6, 6 ); // FALSE; 1202 is pre-Gregorian
</pre>
<p>Note that a <em>y</em> value in the range 00-99 is interpreted as
1900-1999.
<p>See also <a href="#220389">isNull</a>() and <a href="#8ef42d">setYMD</a>().
<h3 class="fn">bool<a name="923611"></a>QDate::leapYear(inty) <code>[static]</code></h3>
<p>Returns TRUE if the specified year <em>y</em> is a leap year.
<h3 class="fn">int<a name="73a46c"></a>QDate::month()const</h3>
<p>Returns the month (January=1 .. December=12) of this date.
<p>See also <a href="#512725">year</a>() and <a href="#ff0275">day</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="a81f91"></a>QDate::monthName(intmonth)const <code>[virtual]</code></h3>
<p>Returns the name of the <em>month.</em>
<p>Month 1 == "Jan", month 2 == "Feb" etc.
<p>See also <a href="#91f47c">toString</a>() and <a href="#70af34">dayName</a>().
<h3 class="fn">bool<a name="6be475"></a>QDate::operator!=(constQDate&d)const</h3>
<p>Returns TRUE if this date is different from <em>d,</em> or FALSE if
they are equal.
<h3 class="fn">bool<a name="999556"></a>QDate::operator<(constQDate&d)const</h3>
<p>Returns TRUE if this date is earlier than <em>d,</em> otherwise FALSE.
<h3 class="fn">bool<a name="df0eb1"></a>QDate::operator<=(constQDate&d)const</h3>
<p>Returns TRUE if this date is earlier than or equal to <em>d,</em> otherwise FALSE.
<h3 class="fn">bool<a name="409627"></a>QDate::operator==(constQDate&d)const</h3>
<p>Returns TRUE if this date is equal to <em>d,</em> or FALSE if
they are different.
<h3 class="fn">bool<a name="118a54"></a>QDate::operator>(constQDate&d)const</h3>
<p>Returns TRUE if this date is later than <em>d,</em> otherwise FALSE.
<h3 class="fn">bool<a name="9742d2"></a>QDate::operator>=(constQDate&d)const</h3>
<p>Returns TRUE if this date is later than or equal to <em>d,</em> otherwise FALSE.
<h3 class="fn">bool<a name="8ef42d"></a>QDate::setYMD(inty, intm, intd)</h3>
<p>Sets the year <em>y,</em> month <em>m</em> and day <em>d.</em>
<p><em>y</em> must be in the range 1752-ca. 8000, <em>m</em> must be in the range
1-12, and <em>d</em> must be in the range 1-31. Exception: if <em>y</em> is in
the range 0-99, it is interpreted as 1900-1999.
<p>Returns TRUE if the date is valid, otherwise FALSE.
<h3 class="fn"><a href="qstring.html">QString</a><a name="91f47c"></a>QDate::toString()const</h3>
<p>Returns the date as a string.
<p>The string format is "Sat May 20 1995". This function uses the
<a href="#70af34">dayName</a>() and <a href="#a81f91">monthName</a>() functions to generate the string.
<p>See also <a href="#70af34">dayName</a>() and <a href="#a81f91">monthName</a>().
<h3 class="fn">int<a name="512725"></a>QDate::year()const</h3>
<p>Returns the year (>= 1752) of this date.
<p>See also <a href="#73a46c">month</a>() and <a href="#ff0275">day</a>().
<h3 class="fn">uint<a name="d16783"></a>QDate::greg2jul(inty, intm, intd) <code>[staticprotected]</code></h3>
<p>For internal use only.
<h3 class="fn">void<a name="ce4bfd"></a>QDate::jul2greg(uintjd, int&y, int&m, int&d) <code>[staticprotected]</code></h3>
<p>For internal use only.
<hr><h2>Related Functions</h2>
<h3><a href="qdatastream.html">QDataStream</a> & <a name="2083cf"></a>operator<< (<a href="qdatastream.html">QDataStream</a> & s, const QDate & d)</h3>
<p>Writes the date 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="2c2644"></a>operator>> (<a href="qdatastream.html">QDataStream</a> & s, QDate & d)</h3>
<p>Reads a date 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>
|