~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qdate.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/corelib/tools/qdatetime.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QDate Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QDate Class Reference</h1>
 
21
<p>The QDate class provides date functions. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QDate&gt;</pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
 
23
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
 
24
<ul>
 
25
<li><a href="qdate-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qdate-qt3.html">Qt 3 support members</a></li>
 
27
</ul>
 
28
<a name="public-functions"></a>
 
29
<h3>Public Functions</h3>
 
30
<ul>
 
31
<li><div class="fn"/><b><a href="qdate.html#QDate">QDate</a></b> ()</li>
 
32
<li><div class="fn"/><b><a href="qdate.html#QDate-2">QDate</a></b> ( int <i>y</i>, int <i>m</i>, int <i>d</i> )</li>
 
33
<li><div class="fn"/>QDate <b><a href="qdate.html#addDays">addDays</a></b> ( int <i>ndays</i> ) const</li>
 
34
<li><div class="fn"/>QDate <b><a href="qdate.html#addMonths">addMonths</a></b> ( int <i>nmonths</i> ) const</li>
 
35
<li><div class="fn"/>QDate <b><a href="qdate.html#addYears">addYears</a></b> ( int <i>nyears</i> ) const</li>
 
36
<li><div class="fn"/>int <b><a href="qdate.html#day">day</a></b> () const</li>
 
37
<li><div class="fn"/>int <b><a href="qdate.html#dayOfWeek">dayOfWeek</a></b> () const</li>
 
38
<li><div class="fn"/>int <b><a href="qdate.html#dayOfYear">dayOfYear</a></b> () const</li>
 
39
<li><div class="fn"/>int <b><a href="qdate.html#daysInMonth">daysInMonth</a></b> () const</li>
 
40
<li><div class="fn"/>int <b><a href="qdate.html#daysInYear">daysInYear</a></b> () const</li>
 
41
<li><div class="fn"/>int <b><a href="qdate.html#daysTo">daysTo</a></b> ( const QDate &amp; <i>d</i> ) const</li>
 
42
<li><div class="fn"/>bool <b><a href="qdate.html#isNull">isNull</a></b> () const</li>
 
43
<li><div class="fn"/>bool <b><a href="qdate.html#isValid">isValid</a></b> () const</li>
 
44
<li><div class="fn"/>int <b><a href="qdate.html#month">month</a></b> () const</li>
 
45
<li><div class="fn"/>bool <b><a href="qdate.html#setYMD">setYMD</a></b> ( int <i>y</i>, int <i>m</i>, int <i>d</i> )</li>
 
46
<li><div class="fn"/>int <b><a href="qdate.html#toJulianDay">toJulianDay</a></b> () const</li>
 
47
<li><div class="fn"/>QString <b><a href="qdate.html#toString">toString</a></b> ( const QString &amp; <i>format</i> ) const</li>
 
48
<li><div class="fn"/>QString <b><a href="qdate.html#toString-2">toString</a></b> ( Qt::DateFormat <i>format</i> = Qt::TextDate ) const</li>
 
49
<li><div class="fn"/>int <b><a href="qdate.html#weekNumber">weekNumber</a></b> ( int * <i>yearNumber</i> = 0 ) const</li>
 
50
<li><div class="fn"/>int <b><a href="qdate.html#year">year</a></b> () const</li>
 
51
<li><div class="fn"/>bool <b><a href="qdate.html#operator-not-eq">operator!=</a></b> ( const QDate &amp; <i>d</i> ) const</li>
 
52
<li><div class="fn"/>bool <b><a href="qdate.html#operator-lt">operator&lt;</a></b> ( const QDate &amp; <i>d</i> ) const</li>
 
53
<li><div class="fn"/>bool <b><a href="qdate.html#operator-lt-eq">operator&lt;=</a></b> ( const QDate &amp; <i>d</i> ) const</li>
 
54
<li><div class="fn"/>bool <b><a href="qdate.html#operator-eq-eq">operator==</a></b> ( const QDate &amp; <i>d</i> ) const</li>
 
55
<li><div class="fn"/>bool <b><a href="qdate.html#operator-gt">operator&gt;</a></b> ( const QDate &amp; <i>d</i> ) const</li>
 
56
<li><div class="fn"/>bool <b><a href="qdate.html#operator-gt-eq">operator&gt;=</a></b> ( const QDate &amp; <i>d</i> ) const</li>
 
57
</ul>
 
58
<a name="static-public-members"></a>
 
59
<h3>Static Public Members</h3>
 
60
<ul>
 
61
<li><div class="fn"/>QDate <b><a href="qdate.html#currentDate-2">currentDate</a></b> ()</li>
 
62
<li><div class="fn"/>QDate <b><a href="qdate.html#fromJulianDay">fromJulianDay</a></b> ( int <i>jd</i> )</li>
 
