author | zecke <zecke> | 2004-02-18 23:25:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-18 23:25:18 (UTC) |
commit | ab41e301eb7f06af0869844d197e38a7838f3f2d (patch) (unidiff) | |
tree | 65fb4cf5e4af1cb2c8d85ec46bc53096a97d110a /library/timestring.h | |
parent | 28b63b3270b8162fcea4449b53b75fa325d740ad (diff) | |
download | opie-ab41e301eb7f06af0869844d197e38a7838f3f2d.zip opie-ab41e301eb7f06af0869844d197e38a7838f3f2d.tar.gz opie-ab41e301eb7f06af0869844d197e38a7838f3f2d.tar.bz2 |
Gross hack to allow compilation with Qt3 more easily
Qt got a DateFormat as well so we use a define to call our QPEDateFormat
-rw-r--r-- | library/timestring.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/library/timestring.h b/library/timestring.h index f8cb3e6..0335715 100644 --- a/library/timestring.h +++ b/library/timestring.h | |||
@@ -1,136 +1,140 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef _TIMESTRING_H_ | 21 | #ifndef _TIMESTRING_H_ |
22 | #define _TIMESTRING_H_ | 22 | #define _TIMESTRING_H_ |
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | 25 | ||
26 | #if (QT_VERSION-0 >= 0x030000) | ||
27 | #define DateFormat QPEDateFormat | ||
28 | #endif | ||
29 | |||
26 | // return a string with the time based on whether or not you want | 30 | // return a string with the time based on whether or not you want |
27 | // you want it in 12 hour form. if ampm is true, then return | 31 | // you want it in 12 hour form. if ampm is true, then return |
28 | // it in 12 hour (am/pm) form otherwise return it in 24 hour form | 32 | // it in 12 hour (am/pm) form otherwise return it in 24 hour form |
29 | // in theory Qt 3,0 handles this better (hopefully obsoleteing this) | 33 | // in theory Qt 3,0 handles this better (hopefully obsoleteing this) |
30 | class DateFormat | 34 | class DateFormat |
31 | { | 35 | { |
32 | public: | 36 | public: |
33 | // date format type 001,010,100 = day month year | 37 | // date format type 001,010,100 = day month year |
34 | enum Order { | 38 | enum Order { |
35 | DayMonthYear = 0x0111, // 0x001 + 0x010(0x2 << 3) + 0x100(0x4 << 3) | 39 | DayMonthYear = 0x0111, // 0x001 + 0x010(0x2 << 3) + 0x100(0x4 << 3) |
36 | MonthDayYear = 0x010A, | 40 | MonthDayYear = 0x010A, |
37 | YearMonthDay = 0x0054 | 41 | YearMonthDay = 0x0054 |
38 | }; | 42 | }; |
39 | 43 | ||
40 | DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so), | 44 | DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so), |
41 | _longOrder(so), _shortSeparator(s) { } | 45 | _longOrder(so), _shortSeparator(s) { } |
42 | DateFormat(QChar s, Order so, Order lo) : _shortOrder(so), | 46 | DateFormat(QChar s, Order so, Order lo) : _shortOrder(so), |
43 | _longOrder(lo), _shortSeparator(s) { } | 47 | _longOrder(lo), _shortSeparator(s) { } |
44 | DateFormat(const DateFormat &o) : _shortOrder(o._shortOrder), | 48 | DateFormat(const DateFormat &o) : _shortOrder(o._shortOrder), |
45 | _longOrder(o._longOrder), _shortSeparator(o._shortSeparator) { } | 49 | _longOrder(o._longOrder), _shortSeparator(o._shortSeparator) { } |
46 | 50 | ||
47 | bool operator==(const DateFormat &o) | 51 | bool operator==(const DateFormat &o) |
48 | { | 52 | { |
49 | if (o._shortOrder == _shortOrder && o._longOrder == _longOrder && | 53 | if (o._shortOrder == _shortOrder && o._longOrder == _longOrder && |
50 | o._shortSeparator == _shortSeparator) | 54 | o._shortSeparator == _shortSeparator) |
51 | return TRUE; | 55 | return TRUE; |
52 | return FALSE; | 56 | return FALSE; |
53 | } | 57 | } |
54 | 58 | ||
55 | // verbosity specifiers | 59 | // verbosity specifiers |
56 | enum Verbosity { | 60 | enum Verbosity { |
57 | shortNumber = 0x01, // default | 61 | shortNumber = 0x01, // default |
58 | longNumber = 0x02, | 62 | longNumber = 0x02, |
59 | 63 | ||
60 | padNumber = 0x04, | 64 | padNumber = 0x04, |
61 | 65 | ||
62 | shortWord = 0x08, // default | 66 | shortWord = 0x08, // default |
63 | longWord = 0x10, | 67 | longWord = 0x10, |
64 | 68 | ||
65 | showWeekDay = 0x20 | 69 | showWeekDay = 0x20 |
66 | }; | 70 | }; |
67 | 71 | ||
68 | QString toNumberString() const; // the M/D/Y string. | 72 | QString toNumberString() const; // the M/D/Y string. |
69 | QString toWordString() const; // the Month day, year string. | 73 | QString toWordString() const; // the Month day, year string. |
70 | 74 | ||
71 | QString numberDate(const QDate &d, int v = 0) const; | 75 | QString numberDate(const QDate &d, int v = 0) const; |
72 | QString wordDate(const QDate &d, int v = 0) const; | 76 | QString wordDate(const QDate &d, int v = 0) const; |
73 | 77 | ||
74 | #ifndef QT_NO_DATASTREAM | 78 | #ifndef QT_NO_DATASTREAM |
75 | void load(QDataStream&); | 79 | void load(QDataStream&); |
76 | void save(QDataStream&) const; | 80 | void save(QDataStream&) const; |
77 | #endif | 81 | #endif |
78 | 82 | ||
79 | QChar separator() const { return _shortSeparator; }; | 83 | QChar separator() const { return _shortSeparator; }; |
80 | Order shortOrder() const { return _shortOrder; }; | 84 | Order shortOrder() const { return _shortOrder; }; |
81 | Order longOrder() const { return _longOrder; }; | 85 | Order longOrder() const { return _longOrder; }; |
82 | 86 | ||
83 | private: | 87 | private: |
84 | Order _shortOrder; | 88 | Order _shortOrder; |
85 | Order _longOrder; | 89 | Order _longOrder; |
86 | QChar _shortSeparator; | 90 | QChar _shortSeparator; |
87 | }; | 91 | }; |
88 | 92 | ||
89 | #ifndef QT_NO_DATASTREAM | 93 | #ifndef QT_NO_DATASTREAM |
90 | QDataStream &operator<<(QDataStream &s, const DateFormat&df); | 94 | QDataStream &operator<<(QDataStream &s, const DateFormat&df); |
91 | QDataStream &operator>>(QDataStream &s, DateFormat&df); | 95 | QDataStream &operator>>(QDataStream &s, DateFormat&df); |
92 | #endif | 96 | #endif |
93 | 97 | ||
94 | class TimeString | 98 | class TimeString |
95 | { | 99 | { |
96 | public: | 100 | public: |
97 | 101 | ||
98 | //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601, | 102 | //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601, |
99 | //YearMonthDay = ISO8601 }; | 103 | //YearMonthDay = ISO8601 }; |
100 | 104 | ||
101 | 105 | ||
102 | static QString shortDate( const QDate &d ) | 106 | static QString shortDate( const QDate &d ) |
103 | { return shortDate( d, currentDateFormat() ); } | 107 | { return shortDate( d, currentDateFormat() ); } |
104 | static QString dateString( const QDate &d ) | 108 | static QString dateString( const QDate &d ) |
105 | { return dateString( d, currentDateFormat() ); } | 109 | { return dateString( d, currentDateFormat() ); } |
106 | static QString longDateString( const QDate &d ) | 110 | static QString longDateString( const QDate &d ) |
107 | { return longDateString( d, currentDateFormat() ); } | 111 | { return longDateString( d, currentDateFormat() ); } |
108 | static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) | 112 | static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) |
109 | { return dateString( dt, ampm, seconds, currentDateFormat() ); } | 113 | { return dateString( dt, ampm, seconds, currentDateFormat() ); } |
110 | 114 | ||
111 | static QString dateString( const QDateTime &t, bool ampm = false ); | 115 | static QString dateString( const QDateTime &t, bool ampm = false ); |
112 | static QString timeString( const QTime &t, bool ampm, bool seconds ); | 116 | static QString timeString( const QTime &t, bool ampm, bool seconds ); |
113 | static QString timeString( const QTime &t, bool ampm = false ); | 117 | static QString timeString( const QTime &t, bool ampm = false ); |
114 | static QString shortTime( bool ampm, bool seconds ); | 118 | static QString shortTime( bool ampm, bool seconds ); |
115 | static QString shortTime( bool ampm = false ); | 119 | static QString shortTime( bool ampm = false ); |
116 | 120 | ||
117 | static QString numberDateString( const QDate &d, DateFormat ); | 121 | static QString numberDateString( const QDate &d, DateFormat ); |
118 | static QString numberDateString( const QDate &d ) | 122 | static QString numberDateString( const QDate &d ) |
119 | { return numberDateString( d, currentDateFormat() ); } | 123 | { return numberDateString( d, currentDateFormat() ); } |
120 | static QString longNumberDateString( const QDate &d, DateFormat ); | 124 | static QString longNumberDateString( const QDate &d, DateFormat ); |
121 | static QString longNumberDateString( const QDate &d ) | 125 | static QString longNumberDateString( const QDate &d ) |
122 | { return longNumberDateString( d, currentDateFormat() ); } | 126 | { return longNumberDateString( d, currentDateFormat() ); } |
123 | 127 | ||
124 | static QString shortDate( const QDate &, DateFormat ); | 128 | static QString shortDate( const QDate &, DateFormat ); |
125 | static QString dateString( const QDate &, DateFormat ); | 129 | static QString dateString( const QDate &, DateFormat ); |
126 | static QString longDateString( const QDate &, DateFormat ); | 130 | static QString longDateString( const QDate &, DateFormat ); |
127 | 131 | ||
128 | static DateFormat currentDateFormat(); | 132 | static DateFormat currentDateFormat(); |
129 | 133 | ||
130 | private: | 134 | private: |
131 | static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); | 135 | static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); |
132 | 136 | ||
133 | 137 | ||
134 | }; | 138 | }; |
135 | 139 | ||
136 | #endif | 140 | #endif |