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/include/qdatetime.h:1 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>qdatetime.h Include File</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.h</h1>
|
---|
33 |
|
---|
34 | <p>This is the verbatim text of the qdatetime.h include file. It is provided only for illustration; the copyright remains with Trolltech.
|
---|
35 | <hr>
|
---|
36 | <pre>
|
---|
37 | /*************************************************************************
|
---|
38 | ** $Id: qdatetime-h.html 2051 2007-02-21 10:04:20Z chehrlic $
|
---|
39 | **
|
---|
40 | ** Definition of date and time classes
|
---|
41 | **
|
---|
42 | ** Created : 940124
|
---|
43 | **
|
---|
44 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
|
---|
45 | **
|
---|
46 | ** This file is part of the tools module of the Qt GUI Toolkit.
|
---|
47 | **
|
---|
48 | ** This file may be distributed under the terms of the Q Public License
|
---|
49 | ** as defined by Trolltech ASA of Norway and appearing in the file
|
---|
50 | ** LICENSE.QPL included in the packaging of this file.
|
---|
51 | **
|
---|
52 | ** This file may be distributed and/or modified under the terms of the
|
---|
53 | ** GNU General Public License version 2 as published by the Free Software
|
---|
54 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
55 | ** packaging of this file.
|
---|
56 | **
|
---|
57 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
58 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
59 | ** Agreement provided with the Software.
|
---|
60 | **
|
---|
61 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
62 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
63 | **
|
---|
64 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
65 | ** information about Qt Commercial License Agreements.
|
---|
66 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
67 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
68 | **
|
---|
69 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
70 | ** not clear to you.
|
---|
71 | **
|
---|
72 | **********************************************************************/
|
---|
73 |
|
---|
74 | #ifndef QDATETIME_H
|
---|
75 | #define QDATETIME_H
|
---|
76 |
|
---|
77 | #ifndef QT_H
|
---|
78 | #include "qstring.h"
|
---|
79 | #include "qnamespace.h"
|
---|
80 | #endif // QT_H
|
---|
81 |
|
---|
82 |
|
---|
83 | /*****************************************************************************
|
---|
84 | QDate class
|
---|
85 | *****************************************************************************/
|
---|
86 |
|
---|
87 | class Q_EXPORT QDate
|
---|
88 | {
|
---|
89 | public:
|
---|
90 | QDate() { jd = 0; }
|
---|
91 | QDate( int y, int m, int d );
|
---|
92 |
|
---|
93 | bool isNull() const { return jd == 0; }
|
---|
94 | bool isValid() const;
|
---|
95 |
|
---|
96 | int year() const;
|
---|
97 | int month() const;
|
---|
98 | int day() const;
|
---|
99 | int dayOfWeek() const;
|
---|
100 | int dayOfYear() const;
|
---|
101 | int daysInMonth() const;
|
---|
102 | int daysInYear() const;
|
---|
103 | int weekNumber( int *yearNum = 0 ) const;
|
---|
104 |
|
---|
105 | #ifndef QT_NO_TEXTDATE
|
---|
106 | #ifndef QT_NO_COMPAT
|
---|
107 | static QString monthName( int month ) { return shortMonthName( month ); }
|
---|
108 | static QString dayName( int weekday ) { return shortDayName( weekday ); }
|
---|
109 | #endif
|
---|
110 | static QString shortMonthName( int month );
|
---|
111 | static QString shortDayName( int weekday );
|
---|
112 | static QString longMonthName( int month );
|
---|
113 | static QString longDayName( int weekday );
|
---|
114 | #endif //QT_NO_TEXTDATE
|
---|
115 | #ifndef QT_NO_TEXTSTRING
|
---|
116 | #if !defined(QT_NO_SPRINTF)
|
---|
117 | QString toString( Qt::DateFormat f = Qt::TextDate ) const;
|
---|
118 | #endif
|
---|
119 | QString toString( const QString& format ) const;
|
---|
120 | #endif
|
---|
121 | bool setYMD( int y, int m, int d );
|
---|
122 |
|
---|
123 | QDate addDays( int days ) const;
|
---|
124 | QDate addMonths( int months ) const;
|
---|
125 | QDate addYears( int years ) const;
|
---|
126 | int daysTo( const QDate & ) const;
|
---|
127 |
|
---|
128 | bool operator==( const QDate &d ) const { return jd == d.jd; }
|
---|
129 | bool operator!=( const QDate &d ) const { return jd != d.jd; }
|
---|
130 | bool operator<( const QDate &d ) const { return jd < d.jd; }
|
---|
131 | bool operator<=( const QDate &d ) const { return jd <= d.jd; }
|
---|
132 | bool operator>( const QDate &d ) const { return jd > d.jd; }
|
---|
133 | bool operator>=( const QDate &d ) const { return jd >= d.jd; }
|
---|
134 |
|
---|
135 | static QDate currentDate();
|
---|
136 | static QDate currentDate( Qt::TimeSpec );
|
---|
137 | #ifndef QT_NO_DATESTRING
|
---|
138 | static QDate fromString( const QString& s, Qt::DateFormat f = Qt::TextDate );
|
---|
139 | #endif
|
---|
140 | static bool isValid( int y, int m, int d );
|
---|
141 | static bool leapYear( int year );
|
---|
142 |
|
---|
143 | static uint gregorianToJulian( int y, int m, int d );
|
---|
144 | static void julianToGregorian( uint jd, int &y, int &m, int &d );
|
---|
145 | private:
|
---|
146 | uint jd;
|
---|
147 | friend class QDateTime;
|
---|
148 | #ifndef QT_NO_DATASTREAM
|
---|
149 | friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QDate & );
|
---|
150 | friend Q_EXPORT QDataStream &operator>>( QDataStream &, QDate & );
|
---|
151 | #endif
|
---|
152 | };
|
---|
153 |
|
---|
154 |
|
---|
155 | /*****************************************************************************
|
---|
156 | QTime class
|
---|
157 | *****************************************************************************/
|
---|
158 |
|
---|
159 | class Q_EXPORT QTime
|
---|
160 | {
|
---|
161 | public:
|
---|
162 | QTime() { ds=0; } // set null time
|
---|
163 | QTime( int h, int m, int s=0, int ms=0 ); // set time
|
---|
164 |
|
---|
165 | bool isNull() const { return ds == 0; }
|
---|
166 | bool isValid() const; // valid time
|
---|
167 |
|
---|
168 | int hour() const; // 0..23
|
---|
169 | int minute() const; // 0..59
|
---|
170 | int second() const; // 0..59
|
---|
171 | int msec() const; // 0..999
|
---|
172 | #ifndef QT_NO_DATESTRING
|
---|
173 | #ifndef QT_NO_SPRINTF
|
---|
174 | QString toString( Qt::DateFormat f = Qt::TextDate ) const;
|
---|
175 | #endif
|
---|
176 | QString toString( const QString& format ) const;
|
---|
177 | #endif
|
---|
178 | bool setHMS( int h, int m, int s, int ms=0 );
|
---|
179 |
|
---|
180 | QTime addSecs( int secs ) const;
|
---|
181 | int secsTo( const QTime & ) const;
|
---|
182 | QTime addMSecs( int ms ) const;
|
---|
183 | int msecsTo( const QTime & ) const;
|
---|
184 |
|
---|
185 | bool operator==( const QTime &d ) const { return ds == d.ds; }
|
---|
186 | bool operator!=( const QTime &d ) const { return ds != d.ds; }
|
---|
187 | bool operator<( const QTime &d ) const { return ds < d.ds; }
|
---|
188 | bool operator<=( const QTime &d ) const { return ds <= d.ds; }
|
---|
189 | bool operator>( const QTime &d ) const { return ds > d.ds; }
|
---|
190 | bool operator>=( const QTime &d ) const { return ds >= d.ds; }
|
---|
191 |
|
---|
192 | static QTime currentTime();
|
---|
193 | static QTime currentTime( Qt::TimeSpec );
|
---|
194 | #ifndef QT_NO_DATESTRING
|
---|
195 | static QTime fromString( const QString& s, Qt::DateFormat f = Qt::TextDate );
|
---|
196 | #endif
|
---|
197 | static bool isValid( int h, int m, int s, int ms=0 );
|
---|
198 |
|
---|
199 | void start();
|
---|
200 | int restart();
|
---|
201 | int elapsed() const;
|
---|
202 |
|
---|
203 | private:
|
---|
204 | static bool currentTime( QTime * );
|
---|
205 | static bool currentTime( QTime *, Qt::TimeSpec );
|
---|
206 |
|
---|
207 | uint ds;
|
---|
208 | friend class QDateTime;
|
---|
209 | #ifndef QT_NO_DATASTREAM
|
---|
210 | friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QTime & );
|
---|
211 | friend Q_EXPORT QDataStream &operator>>( QDataStream &, QTime & );
|
---|
212 | #endif
|
---|
213 | };
|
---|
214 |
|
---|
215 |
|
---|
216 | /*****************************************************************************
|
---|
217 | QDateTime class
|
---|
218 | *****************************************************************************/
|
---|
219 |
|
---|
220 | class Q_EXPORT QDateTime
|
---|
221 | {
|
---|
222 | public:
|
---|
223 | QDateTime() {} // set null date and null time
|
---|
224 | QDateTime( const QDate & );
|
---|
225 | QDateTime( const QDate &, const QTime & );
|
---|
226 |
|
---|
227 | bool isNull() const { return d.isNull() && t.isNull(); }
|
---|
228 | bool isValid() const { return d.isValid() && t.isValid(); }
|
---|
229 |
|
---|
230 | QDate date() const { return d; }
|
---|
231 | QTime time() const { return t; }
|
---|
232 | uint toTime_t() const;
|
---|
233 | void setDate( const QDate &date ) { d = date; }
|
---|
234 | void setTime( const QTime &time ) { t = time; }
|
---|
235 | void setTime_t( uint secsSince1Jan1970UTC );
|
---|
236 | void setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec );
|
---|
237 | #ifndef QT_NO_DATESTRING
|
---|
238 | #ifndef QT_NO_SPRINTF
|
---|
239 | QString toString( Qt::DateFormat f = Qt::TextDate ) const;
|
---|
240 | #endif
|
---|
241 | QString toString( const QString& format ) const;
|
---|
242 | #endif
|
---|
243 | QDateTime addDays( int days ) const;
|
---|
244 | QDateTime addMonths( int months ) const;
|
---|
245 | QDateTime addYears( int years ) const;
|
---|
246 | QDateTime addSecs( int secs ) const;
|
---|
247 | int daysTo( const QDateTime & ) const;
|
---|
248 | int secsTo( const QDateTime & ) const;
|
---|
249 |
|
---|
250 | bool operator==( const QDateTime &dt ) const;
|
---|
251 | bool operator!=( const QDateTime &dt ) const;
|
---|
252 | bool operator<( const QDateTime &dt ) const;
|
---|
253 | bool operator<=( const QDateTime &dt ) const;
|
---|
254 | bool operator>( const QDateTime &dt ) const;
|
---|
255 | bool operator>=( const QDateTime &dt ) const;
|
---|
256 |
|
---|
257 | static QDateTime currentDateTime();
|
---|
258 | static QDateTime currentDateTime( Qt::TimeSpec );
|
---|
259 | #ifndef QT_NO_DATESTRING
|
---|
260 | static QDateTime fromString( const QString& s, Qt::DateFormat f = Qt::TextDate );
|
---|
261 | #endif
|
---|
262 | private:
|
---|
263 | QDate d;
|
---|
264 | QTime t;
|
---|
265 | #ifndef QT_NO_DATASTREAM
|
---|
266 | friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QDateTime &);
|
---|
267 | friend Q_EXPORT QDataStream &operator>>( QDataStream &, QDateTime & );
|
---|
268 | #endif
|
---|
269 | };
|
---|
270 |
|
---|
271 |
|
---|
272 | /*****************************************************************************
|
---|
273 | Date and time stream functions
|
---|
274 | *****************************************************************************/
|
---|
275 |
|
---|
276 | #ifndef QT_NO_DATASTREAM
|
---|
277 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QDate & );
|
---|
278 | Q_EXPORT QDataStream &operator>>( QDataStream &, QDate & );
|
---|
279 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QTime & );
|
---|
280 | Q_EXPORT QDataStream &operator>>( QDataStream &, QTime & );
|
---|
281 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QDateTime & );
|
---|
282 | Q_EXPORT QDataStream &operator>>( QDataStream &, QDateTime & );
|
---|
283 | #endif // QT_NO_DATASTREAM
|
---|
284 |
|
---|
285 | #endif // QDATETIME_H
|
---|
286 |
|
---|
287 | </pre>
|
---|
288 | <!-- eof -->
|
---|
289 | <p><address><hr><div align=center>
|
---|
290 | <table width=100% cellspacing=0 border=0><tr>
|
---|
291 | <td>Copyright © 2007
|
---|
292 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
293 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
294 | </table></div></address></body>
|
---|
295 | </html>
|
---|