63
<li><div class="fn"/>QDate <b><a href="qdate.html#fromString">fromString</a></b> ( const QString &amp; <i>string</i>, Qt::DateFormat <i>format</i> = Qt::TextDate )</li>
 
64
<li><div class="fn"/>QDate <b><a href="qdate.html#fromString-2">fromString</a></b> ( const QString &amp; <i>string</i>, const QString &amp; <i>format</i> )</li>
 
65
<li><div class="fn"/>bool <b><a href="qdate.html#isLeapYear">isLeapYear</a></b> ( int <i>year</i> )</li>
 
66
<li><div class="fn"/>bool <b><a href="qdate.html#isValid-2">isValid</a></b> ( int <i>y</i>, int <i>m</i>, int <i>d</i> )</li>
 
67
<li><div class="fn"/>QString <b><a href="qdate.html#longDayName">longDayName</a></b> ( int <i>weekday</i> )</li>
 
68
<li><div class="fn"/>QString <b><a href="qdate.html#longMonthName">longMonthName</a></b> ( int <i>month</i> )</li>
 
69
<li><div class="fn"/>QString <b><a href="qdate.html#shortDayName">shortDayName</a></b> ( int <i>weekday</i> )</li>
 
70
<li><div class="fn"/>QString <b><a href="qdate.html#shortMonthName">shortMonthName</a></b> ( int <i>month</i> )</li>
 
71
</ul>
 
72
<a name="related-non-members"></a>
 
73
<h3>Related Non-Members</h3>
 
74
<ul>
 
75
<li><div class="fn"/>QDataStream &amp; <b><a href="qdate.html#operator-lt-lt-28">operator&lt;&lt;</a></b> ( QDataStream &amp; <i>out</i>, const QDate &amp; <i>date</i> )</li>
 
76
<li><div class="fn"/>QDataStream &amp; <b><a href="qdate.html#operator-gt-gt-19">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>in</i>, QDate &amp; <i>date</i> )</li>
 
77
</ul>
 
78
<a name="details"></a>
 
79
<hr />
 
80
<h2>Detailed Description</h2>
 
81
<p>The QDate class provides date functions.</p>
 
82
<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 dates. For example, it is possible to add and subtract days, months, and years to dates.</p>
 
83
<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="qdate-qt3.html#currentDate">currentDate</a>() that creates a QDate object containing the system clock's date. An explicit date can also be set using <a href="qdate.html#setYMD">setYMD</a>(). The <a href="qdate.html#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>
 
84
<p>The <a href="qdate.html#year">year</a>(), <a href="qdate.html#month">month</a>(), and <a href="qdate.html#day">day</a>() functions provide access to the year, month, and day numbers. Also, <a href="qdate.html#dayOfWeek">dayOfWeek</a>() and <a href="qdate.html#dayOfYear">dayOfYear</a>() functions are provided. The same information is provided in textual format by the <a href="qdate.html#toString">toString</a>(), <a href="qdate.html#shortDayName">shortDayName</a>(), <a href="qdate.html#longDayName">longDayName</a>(), <a href="qdate.html#shortMonthName">shortMonthName</a>(), and <a href="qdate.html#longMonthName">longMonthName</a>() functions.</p>
 
85
<p>QDate provides a full set of operators to compare two QDate objects where smaller means earlier, and larger means later.</p>
 
86
<p>You can increment (or decrement) a date by a given number of days using <a href="qdate.html#addDays">addDays</a>(). Similarly you can use <a href="qdate.html#addMonths">addMonths</a>() and <a href="qdate.html#addYears">addYears</a>(). The <a href="qdate.html#daysTo">daysTo</a>() function returns the number of days between two dates.</p>
 
87
<p>The <a href="qdate.html#daysInMonth">daysInMonth</a>() and <a href="qdate.html#daysInYear">daysInYear</a>() functions return how many days there are in this date's month and year, respectively. The <a href="qdate.html#isLeapYear">isLeapYear</a>() function indicates whether this date is in a leap year.</p>
 
88
<p>Note that QDate should not be used for date calculations for dates prior to the introduction of the Gregorian calendar. This calendar was adopted by England from the 14 September 1752 (hence this is the earliest valid QDate), and subsequently by most other Western countries, by 1923.</p>
 
89
<p>The latest valid year within this scheme is the year 8000.</p>
 
90
<p>See also <a href="qtime.html">QTime</a>, <a href="qdatetime.html">QDateTime</a>, <a href="qdateedit.html">QDateEdit</a>, and <a href="qdatetimeedit.html">QDateTimeEdit</a>.</p>
 
91
<hr />
 
92
<h2>Member Function Documentation</h2>
 
93
<h3 class="fn"><a name="QDate"></a>QDate::QDate ()</h3>
 
