File: qdatetime.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (375 lines) | stat: -rw-r--r-- 32,962 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDateTime Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDateTime Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QDateTime class provides date and time functions. <a href="#details">More...</a></p>
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdatetime.html#QDateTime">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdatetime.html#QDateTime-2">__init__</a></b> (<i>self</i>, QDate)</li><li><div class="fn" /><b><a href="qdatetime.html#QDateTime-3">__init__</a></b> (<i>self</i>, QDate, QTime, Qt.TimeSpec&#160;<i>spec</i>&#160;=&#160;Qt.LocalTime)</li><li><div class="fn" /><b><a href="qdatetime.html#QDateTime-4">__init__</a></b> (<i>self</i>, QDateTime&#160;<i>other</i>)</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#addDays">addDays</a></b> (<i>self</i>, int&#160;<i>days</i>)</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#addMonths">addMonths</a></b> (<i>self</i>, int&#160;<i>months</i>)</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#addMSecs">addMSecs</a></b> (<i>self</i>, long&#160;<i>msecs</i>)</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#addSecs">addSecs</a></b> (<i>self</i>, int&#160;<i>secs</i>)</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#addYears">addYears</a></b> (<i>self</i>, int&#160;<i>years</i>)</li><li><div class="fn" />QDate <b><a href="qdatetime.html#date">date</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qdatetime.html#daysTo">daysTo</a></b> (<i>self</i>, QDateTime)</li><li><div class="fn" />bool <b><a href="qdatetime.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdatetime.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qdatetime.html#secsTo">secsTo</a></b> (<i>self</i>, QDateTime)</li><li><div class="fn" /><b><a href="qdatetime.html#setDate">setDate</a></b> (<i>self</i>, QDate&#160;<i>date</i>)</li><li><div class="fn" /><b><a href="qdatetime.html#setTime">setTime</a></b> (<i>self</i>, QTime&#160;<i>time</i>)</li><li><div class="fn" /><b><a href="qdatetime.html#setTime_t">setTime_t</a></b> (<i>self</i>, unsigned long&#160;<i>secsSince1Jan1970UTC</i>)</li><li><div class="fn" /><b><a href="qdatetime.html#setTimeSpec">setTimeSpec</a></b> (<i>self</i>, Qt.TimeSpec&#160;<i>spec</i>)</li><li><div class="fn" />QTime <b><a href="qdatetime.html#time">time</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.TimeSpec <b><a href="qdatetime.html#timeSpec">timeSpec</a></b> (<i>self</i>)</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#toLocalTime">toLocalTime</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdatetime.html#toString">toString</a></b> (<i>self</i>, Qt.DateFormat&#160;<i>f</i>&#160;=&#160;Qt.TextDate)</li><li><div class="fn" />QString <b><a href="qdatetime.html#toString-2">toString</a></b> (<i>self</i>, QString&#160;<i>format</i>)</li><li><div class="fn" />unsigned long <b><a href="qdatetime.html#toTime_t">toTime_t</a></b> (<i>self</i>)</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#toTimeSpec">toTimeSpec</a></b> (<i>self</i>, Qt.TimeSpec&#160;<i>spec</i>)</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#toUTC">toUTC</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QDateTime <b><a href="qdatetime.html#currentDateTime">currentDateTime</a></b> ()</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#fromString">fromString</a></b> (QString&#160;<i>s</i>, Qt.DateFormat&#160;<i>f</i>&#160;=&#160;Qt.TextDate)</li><li><div class="fn" />QDateTime <b><a href="qdatetime.html#fromString-2">fromString</a></b> (QString&#160;<i>s</i>, QString&#160;<i>format</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qdatetime.html#__eq__">__eq__</a></b> (<i>self</i>, QDateTime&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qdatetime.html#__ge__">__ge__</a></b> (<i>self</i>, QDateTime&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qdatetime.html#__gt__">__gt__</a></b> (<i>self</i>, QDateTime&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qdatetime.html#__le__">__le__</a></b> (<i>self</i>, QDateTime&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qdatetime.html#__lt__">__lt__</a></b> (<i>self</i>, QDateTime&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qdatetime.html#__ne__">__ne__</a></b> (<i>self</i>, QDateTime&#160;<i>other</i>)</li><li><div class="fn" />int <b><a href="qdatetime.html#__nonzero__">__nonzero__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDateTime class provides date and time functions.</p>
<p>A QDateTime object contains a calendar date and a clock time (a "datetime"). It is a combination of the <a href="qdate.html">QDate</a> and <a href="qtime.html">QTime</a> classes. It can read the current datetime from the system clock. It provides functions for comparing datetimes and for manipulating a datetime by adding a number of seconds, days, months, or years.</p>
<p>A QDateTime object is typically created either by giving a date and time explicitly in the constructor, or by using the static function <a href="qdatetime.html#currentDateTime">currentDateTime</a>() that returns a QDateTime object set to the system clock's time. The date and time can be changed with <a href="qdatetime.html#setDate">setDate</a>() and <a href="qdatetime.html#setTime">setTime</a>(). A datetime can also be set using the <a href="qdatetime.html#setTime_t">setTime_t</a>() function that takes a POSIX-standard "number of seconds since 00:00:00 on January 1, 1970" value. The <a href="qdatetime.html#fromString">fromString</a>() function returns a QDateTime, given a string and a date format used to interpret the date within the string.</p>
<p>The <a href="qdatetime.html#date">date</a>() and <a href="qdatetime.html#time">time</a>() functions provide access to the date and time parts of the datetime. The same information is provided in textual format by the <a href="qdatetime.html#toString">toString</a>() function.</p>
<p>QDateTime provides a full set of operators to compare two QDateTime objects where smaller means earlier and larger means later.</p>
<p>You can increment (or decrement) a datetime by a given number of seconds using <a href="qdatetime.html#addSecs">addSecs</a>(), or days using <a href="qdatetime.html#addDays">addDays</a>(). Similarly you can use <a href="qdatetime.html#addMonths">addMonths</a>() and <a href="qdatetime.html#addYears">addYears</a>(). The <a href="qdatetime.html#daysTo">daysTo</a>() function returns the number of days between two datetimes, and <a href="qdatetime.html#secsTo">secsTo</a>() returns the number of seconds between two datetimes.</p>
<p>QDateTime can store datetimes as <a href="qt.html#TimeSpec-enum">local time</a> or as <a href="qt.html#TimeSpec-enum">UTC</a>. <a href="qdatetime.html#currentDateTime">QDateTime.currentDateTime</a>() returns a QDateTime expressed as local time; use <a href="qdatetime.html#toUTC">toUTC</a>() to convert it to UTC. You can also use <a href="qdatetime.html#timeSpec">timeSpec</a>() to find out if a QDateTime object stores a UTC time or a local time. Operations such as <a href="qdatetime.html#addSecs">addSecs</a>() and <a href="qdatetime.html#secsTo">secsTo</a>() are aware of daylight saving time (DST).</p>
<p>See also <a href="qdate.html">QDate</a>, <a href="qtime.html">QTime</a>, and <a href="qdatetimeedit.html">QDateTimeEdit</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDateTime" />QDateTime.__init__ (<i>self</i>)</h3><p>Constructs a null datetime (i.e. null date and null time). A null datetime is invalid, since the date is invalid.</p>
<p>See also <a href="qdatetime.html#isValid">isValid</a>().</p>
<h3 class="fn"><a name="QDateTime-2" />QDateTime.__init__ (<i>self</i>, <a href="qdate.html">QDate</a>)</h3><p>Constructs a datetime with the given <i>date</i>, and a valid time (00:00:00.000).</p>
<h3 class="fn"><a name="QDateTime-3" />QDateTime.__init__ (<i>self</i>, <a href="qdate.html">QDate</a>, <a href="qtime.html">QTime</a>, <a href="qt.html#TimeSpec-enum">Qt.TimeSpec</a>&#160;<i>spec</i>&#160;=&#160;Qt.LocalTime)</h3><p>Constructs a datetime with the given <i>date</i> and <i>time</i>, using the time specification defined by <i>spec</i>.</p>
<p>If <i>date</i> is valid and <i>time</i> is not, the time will be set to midnight.</p>
<h3 class="fn"><a name="QDateTime-4" />QDateTime.__init__ (<i>self</i>, <a href="qdatetime.html">QDateTime</a>&#160;<i>other</i>)</h3><p>Constructs a copy of the <i>other</i> datetime.</p>
<h3 class="fn"><a name="addDays" /><a href="qdatetime.html">QDateTime</a> QDateTime.addDays (<i>self</i>, int&#160;<i>days</i>)</h3><p>Returns a <a href="qdatetime.html">QDateTime</a> object containing a datetime <i>ndays</i> days later than the datetime of this object (or earlier if <i>ndays</i> is negative).</p>
<p>See also <a href="qdatetime.html#daysTo">daysTo</a>(), <a href="qdatetime.html#addMonths">addMonths</a>(), <a href="qdatetime.html#addYears">addYears</a>(), and <a href="qdatetime.html#addSecs">addSecs</a>().</p>
<h3 class="fn"><a name="addMonths" /><a href="qdatetime.html">QDateTime</a> QDateTime.addMonths (<i>self</i>, int&#160;<i>months</i>)</h3><p>Returns a <a href="qdatetime.html">QDateTime</a> object containing a datetime <i>nmonths</i> months later than the datetime of this object (or earlier if <i>nmonths</i> is negative).</p>
<p>See also <a href="qdatetime.html#daysTo">daysTo</a>(), <a href="qdatetime.html#addDays">addDays</a>(), <a href="qdatetime.html#addYears">addYears</a>(), and <a href="qdatetime.html#addSecs">addSecs</a>().</p>
<h3 class="fn"><a name="addMSecs" /><a href="qdatetime.html">QDateTime</a> QDateTime.addMSecs (<i>self</i>, long&#160;<i>msecs</i>)</h3><p>Returns a <a href="qdatetime.html">QDateTime</a> object containing a datetime <i>msecs</i> miliseconds later than the datetime of this object (or earlier if <i>msecs</i> is negative).</p>
<p>See also <a href="qdatetime.html#addSecs">addSecs</a>(), <a href="qdatetime.html#secsTo">secsTo</a>(), <a href="qdatetime.html#addDays">addDays</a>(), <a href="qdatetime.html#addMonths">addMonths</a>(), and <a href="qdatetime.html#addYears">addYears</a>().</p>
<h3 class="fn"><a name="addSecs" /><a href="qdatetime.html">QDateTime</a> QDateTime.addSecs (<i>self</i>, int&#160;<i>secs</i>)</h3><p>Returns a <a href="qdatetime.html">QDateTime</a> object containing a datetime <i>nsecs</i> seconds later than the datetime of this object (or earlier if <i>nsecs</i> is negative).</p>
<p>See also <a href="qdatetime.html#addMSecs">addMSecs</a>(), <a href="qdatetime.html#secsTo">secsTo</a>(), <a href="qdatetime.html#addDays">addDays</a>(), <a href="qdatetime.html#addMonths">addMonths</a>(), and <a href="qdatetime.html#addYears">addYears</a>().</p>
<h3 class="fn"><a name="addYears" /><a href="qdatetime.html">QDateTime</a> QDateTime.addYears (<i>self</i>, int&#160;<i>years</i>)</h3><p>Returns a <a href="qdatetime.html">QDateTime</a> object containing a datetime <i>nyears</i> years later than the datetime of this object (or earlier if <i>nyears</i> is negative).</p>
<p>See also <a href="qdatetime.html#daysTo">daysTo</a>(), <a href="qdatetime.html#addDays">addDays</a>(), <a href="qdatetime.html#addMonths">addMonths</a>(), and <a href="qdatetime.html#addSecs">addSecs</a>().</p>
<h3 class="fn"><a name="currentDateTime" /><a href="qdatetime.html">QDateTime</a> QDateTime.currentDateTime ()</h3><p>Returns the current datetime, as reported by the system clock, in the local time zone.</p>
<p>See also <a href="qdate-qt3.html#currentDate">QDate.currentDate</a>(), <a href="qtime-qt3.html#currentTime">QTime.currentTime</a>(), and <a href="qdatetime.html#toTimeSpec">toTimeSpec</a>().</p>
<h3 class="fn"><a name="date" /><a href="qdate.html">QDate</a> QDateTime.date (<i>self</i>)</h3><p>Returns the date part of the datetime.</p>
<p>See also <a href="qdatetime.html#setDate">setDate</a>(), <a href="qdatetime.html#time">time</a>(), and <a href="qdatetime.html#timeSpec">timeSpec</a>().</p>
<h3 class="fn"><a name="daysTo" />int QDateTime.daysTo (<i>self</i>, <a href="qdatetime.html">QDateTime</a>)</h3><p>Returns the number of days from this datetime to the <i>other</i> datetime. If the <i>other</i> datetime is earlier than this datetime, the value returned is negative.</p>
<p>See also <a href="qdatetime.html#addDays">addDays</a>() and <a href="qdatetime.html#secsTo">secsTo</a>().</p>
<h3 class="fn"><a name="fromString" /><a href="qdatetime.html">QDateTime</a> QDateTime.fromString (<a href="qstring.html">QString</a>&#160;<i>s</i>, <a href="qt.html#DateFormat-enum">Qt.DateFormat</a>&#160;<i>f</i>&#160;=&#160;Qt.TextDate)</h3><p>Returns the <a href="qdatetime.html">QDateTime</a> represented by the <i>string</i>, using the <i>format</i> given, or an invalid datetime if this is not possible.</p>
<p>Note for <a href="qt.html#DateFormat-enum">Qt.TextDate</a>: It is recommended that you use the English short month names (e.g. "Jan"). Although localized month names can also be used, they depend on the user's locale settings.</p>
<p><b>Warning:</b> Note that <a href="qt.html#DateFormat-enum">Qt.LocalDate</a> cannot be used here.</p>
<h3 class="fn"><a name="fromString-2" /><a href="qdatetime.html">QDateTime</a> QDateTime.fromString (<a href="qstring.html">QString</a>&#160;<i>s</i>, <a href="qstring.html">QString</a>&#160;<i>format</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the <a href="qdatetime.html">QDateTime</a> represented by the <i>string</i>, using the <i>format</i> given, or an invalid datetime if the string cannot be parsed.</p>
<p>These expressions may be used for the date part of the format string:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#A2C511" valign="top">
<th>Expression</th>
<th>Output</th>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>d</td>
<td>the day as number without a leading zero (1 to 31)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>dd</td>
<td>the day as number with a leading zero (01 to 31)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<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>
<tr bgcolor="#E0E0E0" valign="top">
<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>
<tr bgcolor="#F0F0F0" valign="top">
<td>M</td>
<td>the month as number without a leading zero (1-12)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>MM</td>
<td>the month as number with a leading zero (01-12)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<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>
<tr bgcolor="#E0E0E0" valign="top">
<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>
<tr bgcolor="#F0F0F0" valign="top">
<td>yy</td>
<td>the year as two digit number (00-99)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>yyyy</td>
<td>the year as four digit number (1752-8000)</td>
</tr>
</table>
<br />
<br />
<p>These expressions may be used for the time part of the format string:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#A2C511" valign="top">
<th>Expression</th>
<th>Output</th>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>h</td>
<td>the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>hh</td>
<td>the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>H</td>
<td>the hour without a leading zero (0 to 23, even with AM/PM display)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>HH</td>
<td>the hour with a leading zero (00 to 23, even with AM/PM display)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>m</td>
<td>the minute without a leading zero (0 to 59)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>mm</td>
<td>the minute with a leading zero (00 to 59)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>s</td>
<td>the second whithout a leading zero (0 to 59)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>ss</td>
<td>the second whith a leading zero (00 to 59)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>z</td>
<td>the milliseconds without leading zeroes (0 to 999)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>zzz</td>
<td>the milliseconds with leading zeroes (000 to 999)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>AP or A</td>
<td>interpret as an AM/PM time. <i>AP</i> must be either "AM" or "PM".</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>ap or a</td>
<td>Interpret as an AM/PM time. <i>ap</i> must be either "am" or "pm".</td>
</tr>
</table>
<br />
<br />
<p>All other input characters will be treated as text. Any sequence of characters that are enclosed in singlequotes will also be treated as text and not be used as an expression.</p>
<pre>
    QTime time1 = QTime.fromString("131", "HHh");
    // time1 is 13:00:00
    QTime time1 = QTime.fromString("1apA", "1amAM");
    // time1 is 01:00:00

    QDateTime dateTime2 = QDateTime.fromString("M1d1y9800:01:02",
                                                "'M'M'd'd'y'yyhh:mm:ss");
    // dateTime is 1 January 1998 00:01:02
</pre>
<p>If the format is not satisfied an invalid <a href="qdatetime.html">QDateTime</a> is returned. The expressions that don't have leading zeroes (d, M, h, m, s, z) will be greedy. This means that they will use two digits even if this will put them outside the range and/or leave too few digits for other sections.</p>
<pre>
    QDateTime dateTime = QDateTime.fromString("130", "Mm"); // invalid
</pre>
<p>This could have meant 1 January 00:30.00 but the M will grab two digits.</p>
<p>For any field that is not represented in the format the following defaults are used:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#A2C511" valign="top">
<th>Field</th>
<th>Default value</th>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>Year</td>
<td>1900</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>Month</td>
<td>1 (January)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>Day</td>
<td>1</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>Hour</td>
<td>0</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>Minute</td>
<td>0</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>Second</td>
<td>0</td>
</tr>
</table>
<br />
<br />
<p>For example:</p>
<pre>
    QDateTime dateTime = QDateTime.fromString("1.30.1", "M.d.s");
    // dateTime is January 30 in the current year 00:00:01
</pre>
<p><a href="qdatetime.html#toString">QDateTime.toString</a>() <a href="qtime.html#toString">QTime.toString</a>()</p>
<p>See also <a href="qdate.html#fromString">QDate.fromString</a>(), <a href="qtime.html#fromString">QTime.fromString</a>(), and <a href="qdate.html#toString">QDate.toString</a>().</p>
<h3 class="fn"><a name="isNull" />bool QDateTime.isNull (<i>self</i>)</h3><p>Returns true if both the date and the time are null; otherwise returns false. A null datetime is invalid.</p>
<p>See also <a href="qdate.html#isNull">QDate.isNull</a>(), <a href="qtime.html#isNull">QTime.isNull</a>(), and <a href="qdatetime.html#isValid">isValid</a>().</p>
<h3 class="fn"><a name="isValid" />bool QDateTime.isValid (<i>self</i>)</h3><p>Returns true if both the date and the time are valid; otherwise returns false.</p>
<p>See also <a href="qdate.html#isValid">QDate.isValid</a>() and <a href="qtime.html#isValid">QTime.isValid</a>().</p>
<h3 class="fn"><a name="secsTo" />int QDateTime.secsTo (<i>self</i>, <a href="qdatetime.html">QDateTime</a>)</h3><p>Returns the number of seconds from this datetime to the <i>other</i> datetime. If the <i>other</i> datetime is earlier than this datetime, the value returned is negative.</p>
<p>Before performing the comparison, the two datetimes are converted to <a href="qt.html#TimeSpec-enum">Qt.UTC</a> to ensure that the result is correct if one of the two datetimes has daylight saving time (DST) and the other doesn't.</p>
<p>Example:</p>
<pre>
    QDateTime now = QDateTime.currentDateTime();
    QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0));
    qDebug("There are %d seconds to Christmas", now.secsTo(xmas));
</pre>
<p>See also <a href="qdatetime.html#addSecs">addSecs</a>(), <a href="qdatetime.html#daysTo">daysTo</a>(), and <a href="qtime.html#secsTo">QTime.secsTo</a>().</p>
<h3 class="fn"><a name="setDate" />QDateTime.setDate (<i>self</i>, <a href="qdate.html">QDate</a>&#160;<i>date</i>)</h3><p>Sets the date part of this datetime to <i>date</i>. If no time is set, it is set to midnight.</p>
<p>See also <a href="qdatetime.html#date">date</a>(), <a href="qdatetime.html#setTime">setTime</a>(), and <a href="qdatetime.html#setTimeSpec">setTimeSpec</a>().</p>
<h3 class="fn"><a name="setTime" />QDateTime.setTime (<i>self</i>, <a href="qtime.html">QTime</a>&#160;<i>time</i>)</h3><p>Sets the time part of this datetime to <i>time</i>.</p>
<p>See also <a href="qdatetime.html#time">time</a>(), <a href="qdatetime.html#setDate">setDate</a>(), and <a href="qdatetime.html#setTimeSpec">setTimeSpec</a>().</p>
<h3 class="fn"><a name="setTime_t" />QDateTime.setTime_t (<i>self</i>, unsigned long&#160;<i>secsSince1Jan1970UTC</i>)</h3><p>Sets the date and time given the number of <i>seconds</i> that have passed since 1970-01-01T00:00:00, Coordinated Universal Time (<a href="qt.html#TimeSpec-enum">Qt.UTC</a>). On systems that do not support timezones this function will behave as if local time were <a href="qt.html#TimeSpec-enum">Qt.UTC</a>.</p>
<p>See also <a href="qdatetime.html#toTime_t">toTime_t</a>().</p>
<h3 class="fn"><a name="setTimeSpec" />QDateTime.setTimeSpec (<i>self</i>, <a href="qt.html#TimeSpec-enum">Qt.TimeSpec</a>&#160;<i>spec</i>)</h3><p>Sets the time specification used in this datetime to <i>spec</i>.</p>
<p>See also <a href="qdatetime.html#timeSpec">timeSpec</a>(), <a href="qdatetime.html#setDate">setDate</a>(), <a href="qdatetime.html#setTime">setTime</a>(), and <a href="qt.html#TimeSpec-enum">Qt.TimeSpec</a>.</p>
<h3 class="fn"><a name="time" /><a href="qtime.html">QTime</a> QDateTime.time (<i>self</i>)</h3><p>Returns the time part of the datetime.</p>
<p>See also <a href="qdatetime.html#setTime">setTime</a>(), <a href="qdatetime.html#date">date</a>(), and <a href="qdatetime.html#timeSpec">timeSpec</a>().</p>
<h3 class="fn"><a name="timeSpec" /><a href="qt.html#TimeSpec-enum">Qt.TimeSpec</a> QDateTime.timeSpec (<i>self</i>)</h3><p>Returns the time specification of the datetime.</p>
<p>See also <a href="qdatetime.html#setTimeSpec">setTimeSpec</a>(), <a href="qdatetime.html#date">date</a>(), <a href="qdatetime.html#time">time</a>(), and <a href="qt.html#TimeSpec-enum">Qt.TimeSpec</a>.</p>
<h3 class="fn"><a name="toLocalTime" /><a href="qdatetime.html">QDateTime</a> QDateTime.toLocalTime (<i>self</i>)</h3><p>Returns a datetime containing the date and time information in this datetime, but specified using the <a href="qt.html#TimeSpec-enum">Qt.LocalTime</a> definition.</p>
<p>See also <a href="qdatetime.html#toTimeSpec">toTimeSpec</a>().</p>
<h3 class="fn"><a name="toString" /><a href="qstring.html">QString</a> QDateTime.toString (<i>self</i>, <a href="qt.html#DateFormat-enum">Qt.DateFormat</a>&#160;<i>f</i>&#160;=&#160;Qt.TextDate)</h3><p>Returns the datetime as a string. The <i>format</i> parameter determines the format of the result string.</p>
<p>These expressions may be used for the date:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#A2C511" valign="top">
<th>Expression</th>
<th>Output</th>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>d</td>
<td>the day as number without a leading zero (1 to 31)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>dd</td>
<td>the day as number with a leading zero (01 to 31)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<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>
<tr bgcolor="#E0E0E0" valign="top">
<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>
<tr bgcolor="#F0F0F0" valign="top">
<td>M</td>
<td>the month as number without a leading zero (1-12)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>MM</td>
<td>the month as number with a leading zero (01-12)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<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>
<tr bgcolor="#E0E0E0" valign="top">
<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>
<tr bgcolor="#F0F0F0" valign="top">
<td>yy</td>
<td>the year as two digit number (00-99)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>yyyy</td>
<td>the year as four digit number (1752-8000)</td>
</tr>
</table>
<br />
<br />
<p>These expressions may be used for the time:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#A2C511" valign="top">
<th>Expression</th>
<th>Output</th>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>h</td>
<td>the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>hh</td>
<td>the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>m</td>
<td>the minute without a leading zero (0 to 59)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>mm</td>
<td>the minute with a leading zero (00 to 59)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>s</td>
<td>the second whithout a leading zero (0 to 59)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>ss</td>
<td>the second whith a leading zero (00 to 59)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>z</td>
<td>the milliseconds without leading zeroes (0 to 999)</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>zzz</td>
<td>the milliseconds with leading zeroes (000 to 999)</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>AP</td>
<td>use AM/PM display. <i>AP</i> will be replaced by either "AM" or "PM".</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>ap</td>
<td>use am/pm display. <i>ap</i> will be replaced by either "am" or "pm".</td>
</tr>
</table>
<br />
<br />
<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>
<p>Example format strings (assumed that the <a href="qdatetime.html">QDateTime</a> is 21 May 2001 14:13:09):</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#A2C511" valign="top">
<th>Format</th>
<th>Result</th>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>dd.MM.yyyy</td>
<td>21.05.2001</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>ddd MMMM d yy</td>
<td>Tue May 21 01</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>hh:mm:ss.zzz</td>
<td>14:13:09.042</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>h:m:s ap</td>
<td>2:13:9 pm</td>
</tr>
</table>
<br />
<br />
<p>If the datetime is invalid, an empty string will be returned.</p>
<p>See also <a href="qdate.html#toString">QDate.toString</a>() and <a href="qtime.html#toString">QTime.toString</a>().</p>
<h3 class="fn"><a name="toString-2" /><a href="qstring.html">QString</a> QDateTime.toString (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>format</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the datetime as a string in the <i>format</i> given.</p>
<p>If the <i>format</i> is <a href="qt.html#DateFormat-enum">Qt.TextDate</a>, the string is formatted in the default way. <a href="qdate.html#shortDayName">QDate.shortDayName</a>(), <a href="qdate.html#shortMonthName">QDate.shortMonthName</a>(), and <a href="qtime.html#toString">QTime.toString</a>() are used to generate the string, so the day and month names will be localized names. An example of this formatting is "Wed May 20 03:40:13 1998".</p>
<p>If the <i>format</i> is <a href="qt.html#DateFormat-enum">Qt.ISODate</a>, the string format corresponds to the ISO 8601 extended specification for representations of dates and times, taking the form YYYY-MM-DDTHH:MM:SS.</p>
<p>If the <i>format</i> is <a href="qt.html#DateFormat-enum">Qt.LocalDate</a>, the string format depends on the locale settings of the system.</p>
<p>If the datetime is invalid, an empty string will be returned.</p>
<p>See also <a href="qdate.html#toString">QDate.toString</a>(), <a href="qtime.html#toString">QTime.toString</a>(), and <a href="qt.html#DateFormat-enum">Qt.DateFormat</a>.</p>
<h3 class="fn"><a name="toTime_t" />unsigned long QDateTime.toTime_t (<i>self</i>)</h3><p>Returns the datetime as the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time (<a href="qt.html#TimeSpec-enum">Qt.UTC</a>).</p>
<p>On systems that do not support timezones, this function will behave as if local time were <a href="qt.html#TimeSpec-enum">Qt.UTC</a>.</p>
<p>See also <a href="qdatetime.html#setTime_t">setTime_t</a>().</p>
<h3 class="fn"><a name="toTimeSpec" /><a href="qdatetime.html">QDateTime</a> QDateTime.toTimeSpec (<i>self</i>, <a href="qt.html#TimeSpec-enum">Qt.TimeSpec</a>&#160;<i>spec</i>)</h3><p>Returns a copy of this datetime configured to use the given time <i>specification</i>.</p>
<p>See also <a href="qdatetime.html#timeSpec">timeSpec</a>(), <a href="qdatetime.html#toUTC">toUTC</a>(), and <a href="qdatetime.html#toLocalTime">toLocalTime</a>().</p>
<h3 class="fn"><a name="toUTC" /><a href="qdatetime.html">QDateTime</a> QDateTime.toUTC (<i>self</i>)</h3><p>Returns a datetime containing the date and time information in this datetime, but specified using the <a href="qt.html#TimeSpec-enum">Qt.UTC</a> definition.</p>
<p>See also <a href="qdatetime.html#toTimeSpec">toTimeSpec</a>().</p>
<h3 class="fn"><a name="__eq__" />bool QDateTime.__eq__ (<i>self</i>, <a href="qdatetime.html">QDateTime</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__ge__" />bool QDateTime.__ge__ (<i>self</i>, <a href="qdatetime.html">QDateTime</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__gt__" />bool QDateTime.__gt__ (<i>self</i>, <a href="qdatetime.html">QDateTime</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__le__" />bool QDateTime.__le__ (<i>self</i>, <a href="qdatetime.html">QDateTime</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__lt__" />bool QDateTime.__lt__ (<i>self</i>, <a href="qdatetime.html">QDateTime</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__ne__" />bool QDateTime.__ne__ (<i>self</i>, <a href="qdatetime.html">QDateTime</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__nonzero__" />int QDateTime.__nonzero__ (<i>self</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>