1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qdatetime.cpp:201 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QDate Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QDate Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QDate class provides date functions.
|
---|
35 | <a href="#details">More...</a>
|
---|
36 | <p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
|
---|
37 | <p><tt>#include <<a href="qdatetime-h.html">qdatetime.h</a>></tt>
|
---|
38 | <p><a href="qdate-members.html">List of all member functions.</a>
|
---|
39 | <h2>Public Members</h2>
|
---|
40 | <ul>
|
---|
41 | <li class=fn><a href="#QDate"><b>QDate</b></a> ()</li>
|
---|
42 | <li class=fn><a href="#QDate-2"><b>QDate</b></a> ( int y, int m, int d )</li>
|
---|
43 | <li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
|
---|
44 | <li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li>
|
---|
45 | <li class=fn>int <a href="#year"><b>year</b></a> () const</li>
|
---|
46 | <li class=fn>int <a href="#month"><b>month</b></a> () const</li>
|
---|
47 | <li class=fn>int <a href="#day"><b>day</b></a> () const</li>
|
---|
48 | <li class=fn>int <a href="#dayOfWeek"><b>dayOfWeek</b></a> () const</li>
|
---|
49 | <li class=fn>int <a href="#dayOfYear"><b>dayOfYear</b></a> () const</li>
|
---|
50 | <li class=fn>int <a href="#daysInMonth"><b>daysInMonth</b></a> () const</li>
|
---|
51 | <li class=fn>int <a href="#daysInYear"><b>daysInYear</b></a> () const</li>
|
---|
52 | <li class=fn>int <a href="#weekNumber"><b>weekNumber</b></a> ( int * yearNumber = 0 ) const</li>
|
---|
53 | <li class=fn>QString <a href="#toString-2"><b>toString</b></a> ( Qt::DateFormat f = Qt::TextDate ) const</li>
|
---|
54 | <li class=fn>QString <a href="#toString"><b>toString</b></a> ( const QString & format ) const</li>
|
---|
55 | <li class=fn>bool <a href="#setYMD"><b>setYMD</b></a> ( int y, int m, int d )</li>
|
---|
56 | <li class=fn>QDate <a href="#addDays"><b>addDays</b></a> ( int ndays ) const</li>
|
---|
57 | <li class=fn>QDate <a href="#addMonths"><b>addMonths</b></a> ( int nmonths ) const</li>
|
---|
58 | <li class=fn>QDate <a href="#addYears"><b>addYears</b></a> ( int nyears ) const</li>
|
---|
59 | <li class=fn>int <a href="#daysTo"><b>daysTo</b></a> ( const QDate & d ) const</li>
|
---|
60 | <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QDate & d ) const</li>
|
---|
61 | <li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QDate & d ) const</li>
|
---|
62 | <li class=fn>bool <a href="#operator-lt"><b>operator<</b></a> ( const QDate & d ) const</li>
|
---|
63 | <li class=fn>bool <a href="#operator-lt-eq"><b>operator<=</b></a> ( const QDate & d ) const</li>
|
---|
64 | <li class=fn>bool <a href="#operator-gt"><b>operator></b></a> ( const QDate & d ) const</li>
|
---|
65 | <li class=fn>bool <a href="#operator-gt-eq"><b>operator>=</b></a> ( const QDate & d ) const</li>
|
---|
66 | </ul>
|
---|
67 | <h2>Static Public Members</h2>
|
---|
68 | <ul>
|
---|
69 | <li class=fn>QString monthName ( int month ) <em>(obsolete)</em></li>
|
---|
70 | <li class=fn>QString dayName ( int weekday ) <em>(obsolete)</em></li>
|
---|
71 | <li class=fn>QString <a href="#shortMonthName"><b>shortMonthName</b></a> ( int month )</li>
|
---|
72 | <li class=fn>QString <a href="#shortDayName"><b>shortDayName</b></a> ( int weekday )</li>
|
---|
73 | <li class=fn>QString <a href="#longMonthName"><b>longMonthName</b></a> ( int month )</li>
|
---|
74 | <li class=fn>QString <a href="#longDayName"><b>longDayName</b></a> ( int weekday )</li>
|
---|
75 | <li class=fn>QDate <a href="#currentDate-2"><b>currentDate</b></a> ()</li>
|
---|
76 | <li class=fn>QDate <a href="#currentDate"><b>currentDate</b></a> ( Qt::TimeSpec ts )</li>
|
---|
77 | <li class=fn>QDate <a href="#fromString"><b>fromString</b></a> ( const QString & s, Qt::DateFormat f = Qt::TextDate )</li>
|
---|
78 | <li class=fn>bool <a href="#isValid-2"><b>isValid</b></a> ( int y, int m, int d )</li>
|
---|
79 | <li class=fn>bool <a href="#leapYear"><b>leapYear</b></a> ( int y )</li>
|
---|
80 | </ul>
|
---|
81 | <h2>Related Functions</h2>
|
---|
82 | <ul>
|
---|
83 | <li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QDate & d )</li>
|
---|
84 | <li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QDate & d )</li>
|
---|
85 | </ul>
|
---|
86 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
87 |
|
---|
88 |
|
---|
89 |
|
---|
90 | The QDate class provides date functions.
|
---|
91 | <p>
|
---|
92 |
|
---|
93 | <p> A QDate object contains a calendar date, i.e. year, month, and day
|
---|
94 | numbers, in the modern Western (Gregorian) calendar. It can read
|
---|
95 | the current date from the system clock. It provides functions for
|
---|
96 | comparing dates and for manipulating dates, e.g. by adding a
|
---|
97 | number of days or months or years.
|
---|
98 | <p> A QDate object is typically created either by giving the year,
|
---|
99 | month and day numbers explicitly, or by using the static function
|
---|
100 | <a href="#currentDate">currentDate</a>(), which creates a QDate object containing the system
|
---|
101 | clock's date. An explicit date can also be set using <a href="#setYMD">setYMD</a>(). The
|
---|
102 | <a href="#fromString">fromString</a>() function returns a QDate given a string and a date
|
---|
103 | format which is used to interpret the date within the string.
|
---|
104 | <p> The <a href="#year">year</a>(), <a href="#month">month</a>(), and <a href="#day">day</a>() functions provide access to the
|
---|
105 | year, month, and day numbers. Also, <a href="#dayOfWeek">dayOfWeek</a>() and <a href="#dayOfYear">dayOfYear</a>()
|
---|
106 | functions are provided. The same information is provided in
|
---|
107 | textual format by the <a href="#toString">toString</a>(), <a href="#shortDayName">shortDayName</a>(), <a href="#longDayName">longDayName</a>(),
|
---|
108 | <a href="#shortMonthName">shortMonthName</a>() and <a href="#longMonthName">longMonthName</a>() functions.
|
---|
109 | <p> QDate provides a full set of operators to compare two QDate
|
---|
110 | objects where smaller means earlier and larger means later.
|
---|
111 | <p> You can increment (or decrement) a date by a given number of days
|
---|
112 | using <a href="#addDays">addDays</a>(). Similarly you can use <a href="#addMonths">addMonths</a>() and <a href="#addYears">addYears</a>().
|
---|
113 | The <a href="#daysTo">daysTo</a>() function returns the number of days between two
|
---|
114 | dates.
|
---|
115 | <p> The <a href="#daysInMonth">daysInMonth</a>() and <a href="#daysInYear">daysInYear</a>() functions return how many days
|
---|
116 | there are in this date's month and year, respectively. The
|
---|
117 | <a href="#leapYear">leapYear</a>() function indicates whether this date is in a leap year.
|
---|
118 | <p> Note that QDate should not be used for date calculations for dates
|
---|
119 | prior to the introduction of the Gregorian calendar. This calendar
|
---|
120 | was adopted by England from the 14<sup><small>th</small></sup>
|
---|
121 | September 1752 (hence this is the earliest valid QDate), and
|
---|
122 | subsequently by most other Western countries, until 1923.
|
---|
123 | <p> The end of time is reached around the year 8000, by which time we
|
---|
124 | expect Qt to be obsolete.
|
---|
125 | <p> <p>See also <a href="qtime.html">QTime</a>, <a href="qdatetime.html">QDateTime</a>, <a href="qdateedit.html">QDateEdit</a>, <a href="qdatetimeedit.html">QDateTimeEdit</a>, and <a href="time.html">Time and Date</a>.
|
---|
126 |
|
---|
127 | <hr><h2>Member Function Documentation</h2>
|
---|
128 | <h3 class=fn><a name="QDate"></a>QDate::QDate ()
|
---|
129 | </h3>
|
---|
130 |
|
---|
131 | <p> Constructs a null date. Null dates are invalid.
|
---|
132 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isValid">isValid</a>().
|
---|
133 |
|
---|
134 | <h3 class=fn><a name="QDate-2"></a>QDate::QDate ( int y, int m, int d )
|
---|
135 | </h3>
|
---|
136 | Constructs a date with year <em>y</em>, month <em>m</em> and day <em>d</em>.
|
---|
137 | <p> <em>y</em> must be in the range 1752..8000, <em>m</em> must be in the range
|
---|
138 | 1..12, and <em>d</em> must be in the range 1..31.
|
---|
139 | <p> <b>Warning:</b> If <em>y</em> is in the range 0..99, it is interpreted as
|
---|
140 | 1900..1999.
|
---|
141 | <p> <p>See also <a href="#isValid">isValid</a>().
|
---|
142 |
|
---|
143 | <h3 class=fn><a href="qdate.html">QDate</a> <a name="addDays"></a>QDate::addDays ( int ndays ) const
|
---|
144 | </h3>
|
---|
145 | Returns a QDate object containing a date <em>ndays</em> later than the
|
---|
146 | date of this object (or earlier if <em>ndays</em> is negative).
|
---|
147 | <p> <p>See also <a href="#addMonths">addMonths</a>(), <a href="#addYears">addYears</a>(), and <a href="#daysTo">daysTo</a>().
|
---|
148 |
|
---|
149 | <h3 class=fn><a href="qdate.html">QDate</a> <a name="addMonths"></a>QDate::addMonths ( int nmonths ) const
|
---|
150 | </h3>
|
---|
151 | Returns a QDate object containing a date <em>nmonths</em> later than the
|
---|
152 | date of this object (or earlier if <em>nmonths</em> is negative).
|
---|
153 | <p> <p>See also <a href="#addDays">addDays</a>() and <a href="#addYears">addYears</a>().
|
---|
154 |
|
---|
155 | <h3 class=fn><a href="qdate.html">QDate</a> <a name="addYears"></a>QDate::addYears ( int nyears ) const
|
---|
156 | </h3>
|
---|
157 | Returns a QDate object containing a date <em>nyears</em> later than the
|
---|
158 | date of this object (or earlier if <em>nyears</em> is negative).
|
---|
159 | <p> <p>See also <a href="#addDays">addDays</a>() and <a href="#addMonths">addMonths</a>().
|
---|
160 |
|
---|
161 | <h3 class=fn><a href="qdate.html">QDate</a> <a name="currentDate"></a>QDate::currentDate ( <a href="qt.html#TimeSpec-enum">Qt::TimeSpec</a> ts )<tt> [static]</tt>
|
---|
162 | </h3>
|
---|
163 | Returns the current date, as reported by the system clock, for the
|
---|
164 | TimeSpec <em>ts</em>. The default TimeSpec is LocalTime.
|
---|
165 | <p> <p>See also <a href="qtime.html#currentTime">QTime::currentTime</a>(), <a href="qdatetime.html#currentDateTime">QDateTime::currentDateTime</a>(), and <a href="qt.html#TimeSpec-enum">Qt::TimeSpec</a>.
|
---|
166 |
|
---|
167 | <p>Example: <a href="dclock-example.html#x1098">dclock/dclock.cpp</a>.
|
---|
168 | <h3 class=fn><a href="qdate.html">QDate</a> <a name="currentDate-2"></a>QDate::currentDate ()<tt> [static]</tt>
|
---|
169 | </h3>
|
---|
170 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
171 | <p> Returns the current date, as reported by the system clock.
|
---|
172 | <p> <p>See also <a href="qtime.html#currentTime">QTime::currentTime</a>() and <a href="qdatetime.html#currentDateTime">QDateTime::currentDateTime</a>().
|
---|
173 |
|
---|
174 | <h3 class=fn>int <a name="day"></a>QDate::day () const
|
---|
175 | </h3>
|
---|
176 | Returns the day of the month (1..31) of this date.
|
---|
177 | <p> <p>See also <a href="#year">year</a>(), <a href="#month">month</a>(), and <a href="#dayOfWeek">dayOfWeek</a>().
|
---|
178 |
|
---|
179 | <p>Example: <a href="dclock-example.html#x1099">dclock/dclock.cpp</a>.
|
---|
180 | <h3 class=fn><a href="qstring.html">QString</a> <a name="dayName"></a>QDate::dayName ( int weekday )<tt> [static]</tt>
|
---|
181 | </h3>
|
---|
182 |
|
---|
183 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
184 | <p> Use <a href="#shortDayName">shortDayName</a>() instead.
|
---|
185 |
|
---|
186 | <h3 class=fn>int <a name="dayOfWeek"></a>QDate::dayOfWeek () const
|
---|
187 | </h3>
|
---|
188 | Returns the weekday (Monday=1..Sunday=7) for this date.
|
---|
189 | <p> <p>See also <a href="#day">day</a>() and <a href="#dayOfYear">dayOfYear</a>().
|
---|
190 |
|
---|
191 | <h3 class=fn>int <a name="dayOfYear"></a>QDate::dayOfYear () const
|
---|
192 | </h3>
|
---|
193 | Returns the day of the year (1..365) for this date.
|
---|
194 | <p> <p>See also <a href="#day">day</a>() and <a href="#dayOfWeek">dayOfWeek</a>().
|
---|
195 |
|
---|
196 | <h3 class=fn>int <a name="daysInMonth"></a>QDate::daysInMonth () const
|
---|
197 | </h3>
|
---|
198 | Returns the number of days in the month (28..31) for this date.
|
---|
199 | <p> <p>See also <a href="#day">day</a>() and <a href="#daysInYear">daysInYear</a>().
|
---|
200 |
|
---|
201 | <h3 class=fn>int <a name="daysInYear"></a>QDate::daysInYear () const
|
---|
202 | </h3>
|
---|
203 | Returns the number of days in the year (365 or 366) for this date.
|
---|
204 | <p> <p>See also <a href="#day">day</a>() and <a href="#daysInMonth">daysInMonth</a>().
|
---|
205 |
|
---|
206 | <h3 class=fn>int <a name="daysTo"></a>QDate::daysTo ( const <a href="qdate.html">QDate</a> & d ) const
|
---|
207 | </h3>
|
---|
208 | Returns the number of days from this date to <em>d</em> (which is
|
---|
209 | negative if <em>d</em> is earlier than this date).
|
---|
210 | <p> Example:
|
---|
211 | <pre>
|
---|
212 | QDate d1( 1995, 5, 17 ); // May 17th 1995
|
---|
213 | QDate d2( 1995, 5, 20 ); // May 20th 1995
|
---|
214 | d1.<a href="#daysTo">daysTo</a>( d2 ); // returns 3
|
---|
215 | d2.<a href="#daysTo">daysTo</a>( d1 ); // returns -3
|
---|
216 | </pre>
|
---|
217 |
|
---|
218 | <p> <p>See also <a href="#addDays">addDays</a>().
|
---|
219 |
|
---|
220 | <h3 class=fn><a href="qdate.html">QDate</a> <a name="fromString"></a>QDate::fromString ( const <a href="qstring.html">QString</a> & s, <a href="qt.html#DateFormat-enum">Qt::DateFormat</a> f = Qt::TextDate )<tt> [static]</tt>
|
---|
221 | </h3>
|
---|
222 | Returns the QDate represented by the string <em>s</em>, using the format
|
---|
223 | <em>f</em>, or an invalid date if the string cannot be parsed.
|
---|
224 | <p> Note for <a href="qt.html#DateFormat-enum">Qt::TextDate</a>: It is recommended that you use the
|
---|
225 | English short month names (e.g. "Jan"). Although localized month
|
---|
226 | names can also be used, they depend on the user's locale settings.
|
---|
227 | <p> <b>Warning:</b> <a href="qt.html#DateFormat-enum">Qt::LocalDate</a> cannot be used here.
|
---|
228 |
|
---|
229 | <h3 class=fn>bool <a name="isNull"></a>QDate::isNull () const
|
---|
230 | </h3>
|
---|
231 |
|
---|
232 | <p> Returns TRUE if the date is null; otherwise returns FALSE. A null
|
---|
233 | date is invalid.
|
---|
234 | <p> <p>See also <a href="#isValid">isValid</a>().
|
---|
235 |
|
---|
236 | <h3 class=fn>bool <a name="isValid"></a>QDate::isValid () const
|
---|
237 | </h3>
|
---|
238 | Returns TRUE if this date is valid; otherwise returns FALSE.
|
---|
239 | <p> <p>See also <a href="#isNull">isNull</a>().
|
---|
240 |
|
---|
241 | <h3 class=fn>bool <a name="isValid-2"></a>QDate::isValid ( int y, int m, int d )<tt> [static]</tt>
|
---|
242 | </h3>
|
---|
243 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
244 | <p> Returns TRUE if the specified date (year <em>y</em>, month <em>m</em> and day
|
---|
245 | <em>d</em>) is valid; otherwise returns FALSE.
|
---|
246 | <p> Example:
|
---|
247 | <pre>
|
---|
248 | QDate::<a href="#isValid">isValid</a>( 2002, 5, 17 ); // TRUE May 17th 2002 is valid
|
---|
249 | QDate::<a href="#isValid">isValid</a>( 2002, 2, 30 ); // FALSE Feb 30th does not exist
|
---|
250 | QDate::<a href="#isValid">isValid</a>( 2004, 2, 29 ); // TRUE 2004 is a leap year
|
---|
251 | QDate::<a href="#isValid">isValid</a>( 1202, 6, 6 ); // FALSE 1202 is pre-Gregorian
|
---|
252 | </pre>
|
---|
253 |
|
---|
254 | <p> <b>Warning:</b> A <em>y</em> value in the range 00..99 is interpreted as
|
---|
255 | 1900..1999.
|
---|
256 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#setYMD">setYMD</a>().
|
---|
257 |
|
---|
258 | <h3 class=fn>bool <a name="leapYear"></a>QDate::leapYear ( int y )<tt> [static]</tt>
|
---|
259 | </h3>
|
---|
260 | Returns TRUE if the specified year <em>y</em> is a leap year; otherwise
|
---|
261 | returns FALSE.
|
---|
262 |
|
---|
263 | <h3 class=fn><a href="qstring.html">QString</a> <a name="longDayName"></a>QDate::longDayName ( int weekday )<tt> [static]</tt>
|
---|
264 | </h3>
|
---|
265 | Returns the long name of the <em>weekday</em>.
|
---|
266 | <p> 1 = "Monday", 2 = "Tuesday", ... 7 = "Sunday"
|
---|
267 | <p> The day names will be localized according to the system's locale
|
---|
268 | settings.
|
---|
269 | <p> <p>See also <a href="#toString">toString</a>(), <a href="#shortDayName">shortDayName</a>(), <a href="#shortMonthName">shortMonthName</a>(), and <a href="#longMonthName">longMonthName</a>().
|
---|
270 |
|
---|
271 | <h3 class=fn><a href="qstring.html">QString</a> <a name="longMonthName"></a>QDate::longMonthName ( int month )<tt> [static]</tt>
|
---|
272 | </h3>
|
---|
273 | Returns the long name of the <em>month</em>.
|
---|
274 | <p> 1 = "January", 2 = "February", ... 12 = "December"
|
---|
275 | <p> The month names will be localized according to the system's locale
|
---|
276 | settings.
|
---|
277 | <p> <p>See also <a href="#toString">toString</a>(), <a href="#shortMonthName">shortMonthName</a>(), <a href="#shortDayName">shortDayName</a>(), and <a href="#longDayName">longDayName</a>().
|
---|
278 |
|
---|
279 | <h3 class=fn>int <a name="month"></a>QDate::month () const
|
---|
280 | </h3>
|
---|
281 | Returns the month (January=1..December=12) of this date.
|
---|
282 | <p> <p>See also <a href="#year">year</a>() and <a href="#day">day</a>().
|
---|
283 |
|
---|
284 | <p>Example: <a href="dclock-example.html#x1100">dclock/dclock.cpp</a>.
|
---|
285 | <h3 class=fn><a href="qstring.html">QString</a> <a name="monthName"></a>QDate::monthName ( int month )<tt> [static]</tt>
|
---|
286 | </h3>
|
---|
287 |
|
---|
288 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
289 | <p> Use <a href="#shortMonthName">shortMonthName</a>() instead.
|
---|
290 |
|
---|
291 | <h3 class=fn>bool <a name="operator!-eq"></a>QDate::operator!= ( const <a href="qdate.html">QDate</a> & d ) const
|
---|
292 | </h3>
|
---|
293 |
|
---|
294 | <p> Returns TRUE if this date is different from <em>d</em>; otherwise returns FALSE.
|
---|
295 |
|
---|
296 | <h3 class=fn>bool <a name="operator-lt"></a>QDate::operator< ( const <a href="qdate.html">QDate</a> & d ) const
|
---|
297 | </h3>
|
---|
298 |
|
---|
299 | <p> Returns TRUE if this date is earlier than <em>d</em>, otherwise returns FALSE.
|
---|
300 |
|
---|
301 | <h3 class=fn>bool <a name="operator-lt-eq"></a>QDate::operator<= ( const <a href="qdate.html">QDate</a> & d ) const
|
---|
302 | </h3>
|
---|
303 |
|
---|
304 | <p> Returns TRUE if this date is earlier than or equal to <em>d</em>,
|
---|
305 | otherwise returns FALSE.
|
---|
306 |
|
---|
307 | <h3 class=fn>bool <a name="operator-eq-eq"></a>QDate::operator== ( const <a href="qdate.html">QDate</a> & d ) const
|
---|
308 | </h3>
|
---|
309 |
|
---|
310 | <p> Returns TRUE if this date is equal to <em>d</em>; otherwise returns FALSE.
|
---|
311 |
|
---|
312 | <h3 class=fn>bool <a name="operator-gt"></a>QDate::operator> ( const <a href="qdate.html">QDate</a> & d ) const
|
---|
313 | </h3>
|
---|
314 |
|
---|
315 | <p> Returns TRUE if this date is later than <em>d</em>, otherwise returns FALSE.
|
---|
316 |
|
---|
317 | <h3 class=fn>bool <a name="operator-gt-eq"></a>QDate::operator>= ( const <a href="qdate.html">QDate</a> & d ) const
|
---|
318 | </h3>
|
---|
319 |
|
---|
320 | <p> Returns TRUE if this date is later than or equal to <em>d</em>,
|
---|
321 | otherwise returns FALSE.
|
---|
322 |
|
---|
323 | <h3 class=fn>bool <a name="setYMD"></a>QDate::setYMD ( int y, int m, int d )
|
---|
324 | </h3>
|
---|
325 | Sets the date's year <em>y</em>, month <em>m</em> and day <em>d</em>.
|
---|
326 | <p> <em>y</em> must be in the range 1752..8000, <em>m</em> must be in the range
|
---|
327 | 1..12, and <em>d</em> must be in the range 1..31.
|
---|
328 | <p> <b>Warning:</b> If <em>y</em> is in the range 0..99, it is interpreted as
|
---|
329 | 1900..1999.
|
---|
330 | <p> Returns TRUE if the date is valid; otherwise returns FALSE.
|
---|
331 |
|
---|
332 | <h3 class=fn><a href="qstring.html">QString</a> <a name="shortDayName"></a>QDate::shortDayName ( int weekday )<tt> [static]</tt>
|
---|
333 | </h3>
|
---|
334 | Returns the name of the <em>weekday</em>.
|
---|
335 | <p> 1 = "Mon", 2 = "Tue", ... 7 = "Sun"
|
---|
336 | <p> The day names will be localized according to the system's locale
|
---|
337 | settings.
|
---|
338 | <p> <p>See also <a href="#toString">toString</a>(), <a href="#shortMonthName">shortMonthName</a>(), <a href="#longMonthName">longMonthName</a>(), and <a href="#longDayName">longDayName</a>().
|
---|
339 |
|
---|
340 | <h3 class=fn><a href="qstring.html">QString</a> <a name="shortMonthName"></a>QDate::shortMonthName ( int month )<tt> [static]</tt>
|
---|
341 | </h3>
|
---|
342 | Returns the name of the <em>month</em>.
|
---|
343 | <p> 1 = "Jan", 2 = "Feb", ... 12 = "Dec"
|
---|
344 | <p> The month names will be localized according to the system's locale
|
---|
345 | settings.
|
---|
346 | <p> <p>See also <a href="#toString">toString</a>(), <a href="#longMonthName">longMonthName</a>(), <a href="#shortDayName">shortDayName</a>(), and <a href="#longDayName">longDayName</a>().
|
---|
347 |
|
---|
348 | <h3 class=fn><a href="qstring.html">QString</a> <a name="toString"></a>QDate::toString ( const <a href="qstring.html">QString</a> & format ) const
|
---|
349 | </h3>
|
---|
350 | Returns the date as a string. The <em>format</em> parameter determines
|
---|
351 | the format of the result string.
|
---|
352 | <p> These expressions may be used:
|
---|
353 | <p> <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
354 | <tr bgcolor="#a2c511"> <th valign="top">Expression <th valign="top">Output
|
---|
355 | <tr bgcolor="#f0f0f0"> <td valign="top">d <td valign="top">the day as number without a leading zero (1-31)
|
---|
356 | <tr bgcolor="#d0d0d0"> <td valign="top">dd <td valign="top">the day as number with a leading zero (01-31)
|
---|
357 | <tr bgcolor="#f0f0f0"> <td valign="top">ddd
|
---|
358 | <td valign="top">the abbreviated localized day name (e.g. 'Mon'..'Sun').
|
---|
359 | Uses <a href="#shortDayName">QDate::shortDayName</a>().
|
---|
360 | <tr bgcolor="#d0d0d0"> <td valign="top">dddd
|
---|
361 | <td valign="top">the long localized day name (e.g. 'Monday'..'Sunday').
|
---|
362 | Uses <a href="#longDayName">QDate::longDayName</a>().
|
---|
363 | <tr bgcolor="#f0f0f0"> <td valign="top">M <td valign="top">the month as number without a leading zero (1-12)
|
---|
364 | <tr bgcolor="#d0d0d0"> <td valign="top">MM <td valign="top">the month as number with a leading zero (01-12)
|
---|
365 | <tr bgcolor="#f0f0f0"> <td valign="top">MMM
|
---|
366 | <td valign="top">the abbreviated localized month name (e.g. 'Jan'..'Dec').
|
---|
367 | Uses <a href="#shortMonthName">QDate::shortMonthName</a>().
|
---|
368 | <tr bgcolor="#d0d0d0"> <td valign="top">MMMM
|
---|
369 | <td valign="top">the long localized month name (e.g. 'January'..'December').
|
---|
370 | Uses <a href="#longMonthName">QDate::longMonthName</a>().
|
---|
371 | <tr bgcolor="#f0f0f0"> <td valign="top">yy <td valign="top">the year as two digit number (00-99)
|
---|
372 | <tr bgcolor="#d0d0d0"> <td valign="top">yyyy <td valign="top">the year as four digit number (1752-8000)
|
---|
373 | </table></center>
|
---|
374 | <p> All other input characters will be ignored.
|
---|
375 | <p> Example format strings (assuming that the QDate is the
|
---|
376 | 20<sup><small>th</small></sup> July 1969):
|
---|
377 | <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
378 | <tr bgcolor="#a2c511"> <th valign="top">Format <th valign="top">Result
|
---|
379 | <tr bgcolor="#f0f0f0"> <td valign="top">dd.MM.yyyy <td valign="top" colspan="1" rowspan="1"> 20.07.1969
|
---|
380 | <tr bgcolor="#d0d0d0"> <td valign="top">ddd MMMM d yy <td valign="top" colspan="1" rowspan="1"> Sun July 20 69
|
---|
381 | </table></center>
|
---|
382 | <p> If the date is an invalid date, then <a href="qstring.html#QString-null">QString::null</a> will be returned.
|
---|
383 | <p> <p>See also <a href="qdatetime.html#toString">QDateTime::toString</a>() and <a href="qtime.html#toString">QTime::toString</a>().
|
---|
384 |
|
---|
385 | <p>
|
---|
386 | <h3 class=fn><a href="qstring.html">QString</a> <a name="toString-2"></a>QDate::toString ( <a href="qt.html#DateFormat-enum">Qt::DateFormat</a> f = Qt::TextDate ) const
|
---|
387 | </h3>
|
---|
388 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
389 | <p> Returns the date as a string. The <em>f</em> parameter determines the
|
---|
390 | format of the string.
|
---|
391 | <p> If <em>f</em> is <a href="qt.html#DateFormat-enum">Qt::TextDate</a>, the string format is "Sat May 20 1995"
|
---|
392 | (using the <a href="#shortDayName">shortDayName</a>() and <a href="#shortMonthName">shortMonthName</a>() functions to
|
---|
393 | generate the string, so the day and month names are locale
|
---|
394 | specific).
|
---|
395 | <p> If <em>f</em> is <a href="qt.html#DateFormat-enum">Qt::ISODate</a>, the string format corresponds to the
|
---|
396 | ISO 8601 specification for representations of dates, which is
|
---|
397 | YYYY-MM-DD where YYYY is the year, MM is the month of the year
|
---|
398 | (between 01 and 12), and DD is the day of the month between 01 and
|
---|
399 | 31.
|
---|
400 | <p> If <em>f</em> is <a href="qt.html#DateFormat-enum">Qt::LocalDate</a>, the string format depends on the
|
---|
401 | locale settings of the system.
|
---|
402 | <p> If the date is an invalid date, then <a href="qstring.html#QString-null">QString::null</a> will be returned.
|
---|
403 | <p> <p>See also <a href="#shortDayName">shortDayName</a>() and <a href="#shortMonthName">shortMonthName</a>().
|
---|
404 |
|
---|
405 | <h3 class=fn>int <a name="weekNumber"></a>QDate::weekNumber ( int * yearNumber = 0 ) const
|
---|
406 | </h3>
|
---|
407 | Returns the week number (1 to 53), and stores the year in <em>*yearNumber</em> unless <em>yearNumber</em> is null (the default).
|
---|
408 | <p> Returns 0 if the date is invalid.
|
---|
409 | <p> In accordance with ISO 8601, weeks start on Monday and the first
|
---|
410 | Thursday of a year is always in week 1 of that year. Most years
|
---|
411 | have 52 weeks, but some have 53.
|
---|
412 | <p> <em>*yearNumber</em> is not always the same as <a href="#year">year</a>(). For example, 1
|
---|
413 | January 2000 has week number 52 in the year 1999, and 31 December
|
---|
414 | 2002 has week number 1 in the year 2003.
|
---|
415 | <p>
|
---|
416 | <p> Copyright (c) 1989 The Regents of the University of California.
|
---|
417 | All rights reserved.
|
---|
418 | <p> Redistribution and use in source and binary forms are permitted
|
---|
419 | provided that the above copyright notice and this paragraph are
|
---|
420 | duplicated in all such forms and that any documentation,
|
---|
421 | advertising materials, and other materials related to such
|
---|
422 | distribution and use acknowledge that the software was developed
|
---|
423 | by the University of California, Berkeley. The name of the
|
---|
424 | University may not be used to endorse or promote products derived
|
---|
425 | from this software without specific prior written permission.
|
---|
426 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
---|
427 | IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
---|
428 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
429 | <p> <p>See also <a href="#isValid">isValid</a>().
|
---|
430 |
|
---|
431 | <h3 class=fn>int <a name="year"></a>QDate::year () const
|
---|
432 | </h3>
|
---|
433 | Returns the year (1752..8000) of this date.
|
---|
434 | <p> <p>See also <a href="#month">month</a>() and <a href="#day">day</a>().
|
---|
435 |
|
---|
436 | <hr><h2>Related Functions</h2>
|
---|
437 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">QDataStream</a> & s, const <a href="qdate.html">QDate</a> & d )
|
---|
438 | </h3>
|
---|
439 |
|
---|
440 | <p> Writes the date, <em>d</em>, to the data stream, <em>s</em>.
|
---|
441 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
442 |
|
---|
443 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qdate.html">QDate</a> & d )
|
---|
444 | </h3>
|
---|
445 |
|
---|
446 | <p> Reads a date from the stream <em>s</em> into <em>d</em>.
|
---|
447 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
448 |
|
---|
449 | <!-- eof -->
|
---|
450 | <hr><p>
|
---|
451 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
452 | Copyright © 1995-2007
|
---|
453 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
454 | <table width=100% cellspacing=0 border=0><tr>
|
---|
455 | <td>Copyright © 2007
|
---|
456 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
457 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
458 | </table></div></address></body>
|
---|
459 | </html>
|
---|