94
<p>Constructs a null date. Null dates are invalid.</p>
 
95
<p>See also <a href="qdate.html#isNull">isNull</a>() and <a href="qdate.html#isValid">isValid</a>().</p>
 
96
<h3 class="fn"><a name="QDate-2"></a>QDate::QDate ( int <i>y</i>, int <i>m</i>, int <i>d</i> )</h3>
 
97
<p>Constructs a date with year <i>y</i>, month <i>m</i> and day <i>d</i>.</p>
 
98
<p><i>y</i> must be in the range 1752 to 8000, <i>m</i> must be in the range 1 to 12, and <i>d</i> must be in the range 1 to 31.</p>
 
99
<p><b>Warning:</b> If <i>y</i> is in the range 0 to 99, it is interpreted as a year in the range 1900 to 1999.</p>
 
100
<p>See also <a href="qdate.html#isValid">isValid</a>().</p>
 
101
<h3 class="fn"><a name="addDays"></a>QDate QDate::addDays ( int <i>ndays</i> ) const</h3>
 
102
<p>Returns a <a href="qdate.html">QDate</a> object containing a date <i>ndays</i> later than the date of this object (or earlier if <i>ndays</i> is negative).</p>
 
103
<p>See also <a href="qdate.html#addMonths">addMonths</a>(), <a href="qdate.html#addYears">addYears</a>(), and <a href="qdate.html#daysTo">daysTo</a>().</p>
 
104
<h3 class="fn"><a name="addMonths"></a>QDate QDate::addMonths ( int <i>nmonths</i> ) const</h3>
 
105
<p>Returns a <a href="qdate.html">QDate</a> object containing a date <i>nmonths</i> later than the date of this object (or earlier if <i>nmonths</i> is negative).</p>
 
106
<p>See also <a href="qdate.html#addDays">addDays</a>() and <a href="qdate.html#addYears">addYears</a>().</p>
 
107
<h3 class="fn"><a name="addYears"></a>QDate QDate::addYears ( int <i>nyears</i> ) const</h3>
 
108
<p>Returns a <a href="qdate.html">QDate</a> object containing a date <i>nyears</i> later than the date of this object (or earlier if <i>nyears</i> is negative).</p>
 
109
<p>See also <a href="qdate.html#addDays">addDays</a>() and <a href="qdate.html#addMonths">addMonths</a>().</p>
 
110
<h3 class="fn"><a name="currentDate-2"></a>QDate QDate::currentDate ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
111
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
112
<p>Returns the current date, as reported by the system clock.</p>
 
113
<p>See also <a href="qtime-qt3.html#currentTime">QTime::currentTime</a>() and <a href="qdatetime.html#currentDateTime">QDateTime::currentDateTime</a>().</p>
 
114
<h3 class="fn"><a name="day"></a>int QDate::day () const</h3>
 
115
<p>Returns the day of the month (1 to 31) of this date.</p>
 
116
<p>See also <a href="qdate.html#year">year</a>(), <a href="qdate.html#month">month</a>(), and <a href="qdate.html#dayOfWeek">dayOfWeek</a>().</p>
 
117
<h3 class="fn"><a name="dayOfWeek"></a>int QDate::dayOfWeek () const</h3>
 
118
<p>Returns the weekday for this date.</p>
 
119
<p>See also <a href="qdate.html#day">day</a>(), <a href="qdate.html#dayOfYear">dayOfYear</a>(), and <a href="qt.html#DayOfWeek-enum">Qt::DayOfWeek</a>.</p>
 
120
<h3 class="fn"><a name="dayOfYear"></a>int QDate::dayOfYear () const</h3>
 
121
<p>Returns the day of the year (1 to 365) for this date.</p>
 
122
<p>See also <a href="qdate.html#day">day</a>() and <a href="qdate.html#dayOfWeek">dayOfWeek</a>().</p>
 
123
<h3 class="fn"><a name="daysInMonth"></a>int QDate::daysInMonth () const</h3>
 
124
<p>Returns the number of days in the month (28 to 31) for this date.</p>
 
125
<p>See also <a href="qdate.html#day">day</a>() and <a href="qdate.html#daysInYear">daysInYear</a>().</p>
 
126
<h3 class="fn"><a name="daysInYear"></a>int QDate::daysInYear () const</h3>
 
127
<p>Returns the number of days in the year (365 or 366) for this date.</p>
 
128
<p>See also <a href="qdate.html#day">day</a>() and <a href="qdate.html#daysInMonth">daysInMonth</a>().</p>
 
129
<h3 class="fn"><a name="daysTo"></a>int QDate::daysTo ( const QDate &amp; <i>d</i> ) const</h3>
 
130
<p>Returns the number of days from this date to <i>d</i> (which is negative if <i>d</i> is earlier than this date).</p>
 
