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:1861 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QDateTime 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>QDateTime Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QDateTime class provides date and time 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="qdatetime-members.html">List of all member functions.</a>
|
---|
39 | <h2>Public Members</h2>
|
---|
40 | <ul>
|
---|
41 | <li class=fn><a href="#QDateTime"><b>QDateTime</b></a> ()</li>
|
---|
42 | <li class=fn><a href="#QDateTime-2"><b>QDateTime</b></a> ( const QDate & date )</li>
|
---|
43 | <li class=fn><a href="#QDateTime-3"><b>QDateTime</b></a> ( const QDate & date, const QTime & time )</li>
|
---|
44 | <li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
|
---|
45 | <li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li>
|
---|
46 | <li class=fn>QDate <a href="#date"><b>date</b></a> () const</li>
|
---|
47 | <li class=fn>QTime <a href="#time"><b>time</b></a> () const</li>
|
---|
48 | <li class=fn>uint <a href="#toTime_t"><b>toTime_t</b></a> () const</li>
|
---|
49 | <li class=fn>void <a href="#setDate"><b>setDate</b></a> ( const QDate & date )</li>
|
---|
50 | <li class=fn>void <a href="#setTime"><b>setTime</b></a> ( const QTime & time )</li>
|
---|
51 | <li class=fn>void <a href="#setTime_t-2"><b>setTime_t</b></a> ( uint secsSince1Jan1970UTC )</li>
|
---|
52 | <li class=fn>void <a href="#setTime_t"><b>setTime_t</b></a> ( uint secsSince1Jan1970UTC, Qt::TimeSpec ts )</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>QDateTime <a href="#addDays"><b>addDays</b></a> ( int ndays ) const</li>
|
---|
56 | <li class=fn>QDateTime <a href="#addMonths"><b>addMonths</b></a> ( int nmonths ) const</li>
|
---|
57 | <li class=fn>QDateTime <a href="#addYears"><b>addYears</b></a> ( int nyears ) const</li>
|
---|
58 | <li class=fn>QDateTime <a href="#addSecs"><b>addSecs</b></a> ( int nsecs ) const</li>
|
---|
59 | <li class=fn>int <a href="#daysTo"><b>daysTo</b></a> ( const QDateTime & dt ) const</li>
|
---|
60 | <li class=fn>int <a href="#secsTo"><b>secsTo</b></a> ( const QDateTime & dt ) const</li>
|
---|
61 | <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QDateTime & dt ) const</li>
|
---|
62 | <li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QDateTime & dt ) const</li>
|
---|
63 | <li class=fn>bool <a href="#operator-lt"><b>operator<</b></a> ( const QDateTime & dt ) const</li>
|
---|
64 | <li class=fn>bool <a href="#operator-lt-eq"><b>operator<=</b></a> ( const QDateTime & dt ) const</li>
|
---|
65 | <li class=fn>bool <a href="#operator-gt"><b>operator></b></a> ( const QDateTime & dt ) const</li>
|
---|
66 | <li class=fn>bool <a href="#operator-gt-eq"><b>operator>=</b></a> ( const QDateTime & dt ) const</li>
|
---|
67 | </ul>
|
---|
68 | <h2>Static Public Members</h2>
|
---|
69 | <ul>
|
---|
70 | <li class=fn>QDateTime <a href="#currentDateTime-2"><b>currentDateTime</b></a> ()</li>
|
---|
71 | <li class=fn>QDateTime <a href="#currentDateTime"><b>currentDateTime</b></a> ( Qt::TimeSpec ts )</li>
|
---|
72 | <li class=fn>QDateTime <a href="#fromString"><b>fromString</b></a> ( const QString & s, Qt::DateFormat f = Qt::TextDate )</li>
|
---|
73 | </ul>
|
---|
74 | <h2>Related Functions</h2>
|
---|
75 | <ul>
|
---|
76 | <li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QDateTime & dt )</li>
|
---|
77 | <li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QDateTime & dt )</li>
|
---|
78 | </ul>
|
---|
79 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
80 |
|
---|
81 |
|
---|
82 |
|
---|
83 | The QDateTime class provides date and time functions.
|
---|
84 | <p>
|
---|
85 |
|
---|
86 | <p> A QDateTime object contains a calendar date and a clock time (a
|
---|
87 | "datetime"). It is a combination of the <a href="qdate.html">QDate</a> and <a href="qtime.html">QTime</a> classes.
|
---|
88 | It can read the current datetime from the system clock. It
|
---|
89 | provides functions for comparing datetimes and for manipulating a
|
---|
90 | datetime by adding a number of seconds, days, months or years.
|
---|
91 | <p> A QDateTime object is typically created either by giving a date
|
---|
92 | and time explicitly in the constructor, or by using the static
|
---|
93 | function <a href="#currentDateTime">currentDateTime</a>(), which returns a QDateTime object set
|
---|
94 | to the system clock's time. The date and time can be changed with
|
---|
95 | <a href="#setDate">setDate</a>() and <a href="#setTime">setTime</a>(). A datetime can also be set using the
|
---|
96 | <a href="#setTime_t">setTime_t</a>() function, which takes a POSIX-standard "number of
|
---|
97 | seconds since 00:00:00 on January 1, 1970" value. The <a href="#fromString">fromString</a>()
|
---|
98 | function returns a QDateTime given a string and a date format
|
---|
99 | which is used to interpret the date within the string.
|
---|
100 | <p> The <a href="#date">date</a>() and <a href="#time">time</a>() functions provide access to the date and
|
---|
101 | time parts of the datetime. The same information is provided in
|
---|
102 | textual format by the <a href="#toString">toString</a>() function.
|
---|
103 | <p> QDateTime provides a full set of operators to compare two
|
---|
104 | QDateTime objects where smaller means earlier and larger means
|
---|
105 | later.
|
---|
106 | <p> You can increment (or decrement) a datetime by a given number of
|
---|
107 | seconds using <a href="#addSecs">addSecs</a>() or days using <a href="#addDays">addDays</a>(). Similarly you can
|
---|
108 | use <a href="#addMonths">addMonths</a>() and <a href="#addYears">addYears</a>(). The <a href="#daysTo">daysTo</a>() function returns the
|
---|
109 | number of days between two datetimes, and <a href="#secsTo">secsTo</a>() returns the
|
---|
110 | number of seconds between two datetimes.
|
---|
111 | <p> The range of a datetime object is constrained to the ranges of the
|
---|
112 | <a href="qdate.html">QDate</a> and <a href="qtime.html">QTime</a> objects which it embodies.
|
---|
113 | <p> <p>See also <a href="qdate.html">QDate</a>, <a href="qtime.html">QTime</a>, <a href="qdatetimeedit.html">QDateTimeEdit</a>, and <a href="time.html">Time and Date</a>.
|
---|
114 |
|
---|
115 | <hr><h2>Member Function Documentation</h2>
|
---|
116 | <h3 class=fn><a name="QDateTime"></a>QDateTime::QDateTime ()
|
---|
117 | </h3>
|
---|
118 |
|
---|
119 | <p> Constructs a null datetime (i.e. null date and null time). A null
|
---|
120 | datetime is invalid, since the date is invalid.
|
---|
121 | <p> <p>See also <a href="#isValid">isValid</a>().
|
---|
122 |
|
---|
123 | <h3 class=fn><a name="QDateTime-2"></a>QDateTime::QDateTime ( const <a href="qdate.html">QDate</a> & date )
|
---|
124 | </h3>
|
---|
125 | Constructs a datetime with date <em>date</em> and null (but valid) time
|
---|
126 | (00:00:00.000).
|
---|
127 |
|
---|
128 | <h3 class=fn><a name="QDateTime-3"></a>QDateTime::QDateTime ( const <a href="qdate.html">QDate</a> & date, const <a href="qtime.html">QTime</a> & time )
|
---|
129 | </h3>
|
---|
130 | Constructs a datetime with date <em>date</em> and time <em>time</em>.
|
---|
131 |
|
---|
132 | <h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="addDays"></a>QDateTime::addDays ( int ndays ) const
|
---|
133 | </h3>
|
---|
134 | Returns a QDateTime object containing a datetime <em>ndays</em> days
|
---|
135 | later than the datetime of this object (or earlier if <em>ndays</em> is
|
---|
136 | negative).
|
---|
137 | <p> <p>See also <a href="#daysTo">daysTo</a>(), <a href="#addMonths">addMonths</a>(), <a href="#addYears">addYears</a>(), and <a href="#addSecs">addSecs</a>().
|
---|
138 |
|
---|
139 | <h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="addMonths"></a>QDateTime::addMonths ( int nmonths ) const
|
---|
140 | </h3>
|
---|
141 | Returns a QDateTime object containing a datetime <em>nmonths</em> months
|
---|
142 | later than the datetime of this object (or earlier if <em>nmonths</em>
|
---|
143 | is negative).
|
---|
144 | <p> <p>See also <a href="#daysTo">daysTo</a>(), <a href="#addDays">addDays</a>(), <a href="#addYears">addYears</a>(), and <a href="#addSecs">addSecs</a>().
|
---|
145 |
|
---|
146 | <h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="addSecs"></a>QDateTime::addSecs ( int nsecs ) const
|
---|
147 | </h3>
|
---|
148 | Returns a QDateTime object containing a datetime <em>nsecs</em> seconds
|
---|
149 | later than the datetime of this object (or earlier if <em>nsecs</em> is
|
---|
150 | negative).
|
---|
151 | <p> <p>See also <a href="#secsTo">secsTo</a>(), <a href="#addDays">addDays</a>(), <a href="#addMonths">addMonths</a>(), and <a href="#addYears">addYears</a>().
|
---|
152 |
|
---|
153 | <p>Example: <a href="listviews-example.html#x136">listviews/listviews.cpp</a>.
|
---|
154 | <h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="addYears"></a>QDateTime::addYears ( int nyears ) const
|
---|
155 | </h3>
|
---|
156 | Returns a QDateTime object containing a datetime <em>nyears</em> years
|
---|
157 | later than the datetime of this object (or earlier if <em>nyears</em> is
|
---|
158 | negative).
|
---|
159 | <p> <p>See also <a href="#daysTo">daysTo</a>(), <a href="#addDays">addDays</a>(), <a href="#addMonths">addMonths</a>(), and <a href="#addSecs">addSecs</a>().
|
---|
160 |
|
---|
161 | <h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="currentDateTime"></a>QDateTime::currentDateTime ( <a href="qt.html#TimeSpec-enum">Qt::TimeSpec</a> ts )<tt> [static]</tt>
|
---|
162 | </h3>
|
---|
163 | Returns the current datetime, 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="qdate.html#currentDate">QDate::currentDate</a>(), <a href="qtime.html#currentTime">QTime::currentTime</a>(), and <a href="qt.html#TimeSpec-enum">Qt::TimeSpec</a>.
|
---|
166 |
|
---|
167 | <p>Example: <a href="listviews-example.html#x137">listviews/listviews.cpp</a>.
|
---|
168 | <h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="currentDateTime-2"></a>QDateTime::currentDateTime ()<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 datetime, as reported by the system clock.
|
---|
172 | <p> <p>See also <a href="qdate.html#currentDate">QDate::currentDate</a>() and <a href="qtime.html#currentTime">QTime::currentTime</a>().
|
---|
173 |
|
---|
174 | <h3 class=fn><a href="qdate.html">QDate</a> <a name="date"></a>QDateTime::date () const
|
---|
175 | </h3>
|
---|
176 |
|
---|
177 | <p> Returns the date part of the datetime.
|
---|
178 | <p> <p>See also <a href="#setDate">setDate</a>() and <a href="#time">time</a>().
|
---|
179 |
|
---|
180 | <h3 class=fn>int <a name="daysTo"></a>QDateTime::daysTo ( const <a href="qdatetime.html">QDateTime</a> & dt ) const
|
---|
181 | </h3>
|
---|
182 | Returns the number of days from this datetime to <em>dt</em> (which is
|
---|
183 | negative if <em>dt</em> is earlier than this datetime).
|
---|
184 | <p> <p>See also <a href="#addDays">addDays</a>() and <a href="#secsTo">secsTo</a>().
|
---|
185 |
|
---|
186 | <h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="fromString"></a>QDateTime::fromString ( const <a href="qstring.html">QString</a> & s, <a href="qt.html#DateFormat-enum">Qt::DateFormat</a> f = Qt::TextDate )<tt> [static]</tt>
|
---|
187 | </h3>
|
---|
188 | Returns the QDateTime represented by the string <em>s</em>, using the
|
---|
189 | format <em>f</em>, or an invalid datetime if this is not possible.
|
---|
190 | <p> Note for <a href="qt.html#DateFormat-enum">Qt::TextDate</a>: It is recommended that you use the
|
---|
191 | English short month names (e.g. "Jan"). Although localized month
|
---|
192 | names can also be used, they depend on the user's locale settings.
|
---|
193 | <p> <b>Warning:</b> Note that <a href="qt.html#DateFormat-enum">Qt::LocalDate</a> cannot be used here.
|
---|
194 |
|
---|
195 | <h3 class=fn>bool <a name="isNull"></a>QDateTime::isNull () const
|
---|
196 | </h3>
|
---|
197 |
|
---|
198 | <p> Returns TRUE if both the date and the time are null; otherwise
|
---|
199 | returns FALSE. A null datetime is invalid.
|
---|
200 | <p> <p>See also <a href="qdate.html#isNull">QDate::isNull</a>() and <a href="qtime.html#isNull">QTime::isNull</a>().
|
---|
201 |
|
---|
202 | <h3 class=fn>bool <a name="isValid"></a>QDateTime::isValid () const
|
---|
203 | </h3>
|
---|
204 |
|
---|
205 | <p> Returns TRUE if both the date and the time are valid; otherwise
|
---|
206 | returns FALSE.
|
---|
207 | <p> <p>See also <a href="qdate.html#isValid">QDate::isValid</a>() and <a href="qtime.html#isValid">QTime::isValid</a>().
|
---|
208 |
|
---|
209 | <h3 class=fn>bool <a name="operator!-eq"></a>QDateTime::operator!= ( const <a href="qdatetime.html">QDateTime</a> & dt ) const
|
---|
210 | </h3>
|
---|
211 | Returns TRUE if this datetime is different from <em>dt</em>; otherwise
|
---|
212 | returns FALSE.
|
---|
213 | <p> <p>See also <a href="#operator-eq-eq">operator==</a>().
|
---|
214 |
|
---|
215 | <h3 class=fn>bool <a name="operator-lt"></a>QDateTime::operator< ( const <a href="qdatetime.html">QDateTime</a> & dt ) const
|
---|
216 | </h3>
|
---|
217 | Returns TRUE if this datetime is earlier than <em>dt</em>; otherwise
|
---|
218 | returns FALSE.
|
---|
219 |
|
---|
220 | <h3 class=fn>bool <a name="operator-lt-eq"></a>QDateTime::operator<= ( const <a href="qdatetime.html">QDateTime</a> & dt ) const
|
---|
221 | </h3>
|
---|
222 | Returns TRUE if this datetime is earlier than or equal to <em>dt</em>;
|
---|
223 | otherwise returns FALSE.
|
---|
224 |
|
---|
225 | <h3 class=fn>bool <a name="operator-eq-eq"></a>QDateTime::operator== ( const <a href="qdatetime.html">QDateTime</a> & dt ) const
|
---|
226 | </h3>
|
---|
227 | Returns TRUE if this datetime is equal to <em>dt</em>; otherwise returns FALSE.
|
---|
228 | <p> <p>See also <a href="#operator!-eq">operator!=</a>().
|
---|
229 |
|
---|
230 | <h3 class=fn>bool <a name="operator-gt"></a>QDateTime::operator> ( const <a href="qdatetime.html">QDateTime</a> & dt ) const
|
---|
231 | </h3>
|
---|
232 | Returns TRUE if this datetime is later than <em>dt</em>; otherwise
|
---|
233 | returns FALSE.
|
---|
234 |
|
---|
235 | <h3 class=fn>bool <a name="operator-gt-eq"></a>QDateTime::operator>= ( const <a href="qdatetime.html">QDateTime</a> & dt ) const
|
---|
236 | </h3>
|
---|
237 | Returns TRUE if this datetime is later than or equal to <em>dt</em>;
|
---|
238 | otherwise returns FALSE.
|
---|
239 |
|
---|
240 | <h3 class=fn>int <a name="secsTo"></a>QDateTime::secsTo ( const <a href="qdatetime.html">QDateTime</a> & dt ) const
|
---|
241 | </h3>
|
---|
242 | Returns the number of seconds from this datetime to <em>dt</em> (which
|
---|
243 | is negative if <em>dt</em> is earlier than this datetime).
|
---|
244 | <p> Example:
|
---|
245 | <pre>
|
---|
246 | QDateTime dt = QDateTime::<a href="#currentDateTime">currentDateTime</a>();
|
---|
247 | QDateTime xmas( QDate(dt.<a href="#date">date</a>().year(),12,24), QTime(17,00) );
|
---|
248 | <a href="qapplication.html#qDebug">qDebug</a>( "There are %d seconds to Christmas", dt.<a href="#secsTo">secsTo</a>(xmas) );
|
---|
249 | </pre>
|
---|
250 |
|
---|
251 | <p> <p>See also <a href="#addSecs">addSecs</a>(), <a href="#daysTo">daysTo</a>(), and <a href="qtime.html#secsTo">QTime::secsTo</a>().
|
---|
252 |
|
---|
253 | <h3 class=fn>void <a name="setDate"></a>QDateTime::setDate ( const <a href="qdate.html">QDate</a> & date )
|
---|
254 | </h3>
|
---|
255 |
|
---|
256 | <p> Sets the date part of this datetime to <em>date</em>.
|
---|
257 | <p> <p>See also <a href="#date">date</a>() and <a href="#setTime">setTime</a>().
|
---|
258 |
|
---|
259 | <h3 class=fn>void <a name="setTime"></a>QDateTime::setTime ( const <a href="qtime.html">QTime</a> & time )
|
---|
260 | </h3>
|
---|
261 |
|
---|
262 | <p> Sets the time part of this datetime to <em>time</em>.
|
---|
263 | <p> <p>See also <a href="#time">time</a>() and <a href="#setDate">setDate</a>().
|
---|
264 |
|
---|
265 | <h3 class=fn>void <a name="setTime_t"></a>QDateTime::setTime_t ( uint secsSince1Jan1970UTC, <a href="qt.html#TimeSpec-enum">Qt::TimeSpec</a> ts )
|
---|
266 | </h3>
|
---|
267 | Sets the date and time to <em>ts</em> time (<a href="qt.html#TimeSpec-enum">Qt::LocalTime</a> or <a href="qt.html#TimeSpec-enum">Qt::UTC</a>) given the number of seconds that have passed since
|
---|
268 | 1970-01-01T00:00:00, Coordinated Universal Time (UTC). On systems
|
---|
269 | that do not support timezones this function will behave as if
|
---|
270 | local time were UTC.
|
---|
271 | <p> On Windows, only a subset of <em>secsSince1Jan1970UTC</em> values are
|
---|
272 | supported, as Windows starts counting from 1980.
|
---|
273 | <p> <p>See also <a href="#toTime_t">toTime_t</a>().
|
---|
274 |
|
---|
275 | <h3 class=fn>void <a name="setTime_t-2"></a>QDateTime::setTime_t ( uint secsSince1Jan1970UTC )
|
---|
276 | </h3>
|
---|
277 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
278 | <p> Convenience function that sets the date and time to local time
|
---|
279 | based on the given UTC time.
|
---|
280 |
|
---|
281 | <h3 class=fn><a href="qtime.html">QTime</a> <a name="time"></a>QDateTime::time () const
|
---|
282 | </h3>
|
---|
283 |
|
---|
284 | <p> Returns the time part of the datetime.
|
---|
285 | <p> <p>See also <a href="#setTime">setTime</a>() and <a href="#date">date</a>().
|
---|
286 |
|
---|
287 | <h3 class=fn><a href="qstring.html">QString</a> <a name="toString"></a>QDateTime::toString ( const <a href="qstring.html">QString</a> & format ) const
|
---|
288 | </h3>
|
---|
289 | Returns the datetime as a string. The <em>format</em> parameter
|
---|
290 | determines the format of the result string.
|
---|
291 | <p> These expressions may be used for the date:
|
---|
292 | <p> <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
293 | <tr bgcolor="#a2c511"> <th valign="top">Expression <th valign="top">Output
|
---|
294 | <tr bgcolor="#f0f0f0"> <td valign="top">d <td valign="top">the day as number without a leading zero (1-31)
|
---|
295 | <tr bgcolor="#d0d0d0"> <td valign="top">dd <td valign="top">the day as number with a leading zero (01-31)
|
---|
296 | <tr bgcolor="#f0f0f0"> <td valign="top">ddd
|
---|
297 | <td valign="top">the abbreviated localized day name (e.g. 'Mon'..'Sun').
|
---|
298 | Uses <a href="qdate.html#shortDayName">QDate::shortDayName</a>().
|
---|
299 | <tr bgcolor="#d0d0d0"> <td valign="top">dddd
|
---|
300 | <td valign="top">the long localized day name (e.g. 'Monday'..'Sunday').
|
---|
301 | Uses <a href="qdate.html#longDayName">QDate::longDayName</a>().
|
---|
302 | <tr bgcolor="#f0f0f0"> <td valign="top">M <td valign="top">the month as number without a leading zero (1-12)
|
---|
303 | <tr bgcolor="#d0d0d0"> <td valign="top">MM <td valign="top">the month as number with a leading zero (01-12)
|
---|
304 | <tr bgcolor="#f0f0f0"> <td valign="top">MMM
|
---|
305 | <td valign="top">the abbreviated localized month name (e.g. 'Jan'..'Dec').
|
---|
306 | Uses <a href="qdate.html#shortMonthName">QDate::shortMonthName</a>().
|
---|
307 | <tr bgcolor="#d0d0d0"> <td valign="top">MMMM
|
---|
308 | <td valign="top">the long localized month name (e.g. 'January'..'December').
|
---|
309 | Uses <a href="qdate.html#longMonthName">QDate::longMonthName</a>().
|
---|
310 | <tr bgcolor="#f0f0f0"> <td valign="top">yy <td valign="top">the year as two digit number (00-99)
|
---|
311 | <tr bgcolor="#d0d0d0"> <td valign="top">yyyy <td valign="top">the year as four digit number (1752-8000)
|
---|
312 | </table></center>
|
---|
313 | <p> These expressions may be used for the time:
|
---|
314 | <p> <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
315 | <tr bgcolor="#a2c511"> <th valign="top">Expression <th valign="top">Output
|
---|
316 | <tr bgcolor="#f0f0f0"> <td valign="top">h
|
---|
317 | <td valign="top">the hour without a leading zero (0..23 or 1..12 if AM/PM display)
|
---|
318 | <tr bgcolor="#d0d0d0"> <td valign="top">hh
|
---|
319 | <td valign="top">the hour with a leading zero (00..23 or 01..12 if AM/PM display)
|
---|
320 | <tr bgcolor="#f0f0f0"> <td valign="top">m <td valign="top">the minute without a leading zero (0..59)
|
---|
321 | <tr bgcolor="#d0d0d0"> <td valign="top">mm <td valign="top">the minute with a leading zero (00..59)
|
---|
322 | <tr bgcolor="#f0f0f0"> <td valign="top">s <td valign="top">the second whithout a leading zero (0..59)
|
---|
323 | <tr bgcolor="#d0d0d0"> <td valign="top">ss <td valign="top">the second whith a leading zero (00..59)
|
---|
324 | <tr bgcolor="#f0f0f0"> <td valign="top">z <td valign="top">the milliseconds without leading zeroes (0..999)
|
---|
325 | <tr bgcolor="#d0d0d0"> <td valign="top">zzz <td valign="top">the milliseconds with leading zeroes (000..999)
|
---|
326 | <tr bgcolor="#f0f0f0"> <td valign="top">AP
|
---|
327 | <td valign="top">use AM/PM display. <em>AP</em> will be replaced by either "AM" or "PM".
|
---|
328 | <tr bgcolor="#d0d0d0"> <td valign="top">ap
|
---|
329 | <td valign="top">use am/pm display. <em>ap</em> will be replaced by either "am" or "pm".
|
---|
330 | </table></center>
|
---|
331 | <p> All other input characters will be ignored.
|
---|
332 | <p> Example format strings (assumed that the QDateTime is
|
---|
333 | 21<small><sup>st</sup></small> May 2001 14:13:09)
|
---|
334 | <p> <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
335 | <tr bgcolor="#a2c511"> <th valign="top">Format <th valign="top">Result
|
---|
336 | <tr bgcolor="#f0f0f0"> <td valign="top">dd.MM.yyyy <td valign="top" colspan="1" rowspan="1"> 21.05.2001
|
---|
337 | <tr bgcolor="#d0d0d0"> <td valign="top">ddd MMMM d yy <td valign="top" colspan="1" rowspan="1"> Tue May 21 01
|
---|
338 | <tr bgcolor="#f0f0f0"> <td valign="top">hh:mm:ss.zzz <td valign="top" colspan="1" rowspan="1"> 14:13:09.042
|
---|
339 | <tr bgcolor="#d0d0d0"> <td valign="top">h:m:s ap <td valign="top" colspan="1" rowspan="1"> 2:13:9 pm
|
---|
340 | </table></center>
|
---|
341 | <p> If the datetime is an invalid datetime, then <a href="qstring.html#QString-null">QString::null</a> will be returned.
|
---|
342 | <p> <p>See also <a href="qdate.html#toString">QDate::toString</a>() and <a href="qtime.html#toString">QTime::toString</a>().
|
---|
343 |
|
---|
344 | <h3 class=fn><a href="qstring.html">QString</a> <a name="toString-2"></a>QDateTime::toString ( <a href="qt.html#DateFormat-enum">Qt::DateFormat</a> f = Qt::TextDate ) const
|
---|
345 | </h3>
|
---|
346 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
347 | <p> Returns the datetime as a string. The <em>f</em> parameter determines
|
---|
348 | the format of the string.
|
---|
349 | <p> If <em>f</em> is <a href="qt.html#DateFormat-enum">Qt::TextDate</a>, the string format is "Wed May 20
|
---|
350 | 03:40:13 1998" (using <a href="qdate.html#shortDayName">QDate::shortDayName</a>(), <a href="qdate.html#shortMonthName">QDate::shortMonthName</a>(),
|
---|
351 | and <a href="qtime.html#toString">QTime::toString</a>() to generate the string, so the day and month
|
---|
352 | names will have localized names).
|
---|
353 | <p> If <em>f</em> is <a href="qt.html#DateFormat-enum">Qt::ISODate</a>, the string format corresponds to the
|
---|
354 | ISO 8601 extended specification for representations of dates and
|
---|
355 | times, which is YYYY-MM-DDTHH:MM:SS.
|
---|
356 | <p> If <em>f</em> is <a href="qt.html#DateFormat-enum">Qt::LocalDate</a>, the string format depends on the
|
---|
357 | locale settings of the system.
|
---|
358 | <p> If the format <em>f</em> is invalid or the datetime is invalid, <a href="#toString">toString</a>()
|
---|
359 | returns a null string.
|
---|
360 | <p> <p>See also <a href="qdate.html#toString">QDate::toString</a>() and <a href="qtime.html#toString">QTime::toString</a>().
|
---|
361 |
|
---|
362 | <h3 class=fn>uint <a name="toTime_t"></a>QDateTime::toTime_t () const
|
---|
363 | </h3>
|
---|
364 | Returns the datetime as the number of seconds that have passed
|
---|
365 | since 1970-01-01T00:00:00, Coordinated Universal Time (UTC).
|
---|
366 | <p> On systems that do not support timezones, this function will
|
---|
367 | behave as if local time were UTC.
|
---|
368 | <p> <p>See also <a href="#setTime_t">setTime_t</a>().
|
---|
369 |
|
---|
370 | <hr><h2>Related Functions</h2>
|
---|
371 | <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="qdatetime.html">QDateTime</a> & dt )
|
---|
372 | </h3>
|
---|
373 |
|
---|
374 | <p> Writes the datetime <em>dt</em> to the stream <em>s</em>.
|
---|
375 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
376 |
|
---|
377 | <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="qdatetime.html">QDateTime</a> & dt )
|
---|
378 | </h3>
|
---|
379 |
|
---|
380 | <p> Reads a datetime from the stream <em>s</em> into <em>dt</em>.
|
---|
381 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
382 |
|
---|
383 | <!-- eof -->
|
---|
384 | <hr><p>
|
---|
385 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
386 | Copyright © 1995-2007
|
---|
387 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
388 | <table width=100% cellspacing=0 border=0><tr>
|
---|
389 | <td>Copyright © 2007
|
---|
390 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
391 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
392 | </table></div></address></body>
|
---|
393 | </html>
|
---|