summaryrefslogtreecommitdiff
path: root/qmake/include/qdatetime.h
Unidiff
Diffstat (limited to 'qmake/include/qdatetime.h') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/include/qdatetime.h250
1 files changed, 250 insertions, 0 deletions
diff --git a/qmake/include/qdatetime.h b/qmake/include/qdatetime.h
new file mode 100644
index 0000000..4f01760
--- a/dev/null
+++ b/qmake/include/qdatetime.h
@@ -0,0 +1,250 @@
1/*************************************************************************
2** $Id$
3**
4** Definition of date and time classes
5**
6** Created : 940124
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the tools module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QDATETIME_H
39#define QDATETIME_H
40
41#ifndef QT_H
42#include "qstring.h"
43#include "qnamespace.h"
44#endif // QT_H
45
46
47/*****************************************************************************
48 QDate class
49 *****************************************************************************/
50
51class Q_EXPORT QDate
52{
53public:
54 QDate() { jd = 0; }
55 QDate( int y, int m, int d );
56
57 bool isNull() const { return jd == 0; }
58 bool isValid() const;
59
60 int year() const;
61 int month() const;
62 int day() const;
63 int dayOfWeek() const;
64 int dayOfYear() const;
65 int daysInMonth() const;
66 int daysInYear() const;
67 int weekNumber( int *yearNum = 0 ) const;
68
69#ifndef QT_NO_TEXTDATE
70#ifndef QT_NO_COMPAT
71 static QString monthName( int month ) { return shortMonthName( month ); }
72 static QString dayName( int weekday ) { return shortDayName( weekday ); }
73#endif
74 static QString shortMonthName( int month );
75 static QString shortDayName( int weekday );
76 static QString longMonthName( int month );
77 static QString longDayName( int weekday );
78#endif //QT_NO_TEXTDATE
79#ifndef QT_NO_TEXTSTRING
80#if !defined(QT_NO_SPRINTF)
81 QString toString( Qt::DateFormat f = Qt::TextDate ) const;
82#endif
83 QString toString( const QString& format ) const;
84#endif
85 bool setYMD( int y, int m, int d );
86
87 QDate addDays( int days ) const;
88 QDate addMonths( int months ) const;
89 QDate addYears( int years ) const;
90 int daysTo( const QDate & )const;
91
92 bool operator==( const QDate &d ) const { return jd == d.jd; }
93 bool operator!=( const QDate &d ) const { return jd != d.jd; }
94 bool operator<( const QDate &d )const { return jd < d.jd; }
95 bool operator<=( const QDate &d ) const { return jd <= d.jd; }
96 bool operator>( const QDate &d )const { return jd > d.jd; }
97 bool operator>=( const QDate &d ) const { return jd >= d.jd; }
98
99 static QDate currentDate();
100 static QDate currentDate( Qt::TimeSpec );
101#ifndef QT_NO_DATESTRING
102 static QDate fromString( const QString& s, Qt::DateFormat f = Qt::TextDate );
103#endif
104 static bool isValid( int y, int m, int d );
105 static bool leapYear( int year );
106
107 static uint gregorianToJulian( int y, int m, int d );
108 static void julianToGregorian( uint jd, int &y, int &m, int &d );
109private:
110 uint jd;
111 friend class QDateTime;
112#ifndef QT_NO_DATASTREAM
113 friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QDate & );
114 friend Q_EXPORT QDataStream &operator>>( QDataStream &, QDate & );
115#endif
116};
117
118
119/*****************************************************************************
120 QTime class
121 *****************************************************************************/
122
123class Q_EXPORT QTime
124{
125public:
126 QTime() { ds=0; } // set null time
127 QTime( int h, int m, int s=0, int ms=0 );// set time
128
129 bool isNull() const { return ds == 0; }
130 bool isValid() const; // valid time
131
132 int hour() const; // 0..23
133 int minute() const; // 0..59
134 int second() const; // 0..59
135 int msec() const; // 0..999
136#ifndef QT_NO_DATESTRING
137#ifndef QT_NO_SPRINTF
138 QString toString( Qt::DateFormat f = Qt::TextDate ) const;
139#endif
140 QString toString( const QString& format ) const;
141#endif
142 bool setHMS( int h, int m, int s, int ms=0 );
143
144 QTime addSecs( int secs ) const;
145 int secsTo( const QTime & )const;
146 QTime addMSecs( int ms ) const;
147 int msecsTo( const QTime & )const;
148
149 bool operator==( const QTime &d ) const { return ds == d.ds; }
150 bool operator!=( const QTime &d ) const { return ds != d.ds; }
151 bool operator<( const QTime &d )const { return ds < d.ds; }
152 bool operator<=( const QTime &d ) const { return ds <= d.ds; }
153 bool operator>( const QTime &d )const { return ds > d.ds; }
154 bool operator>=( const QTime &d ) const { return ds >= d.ds; }
155
156 static QTime currentTime();
157 static QTime currentTime( Qt::TimeSpec );
158#ifndef QT_NO_DATESTRING
159 static QTime fromString( const QString& s, Qt::DateFormat f = Qt::TextDate );
160#endif
161 static bool isValid( int h, int m, int s, int ms=0 );
162
163 void start();
164 int restart();
165 int elapsed() const;
166
167private:
168 static bool currentTime( QTime * );
169 static bool currentTime( QTime *, Qt::TimeSpec );
170
171 uint ds;
172 friend class QDateTime;
173#ifndef QT_NO_DATASTREAM
174 friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QTime & );
175 friend Q_EXPORT QDataStream &operator>>( QDataStream &, QTime & );
176#endif
177};
178
179
180/*****************************************************************************
181 QDateTime class
182 *****************************************************************************/
183
184class Q_EXPORT QDateTime
185{
186public:
187 QDateTime() {} // set null date and null time
188 QDateTime( const QDate & );
189 QDateTime( const QDate &, const QTime & );
190
191 bool isNull() const { return d.isNull() && t.isNull(); }
192 bool isValid() const { return d.isValid() && t.isValid(); }
193
194 QDate date() const { return d; }
195 QTime time() const { return t; }
196 uint toTime_t()const;
197 void setDate( const QDate &date ) { d = date; }
198 void setTime( const QTime &time ) { t = time; }
199 void setTime_t( uint secsSince1Jan1970UTC );
200 void setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec );
201#ifndef QT_NO_DATESTRING
202#ifndef QT_NO_SPRINTF
203 QString toString( Qt::DateFormat f = Qt::TextDate )const;
204#endif
205 QString toString( const QString& format ) const;
206#endif
207 QDateTime addDays( int days )const;
208 QDateTime addMonths( int months ) const;
209 QDateTime addYears( int years ) const;
210 QDateTime addSecs( int secs )const;
211 int daysTo( const QDateTime & )const;
212 int secsTo( const QDateTime & )const;
213
214 bool operator==( const QDateTime &dt ) const;
215 bool operator!=( const QDateTime &dt ) const;
216 bool operator<( const QDateTime &dt ) const;
217 bool operator<=( const QDateTime &dt ) const;
218 bool operator>( const QDateTime &dt ) const;
219 bool operator>=( const QDateTime &dt ) const;
220
221 static QDateTime currentDateTime();
222 static QDateTime currentDateTime( Qt::TimeSpec );
223#ifndef QT_NO_DATESTRING
224 static QDateTime fromString( const QString& s, Qt::DateFormat f = Qt::TextDate );
225#endif
226private:
227 QDate d;
228 QTime t;
229#ifndef QT_NO_DATASTREAM
230 friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QDateTime &);
231 friend Q_EXPORT QDataStream &operator>>( QDataStream &, QDateTime & );
232#endif
233};
234
235
236/*****************************************************************************
237 Date and time stream functions
238 *****************************************************************************/
239
240#ifndef QT_NO_DATASTREAM
241Q_EXPORT QDataStream &operator<<( QDataStream &, const QDate & );
242Q_EXPORT QDataStream &operator>>( QDataStream &, QDate & );
243Q_EXPORT QDataStream &operator<<( QDataStream &, const QTime & );
244Q_EXPORT QDataStream &operator>>( QDataStream &, QTime & );
245Q_EXPORT QDataStream &operator<<( QDataStream &, const QDateTime & );
246Q_EXPORT QDataStream &operator>>( QDataStream &, QDateTime & );
247#endif // QT_NO_DATASTREAM
248
249#endif // QDATETIME_H
250