131
<p>Example:</p>
 
132
<pre>&nbsp;   QDate d1(1995, 5, 17);  // May 17, 1995
 
133
    QDate d2(1995, 5, 20);  // May 20, 1995
 
134
    d1.daysTo(d2);          // returns 3
 
135
    d2.daysTo(d1);          // returns -3</pre>
 
136
<p>See also <a href="qdate.html#addDays">addDays</a>().</p>
 
137
<h3 class="fn"><a name="fromJulianDay"></a>QDate QDate::fromJulianDay ( int <i>jd</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
138
<p>Converts the Julian day <i>jd</i> to a <a href="qdate.html">QDate</a>.</p>
 
139
<p>See also <a href="qdate.html#toJulianDay">toJulianDay</a>().</p>
 
140
<h3 class="fn"><a name="fromString"></a>QDate QDate::fromString ( const <a href="qstring.html">QString</a> &amp; <i>string</i>, <a href="qt.html#DateFormat-enum">Qt::DateFormat</a> <i>format</i> = Qt::TextDate )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
141
<p>Returns the <a href="qdate.html">QDate</a> represented by the <i>string</i>, using the <i>format</i> given, or an invalid date if the string cannot be parsed.</p>
 
142
<p>Note for <tt>Qt::TextDate</tt>: It is recommended that you use the English short month names (e.g. &quot;Jan&quot;). Although localized month names can also be used, they depend on the user's locale settings.</p>
 
143
<p><b>Warning:</b> <tt>Qt::LocalDate</tt> cannot be used here.</p>
 
144
<h3 class="fn"><a name="fromString-2"></a>QDate QDate::fromString ( const <a href="qstring.html">QString</a> &amp; <i>string</i>, const <a href="qstring.html">QString</a> &amp; <i>format</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
145
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
146
<p>Returns the <a href="qdate.html">QDate</a> represented by the <i>string</i>, using the <i>format</i> given, or an invalid date if the string cannot be parsed.</p>
 
147
<p>These expressions may be used for the format:</p>
 
148
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
149
<tr valign="top" bgcolor="#a2c511"><th>Expression</th><th>Output</th></tr>
 
150
<tr valign="top" bgcolor="#f0f0f0"><td>d</td><td>The day as a number without a leading zero (1 to 31)</td></tr>
 
151
<tr valign="top" bgcolor="#e0e0e0"><td>dd</td><td>The day as a number with a leading zero (01 to 31)</td></tr>
 
152
<tr valign="top" bgcolor="#f0f0f0"><td>ddd</td><td>The abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses <a href="qdate.html#shortDayName">QDate::shortDayName</a>().</td></tr>
 
153
<tr valign="top" bgcolor="#e0e0e0"><td>dddd</td><td>The long localized day name (e.g. 'Monday' to 'Sunday'). Uses <a href="qdate.html#longDayName">QDate::longDayName</a>().</td></tr>
 
154
<tr valign="top" bgcolor="#f0f0f0"><td>M</td><td>The month as a number without a leading zero (1 to 12)</td></tr>
 
155
<tr valign="top" bgcolor="#e0e0e0"><td>MM</td><td>The month as a number with a leading zero (01 to 12)</td></tr>
 
156
<tr valign="top" bgcolor="#f0f0f0"><td>MMM</td><td>The abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses <a href="qdate.html#shortMonthName">QDate::shortMonthName</a>().</td></tr>
 
157
<tr valign="top" bgcolor="#e0e0e0"><td>MMMM</td><td>The long localized month name (e.g. 'January' to 'December'). Uses <a href="qdate.html#longMonthName">QDate::longMonthName</a>().</td></tr>
 
158
<tr valign="top" bgcolor="#f0f0f0"><td>yy</td><td>The year as two digit number (00 to 99)</td></tr>
 
159
<tr valign="top" bgcolor="#e0e0e0"><td>yyyy</td><td>The year as four digit number (1752 to 8000)</td></tr>
 
160
</table>
 
161
<p>All other input characters will be treated as text. Any sequence of characters that are enclosed in single quotes will also be treated as text and will not be used as an expression. For example:</p>
 
162
<pre>&nbsp;   QDate date = QDate::fromString(&quot;1MM12car2003&quot;, &quot;d'MM'MMcaryyyy&quot;);
 
163
    // date is 1 December 2003</pre>
 
164
<p>If the format is not satisfied, an invalid <a href="qdate.html">QDate</a> is returned. The expressions that don't expect leading zeroes (d, M) will be greedy. This means that they will use two digits even if this will put them outside the accepted range of values and leaves too few digits for other sections. For example, the following format string could have meant January 30 but the M will grab two digits, resulting in an invalid date:</p>
 
165
<pre>&nbsp;   QDate date = QDate::fromString(&quot;130&quot;, &quot;Md&quot;); // invalid</pre>
 
166
<p>For any field that is not represented in the format the following defaults are used:</p>
 
167
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
168
<tr valign="top" bgcolor="#a2c511"><th>Field</th><th>Default value</th></tr>
 
169
<tr valign="top" bgcolor="#f0f0f0"><td>Year</td><td>The current year</td></tr>
 
170
<tr valign="top" bgcolor="#e0e0e0"><td>Month</td><td>1</td></tr>
 
171
<tr valign="top" bgcolor="#f0f0f0"><td>Day</td><td>1</td></tr>
 
172
</table>
 
173
<p>The following examples demonstrate the default values:</p>
 
174
<pre>&nbsp;   QDate::fromString(&quot;1.30&quot;, &quot;M.d&quot;);           // January 30 in the current year
 
175
    QDate::fromString(&quot;20000110&quot;, &quot;yyyyMMdd&quot;);  // January 10, 2000
 
176
    QDate::fromString(&quot;20000110&quot;, &quot;yyyyMd&quot;);    // January 10, 2000</pre>
 
177
<p>See also <a href="qdatetime.html#fromString">QDateTime::fromString</a>(), <a href="qtime.html#fromString">QTime::fromString</a>(), <a href="qdate.html#toString">QDate::toString</a>(), <a href="qdatetime.html#toString">QDateTime::toString</a>(), and <a href="qtime.html#toString">QTime::toString</a>().</p>
 
178
<h3 class="fn"><a name="isLeapYear"></a>bool QDate::isLeapYear ( int <i>year</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
179
<p>Returns true if the specified <i>year</i> is a leap year; otherwise returns false.</p>
 
180
<h3 class="fn"><a name="isNull"></a>bool QDate::isNull () const</h3>
 
181
<p>Returns true if the date is null; otherwise returns false. A null date is invalid.</p>
 
182
<p>See also <a href="qdate.html#isValid">isValid</a>().</p>
 
183
<h3 class="fn"><a name="isValid"></a>bool QDate::isValid () const</h3>
 
184
<p>Returns true if this date is valid; otherwise returns false.</p>
 
185
<p>See also <a href="qdate.html#isNull">isNull</a>().</p>
 
186
<h3 class="fn"><a name="isValid-2"></a>bool QDate::isValid ( int <i>y</i>, int <i>m</i>, int <i>d</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
187
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
188
<p>Returns true if the specified date (year <i>y</i>, month <i>m</i>, and day <i>d</i>) is valid; otherwise returns false.</p>
 
189
<p>Example:</p>
 
190
<pre>&nbsp;   QDate::isValid(2002, 5, 17);  // true
 
191
    QDate::isValid(2002, 2, 30);  // false (Feb 30 does not exist)
 
192
    QDate::isValid(2004, 2, 29);  // true (2004 is a leap year)
 
193
    QDate::isValid(1202, 6, 6);   // false (1202 is pre-Gregorian)</pre>
 
194
<p><b>Warning:</b> A <i>y</i> value in the range 00 to 99 is interpreted as 1900 to 1999.</p>
 
195
<p>See also <a href="qdate.html#isNull">isNull</a>() and <a href="qdate.html#setYMD">setYMD</a>().</p>
 
196
<h3 class="fn"><a name="longDayName"></a><a href="qstring.html">QString</a> QDate::longDayName ( int <i>weekday</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
197
<p>Returns the long name of the <i>weekday</i> using the following convention:</p>
 
198
<ul>
 
199
<li>1 = &quot;Monday&quot;</li>
 
200
<li>2 = &quot;Tuesday&quot;</li>
 
201
<li>3 = &quot;Wednesday&quot;</li>
 
202
<li>4 = &quot;Thursday&quot;</li>
 
203
<li>5 = &quot;Friday&quot;</li>
 
204
<li>6 = &quot;Saturday&quot;</li>
 
205
<li>7 = &quot;Sunday&quot;</li>
 
206
</ul>
 
207
<p>The day names will be localized according to the system's locale settings.</p>
 
208
<p>See also <a href="qdate.html#toString">toString</a>(), <a href="qdate.html#shortDayName">shortDayName</a>(), <a href="qdate.html#shortMonthName">shortMonthName</a>(), and <a href="qdate.html#longMonthName">longMonthName</a>().</p>
 
209
<h3 class="fn"><a name="longMonthName"></a><a href="qstring.html">QString</a> QDate::longMonthName ( int <i>month</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
210
<p>Returns the long name of the <i>month</i> using the following convention:</p>
 
211
<ul>
 
212
<li>1 = &quot;January&quot;</li>
 
213
<li>2 = &quot;February&quot;</li>
 
214
<li>3 = &quot;March&quot;</li>
 
215
<li>4 = &quot;April&quot;</li>
 
216
<li>5 = &quot;May&quot;</li>
 
217
<li>6 = &quot;June&quot;</li>
 
218
<li>7 = &quot;July&quot;</li>
 
219
<li>8 = &quot;August&quot;</li>
 
220
<li>9 = &quot;September&quot;</li>
 
221
<li>10 = &quot;October&quot;</li>
 
222
<li>11 = &quot;November&quot;</li>
 
223
<li>12 = &quot;December&quot;</li>
 
224
</ul>
 
225
<p>The month names will be localized according to the system's locale settings.</p>
 
226
<p>See also <a href="qdate.html#toString">toString</a>(), <a href="qdate.html#shortMonthName">shortMonthName</a>(), <a href="qdate.html#shortDayName">shortDayName</a>(), and <a href="qdate.html#longDayName">longDayName</a>().</p>
 
227
<h3 class="fn"><a name="month"></a>int QDate::month () const</h3>
 
228
<p>Returns the number corresponding to the month of this date, using the following convention:</p>
 
229
<ul>
 
230
<li>1 = &quot;January&quot;</li>
 
231
<li>2 = &quot;February&quot;</li>
 
232
<li>3 = &quot;March&quot;</li>
 
233
<li>4 = &quot;April&quot;</li>
 
234
<li>5 = &quot;May&quot;</li>
 
235
<li>6 = &quot;June&quot;</li>
 
236
<li>7 = &quot;July&quot;</li>
 
237
<li>8 = &quot;August&quot;</li>
 
238
<li>9 = &quot;September&quot;</li>
 
239
<li>10 = &quot;October&quot;</li>
 
240
<li>11 = &quot;November&quot;</li>
 
241
<li>12 = &quot;December&quot;</li>
 
242
</ul>
 
243
<p>See also <a href="qdate.html#year">year</a>() and <a href="qdate.html#day">day</a>().</p>
 
244
<h3 class="fn"><a name="setYMD"></a>bool QDate::setYMD ( int <i>y</i>, int <i>m</i>, int <i>d</i> )</h3>
 
245
<p>Sets the date's year <i>y</i>, month <i>m</i>, and day <i>d</i>.</p>
 
246
<p><i>y</i> must be in the range 1752 to 8000, <i>m</i> must be in the range 1 to 12, and <i>d</i> must be in the range 1 to 31.</p>
 
247
<p><b>Warning:</b> If <i>y</i> is in the range 0 to 99, it is interpreted as 1900 to 1999.</p>
 
248
<p>Returns true if the date is valid; otherwise returns false.</p>
 
249
<h3 class="fn"><a name="shortDayName"></a><a href="qstring.html">QString</a> QDate::shortDayName ( int <i>weekday</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
250
<p>Returns the name of the <i>weekday</i> using the following convention:</p>
 
251
<ul>
 
252
<li>1 = &quot;Mon&quot;</li>
 
253
<li>2 = &quot;Tue&quot;</li>
 
254
<li>3 = &quot;Wed&quot;</li>
 
255
<li>4 = &quot;Thu&quot;</li>
 
256
<li>5 = &quot;Fri&quot;</li>
 
257
<li>6 = &quot;Sat&quot;</li>
 
258
<li>7 = &quot;Sun&quot;</li>
 
259
</ul>
 
260
<p>The day names will be localized according to the system's locale settings.</p>
 
261
<p>See also <a href="qdate.html#toString">toString</a>(), <a href="qdate.html#shortMonthName">shortMonthName</a>(), <a href="qdate.html#longMonthName">longMonthName</a>(), and <a href="qdate.html#longDayName">longDayName</a>().</p>
 
262
<h3 class="fn"><a name="shortMonthName"></a><a href="qstring.html">QString</a> QDate::shortMonthName ( int <i>month</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
263
<p>Returns the name of the <i>month</i> using the following convention:</p>
 
264
<ul>
 
265
<li>1 = &quot;Jan&quot;</li>
 
266
<li>2 = &quot;Feb&quot;</li>
 
267
<li>3 = &quot;Mar&quot;</li>
 
268
<li>4 = &quot;Apr&quot;</li>
 
269
<li>5 = &quot;May&quot;</li>
 
270
<li>6 = &quot;Jun&quot;</li>
 
271
<li>7 = &quot;Jul&quot;</li>
 
272
<li>8 = &quot;Aug&quot;</li>
 
273
<li>9 = &quot;Sep&quot;</li>
 
274
<li>10 = &quot;Oct&quot;</li>
 
275
<li>11 = &quot;Nov&quot;</li>
 
276
<li>12 = &quot;Dec&quot;</li>
 
277
</ul>
 
278
<p>The month names will be localized according to the system's locale settings.</p>
 
279
<p>See also <a href="qdate.html#toString">toString</a>(), <a href="qdate.html#longMonthName">longMonthName</a>(), <a href="qdate.html#shortDayName">shortDayName</a>(), and <a href="qdate.html#longDayName">longDayName</a>().</p>
 
280
<h3 class="fn"><a name="toJulianDay"></a>int QDate::toJulianDay () const</h3>
 
281
<p>Converts the date to a Julian day.</p>
 
282
<p>See also <a href="qdate.html#fromJulianDay">fromJulianDay</a>().</p>
 
283
<h3 class="fn"><a name="toString"></a><a href="qstring.html">QString</a> QDate::toString ( const <a href="qstring.html">QString</a> &amp; <i>format</i> ) const</h3>
 
284
<p>Returns the date as a string. The <i>format</i> parameter determines the format of the result string.</p>
 
285
<p>These expressions may be used:</p>
 
286
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
287
<tr valign="top" bgcolor="#a2c511"><th>Expression</th><th>Output</th></tr>
 
288
<tr valign="top" bgcolor="#f0f0f0"><td>d</td><td>the day as number without a leading zero (1 to31)</td></tr>
 
289
<tr valign="top" bgcolor="#e0e0e0"><td>dd</td><td>the day as number with a leading zero (01 to 31)</td></tr>
 
290
<tr valign="top" bgcolor="#f0f0f0"><td>ddd</td><td>the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses <a href="qdate.html#shortDayName">QDate::shortDayName</a>().</td></tr>
 
291
<tr valign="top" bgcolor="#e0e0e0"><td>dddd</td><td>the long localized day name (e.g. '<a href="qt.html#DayOfWeek-enum">Qt::Monday</a>' to '<a href="qt.html#DayOfWeek-enum">Qt::Sunday</a>'). Uses <a href="qdate.html#longDayName">QDate::longDayName</a>().</td></tr>
 
292
<tr valign="top" bgcolor="#f0f0f0"><td>M</td><td>the month as number without a leading zero (1-12)</td></tr>
 
293
<tr valign="top" bgcolor="#e0e0e0"><td>MM</td><td>the month as number with a leading zero (01-12)</td></tr>
 
294
<tr valign="top" bgcolor="#f0f0f0"><td>MMM</td><td>the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses <a href="qdate.html#shortMonthName">QDate::shortMonthName</a>().</td></tr>
 
295
<tr valign="top" bgcolor="#e0e0e0"><td>MMMM</td><td>the long localized month name (e.g. 'January' to 'December'). Uses <a href="qdate.html#longMonthName">QDate::longMonthName</a>().</td></tr>
 
296
<tr valign="top" bgcolor="#f0f0f0"><td>yy</td><td>the year as two digit number (00 to 99)</td></tr>
 
297
<tr valign="top" bgcolor="#e0e0e0"><td>yyyy</td><td>the year as four digit number (1752 to 8000)</td></tr>
 
298
</table>
 
299
<p>All other input characters will be ignored. Any sequence of characters that are enclosed in singlequotes will be treated as text and not be used as an expression.</p>
 
300
<p>Example format strings (assuming that the <a href="qdate.html">QDate</a> is the 20 July 1969):</p>
 
301
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
302
<tr valign="top" bgcolor="#a2c511"><th>Format</th><th>Result</th></tr>
 
303
<tr valign="top" bgcolor="#f0f0f0"><td>dd.MM.yyyy</td><td>20.07.1969</td></tr>
 
304
<tr valign="top" bgcolor="#e0e0e0"><td>ddd MMMM d yy</td><td>Sun July 20 69</td></tr>
 
305
<tr valign="top" bgcolor="#f0f0f0"><td>'The day is' dddd</td><td>The day is Sunday</td></tr>
 
306
</table>
 
307
<p>If the datetime is invalid, an empty string will be returned.</p>
 
308
<p>See also <a href="qdatetime.html#toString">QDateTime::toString</a>() and <a href="qtime.html#toString">QTime::toString</a>().</p>
 
309
<h3 class="fn"><a name="toString-2"></a><a href="qstring.html">QString</a> QDate::toString ( <a href="qt.html#DateFormat-enum">Qt::DateFormat</a> <i>format</i> = Qt::TextDate ) const</h3>
 
310
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
311
<p>Returns the date as a string. The <i>format</i> parameter determines the format of the string.</p>
 
312
<p>If the <i>format</i> is <tt>Qt::TextDate</tt>, the string is formatted in the default way. <a href="qdate.html#shortDayName">QDate::shortDayName</a>() and <a href="qdate.html#shortMonthName">QDate::shortMonthName</a>() are used to generate the string, so the day and month names will be localized names. An example of this formatting is &quot;Sat May 20 1995&quot;.</p>
 
313
<p>If the <i>format</i> is <tt>Qt::ISODate</tt>, the string format corresponds to the ISO 8601 extended specification for representations of dates and times, taking the form YYYY-MM-DD, where YYYY is the year, MM is the month of the year (between 01 and 12), and DD is the day of the month between 01 and 31.</p>
 
314
<p>If the <i>format</i> is <tt>Qt::LocalDate</tt>, the string format depends on the locale settings of the system.</p>
 
315
<p>If the datetime is invalid, an empty string will be returned.</p>
 
316
<p>See also <a href="qdate.html#shortDayName">shortDayName</a>() and <a href="qdate.html#shortMonthName">shortMonthName</a>().</p>
 
317
<h3 class="fn"><a name="weekNumber"></a>int QDate::weekNumber ( int * <i>yearNumber</i> = 0 ) const</h3>
 
318
<p>Returns the week number (1 to 53), and stores the year in *<i>yearNumber</i> unless <i>yearNumber</i> is null (the default).</p>
 
319
<p>Returns 0 if the date is invalid.</p>
 
320
<p>In accordance with ISO 8601, weeks start on <a href="qt.html#DayOfWeek-enum">Qt::Monday</a> and the first <a href="qt.html#DayOfWeek-enum">Qt::Thursday</a> of a year is always in week 1 of that year. Most years have 52 weeks, but some have 53.</p>
 
321
<p>*<i>yearNumber</i> is not always the same as <a href="qdate.html#year">year</a>(). For example, 1 January 2000 has week number 52 in the year 1999, and 31 December 2002 has week number 1 in the year 2003.</p>
 
322
<pre>&nbsp;   Copyright (c) 1989 The Regents of the University of California.
 
323
    All rights reserved.
 
324
 
 
325
    Redistribution and use in source and binary forms are permitted
 
326
    provided that the above copyright notice and this paragraph are
 
327
    duplicated in all such forms and that any documentation,
 
328
    advertising materials, and other materials related to such
 
329
    distribution and use acknowledge that the software was developed
 
330
    by the University of California, Berkeley.  The name of the
 
331
    University may not be used to endorse or promote products derived
 
332
    from this software without specific prior written permission.
 
333
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 
334
    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 
335
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.</pre>
 
336
<p>See also <a href="qdate.html#isValid">isValid</a>().</p>
 
337
<h3 class="fn"><a name="year"></a>int QDate::year () const</h3>
 
338
<p>Returns the year (1752 to 8000) of this date.</p>
 
339
<p>See also <a href="qdate.html#month">month</a>() and <a href="qdate.html#day">day</a>().</p>
 
340
<h3 class="fn"><a name="operator-not-eq"></a>bool QDate::operator!= ( const QDate &amp; <i>d</i> ) const</h3>
 
341
<p>Returns true if this date is different from <i>d</i>; otherwise returns false.</p>
 
342
<h3 class="fn"><a name="operator-lt"></a>bool QDate::operator&lt; ( const QDate &amp; <i>d</i> ) const</h3>
 
343
<p>Returns true if this date is earlier than <i>d</i>; otherwise returns false.</p>
 
344
<h3 class="fn"><a name="operator-lt-eq"></a>bool QDate::operator&lt;= ( const QDate &amp; <i>d</i> ) const</h3>
 
345
<p>Returns true if this date is earlier than or equal to <i>d</i>; otherwise returns false.</p>
 
346
<h3 class="fn"><a name="operator-eq-eq"></a>bool QDate::operator== ( const QDate &amp; <i>d</i> ) const</h3>
 
347
<p>Returns true if this date is equal to <i>d</i>; otherwise returns false.</p>
 
348
<h3 class="fn"><a name="operator-gt"></a>bool QDate::operator&gt; ( const QDate &amp; <i>d</i> ) const</h3>
 
349
<p>Returns true if this date is later than <i>d</i>; otherwise returns false.</p>
 
350
<h3 class="fn"><a name="operator-gt-eq"></a>bool QDate::operator&gt;= ( const QDate &amp; <i>d</i> ) const</h3>
 
351
<p>Returns true if this date is later than or equal to <i>d</i>; otherwise returns false.</p>
 
352
<hr />
 
353
<h2>Related Non-Members</h2>
 
354
<h3 class="fn"><a name="operator-lt-lt-28"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>out</i>, const QDate &amp; <i>date</i> )</h3>
 
355
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
356
<p>Writes the <i>date</i> to stream <i>out</i>.</p>
 
357
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
 
358
<h3 class="fn"><a name="operator-gt-gt-19"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>in</i>, QDate &amp; <i>date</i> )</h3>
 
359
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
360
<p>Reads a date from stream <i>in</i> into the <i>date</i>.</p>
 
361
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
 
362
<p /><address><hr /><div align="center">
 
363
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
364
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
365
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
366
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
367
</tr></table></div></address></body>
 
368
</html>