author | llornkcor <llornkcor> | 2006-07-17 20:04:18 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2006-07-17 20:04:18 (UTC) |
commit | 3e77cb64e7ca0d89656e6665c1007bff6b34d609 (patch) (unidiff) | |
tree | 1708763bc99ed75de6c395093c9421b1bd0fe268 | |
parent | 20b8c8eb22b5498647430da49986f75b78cf2d79 (diff) | |
download | opie-3e77cb64e7ca0d89656e6665c1007bff6b34d609.zip opie-3e77cb64e7ca0d89656e6665c1007bff6b34d609.tar.gz opie-3e77cb64e7ca0d89656e6665c1007bff6b34d609.tar.bz2 |
supply default arguments
-rw-r--r-- | library/timestring.h | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/library/timestring.h b/library/timestring.h index b8d1aea..9a2889b 100644 --- a/library/timestring.h +++ b/library/timestring.h | |||
@@ -1,70 +1,60 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2006 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2006 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 program is free software; you can redistribute it and/or modify it | 6 | ** This program is free software; you can redistribute it and/or modify it |
7 | ** under the terms of the GNU General Public License as published by the | 7 | ** under the terms of the GNU General Public License as published by the |
8 | ** Free Software Foundation; either version 2 of the License, or (at your | 8 | ** Free Software Foundation; either version 2 of the License, or (at your |
9 | ** option) any later version. | 9 | ** option) any later version. |
10 | ** | 10 | ** |
11 | ** A copy of the GNU GPL license version 2 is included in this package as | 11 | ** A copy of the GNU GPL license version 2 is included in this package as |
12 | ** LICENSE.GPL. | 12 | ** LICENSE.GPL. |
13 | ** | 13 | ** |
14 | ** This program is distributed in the hope that it will be useful, but | 14 | ** This program is distributed in the hope that it will be useful, but |
15 | ** WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | ** WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | ** See the GNU General Public License for more details. | 17 | ** See the GNU General Public License for more details. |
18 | ** | 18 | ** |
19 | ** In addition, as a special exception Trolltech gives permission to link | ||
20 | ** the code of this program with Qtopia applications copyrighted, developed | ||
21 | ** and distributed by Trolltech under the terms of the Qtopia Personal Use | ||
22 | ** License Agreement. You must comply with the GNU General Public License | ||
23 | ** in all respects for all of the code used other than the applications | ||
24 | ** licensed under the Qtopia Personal Use License Agreement. If you modify | ||
25 | ** this file, you may extend this exception to your version of the file, | ||
26 | ** but you are not obligated to do so. If you do not wish to do so, delete | ||
27 | ** this exception statement from your version. | ||
28 | ** | ||
29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 19 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
30 | ** | 20 | ** |
31 | ** Contact info@trolltech.com if any conditions of this licensing are | 21 | ** Contact info@trolltech.com if any conditions of this licensing are |
32 | ** not clear to you. | 22 | ** not clear to you. |
33 | ** | 23 | ** |
34 | **********************************************************************/ | 24 | **********************************************************************/ |
35 | 25 | ||
36 | #ifndef _TIMESTRING_H_ | 26 | #ifndef _TIMESTRING_H_ |
37 | #define _TIMESTRING_H_ | 27 | #define _TIMESTRING_H_ |
38 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
39 | #include <qstring.h> | 29 | #include <qstring.h> |
40 | #include <qarray.h> | 30 | #include <qarray.h> |
41 | 31 | ||
42 | #if (QT_VERSION-0 >= 0x030000) | 32 | #if (QT_VERSION-0 >= 0x030000) |
43 | #define DateFormat QPEDateFormat | 33 | #define DateFormat QPEDateFormat |
44 | #endif | 34 | #endif |
45 | 35 | ||
46 | #include <qtopia/qpeglobal.h> | 36 | #include <qtopia/qpeglobal.h> |
47 | 37 | ||
48 | class QObject; | 38 | class QObject; |
49 | 39 | ||
50 | // return a string with the time based on whether or not you want | 40 | // return a string with the time based on whether or not you want |
51 | // you want it in 12 hour form. if ampm is true, then return | 41 | // you want it in 12 hour form. if ampm is true, then return |
52 | // it in 12 hour (am/pm) form otherwise return it in 24 hour form | 42 | // it in 12 hour (am/pm) form otherwise return it in 24 hour form |
53 | // in theory Qt 3,0 handles this better (hopefully obsoleteing this) | 43 | // in theory Qt 3,0 handles this better (hopefully obsoleteing this) |
54 | class DateFormat | 44 | class DateFormat |
55 | { | 45 | { |
56 | public: | 46 | public: |
57 | // date format type 1,2,4 = day,month,year | 47 | // date format type 1,2,4 = day,month,year |
58 | enum Order { | 48 | enum Order { |
59 | DayMonthYear = 0421, // right-to-left | 49 | DayMonthYear = 0421, // right-to-left |
60 | MonthDayYear = 0412, | 50 | MonthDayYear = 0412, |
61 | YearMonthDay = 0124 | 51 | YearMonthDay = 0124 |
62 | }; | 52 | }; |
63 | 53 | ||
64 | DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so), | 54 | DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so), |
65 | _longOrder(so), _shortSeparator(s) { } | 55 | _longOrder(so), _shortSeparator(s) { } |
66 | DateFormat(QChar s, Order so, Order lo) : _shortOrder(so), | 56 | DateFormat(QChar s, Order so, Order lo) : _shortOrder(so), |
67 | _longOrder(lo), _shortSeparator(s) { } | 57 | _longOrder(lo), _shortSeparator(s) { } |
68 | DateFormat(const DateFormat &o) : _shortOrder(o._shortOrder), | 58 | DateFormat(const DateFormat &o) : _shortOrder(o._shortOrder), |
69 | _longOrder(o._longOrder), _shortSeparator(o._shortSeparator) { } | 59 | _longOrder(o._longOrder), _shortSeparator(o._shortSeparator) { } |
70 | 60 | ||
@@ -106,77 +96,77 @@ public: | |||
106 | 96 | ||
107 | private: | 97 | private: |
108 | Order _shortOrder; | 98 | Order _shortOrder; |
109 | Order _longOrder; | 99 | Order _longOrder; |
110 | QChar _shortSeparator; | 100 | QChar _shortSeparator; |
111 | }; | 101 | }; |
112 | 102 | ||
113 | #ifndef QT_NO_DATASTREAM | 103 | #ifndef QT_NO_DATASTREAM |
114 | QDataStream &operator<<(QDataStream &s, const DateFormat&df); | 104 | QDataStream &operator<<(QDataStream &s, const DateFormat&df); |
115 | QDataStream &operator>>(QDataStream &s, DateFormat&df); | 105 | QDataStream &operator>>(QDataStream &s, DateFormat&df); |
116 | #endif | 106 | #endif |
117 | 107 | ||
118 | class TimeString | 108 | class TimeString |
119 | { | 109 | { |
120 | public: | 110 | public: |
121 | 111 | ||
122 | //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601, | 112 | //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601, |
123 | //YearMonthDay = ISO8601 }; | 113 | //YearMonthDay = ISO8601 }; |
124 | 114 | ||
125 | 115 | ||
126 | //private: | 116 | //private: |
127 | static QString shortDate( const QDate &d ) | 117 | static QString shortDate( const QDate &d ) |
128 | { return shortDate( d, currentDateFormat() ); } | 118 | { return shortDate( d, currentDateFormat() ); } |
129 | static QString dateString( const QDate &d ) | 119 | static QString dateString( const QDate &d ) |
130 | { return dateString( d, currentDateFormat() ); } | 120 | { return dateString( d, currentDateFormat() ); } |
131 | static QString longDateString( const QDate &d ) | 121 | static QString longDateString( const QDate &d ) |
132 | { return longDateString( d, currentDateFormat() ); } | 122 | { return longDateString( d, currentDateFormat() ); } |
133 | static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) | 123 | static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) |
134 | { return dateString( dt, ampm, seconds, currentDateFormat() ); } | 124 | { return dateString( dt, ampm, seconds, currentDateFormat() ); } |
135 | 125 | ||
136 | public: | 126 | public: |
137 | enum Length { Short, Medium, Long }; | 127 | enum Length { Short, Medium, Long }; |
138 | static QString localH( int hour ); | 128 | static QString localH( int hour ); |
139 | static QString localHM( const QTime & ); | 129 | static QString localHM( const QTime & ); |
140 | static QString localHM( const QTime &, Length ); // qtopia 2.1.0 | 130 | static QString localHM( const QTime &, Length ); // qtopia 2.1.0 |
141 | static QString localHMS( const QTime & ); | 131 | static QString localHMS( const QTime & ); |
142 | static QString localHMDayOfWeek( const QDateTime &t ); | 132 | static QString localHMDayOfWeek( const QDateTime &t ); |
143 | static QString localHMSDayOfWeek( const QDateTime &t ); | 133 | static QString localHMSDayOfWeek( const QDateTime &t ); |
144 | static QString localMD( const QDate &, Length=Medium ); | 134 | static QString localMD( const QDate &, Length=Medium ); |
145 | static QString localYMD( const QDate &, Length=Medium ); | 135 | static QString localYMD( const QDate &, Length=Medium ); |
146 | static QString localYMDHMS( const QDateTime &, Length=Medium ); | 136 | static QString localYMDHMS( const QDateTime &, Length=Medium ); |
147 | static QString localDayOfWeek( const QDate&, Length=Medium ); | 137 | static QString localDayOfWeek( const QDate&, Length=Medium ); |
148 | static QString localDayOfWeek( int day1to7, Length=Medium ); | 138 | static QString localDayOfWeek( int day1to7, Length=Medium ); |
149 | 139 | ||
150 | static QString hourString( int hour, bool ampm ); | 140 | static QString hourString( int hour, bool ampm ); |
151 | static bool currentAMPM(); | 141 | static bool currentAMPM(); |
152 | static DateFormat currentDateFormat(); | 142 | static DateFormat currentDateFormat(); |
153 | static QArray<DateFormat> formatOptions(); // qtopia 1.6.0 | 143 | static QArray<DateFormat> formatOptions(); // qtopia 1.6.0 |
154 | 144 | ||
155 | static void connectChange(QObject*,const char* member); | 145 | static void connectChange(QObject*,const char* member); |
156 | static void disconnectChange(QObject*,const char* member); | 146 | static void disconnectChange(QObject*,const char* member); |
157 | 147 | ||
158 | // Not recommended to call these (they don't honor system ampm) | 148 | // Not recommended to call these (they don't honor system ampm) |
159 | static QString dateString( const QDateTime &t, bool ampm ); | 149 | static QString dateString( const QDateTime &t, bool ampm = false); |
160 | static QString timeString( const QTime &t, bool ampm, bool seconds ); | 150 | static QString timeString( const QTime &t, bool ampm, bool seconds ); |
161 | static QString timeString( const QTime &t, bool ampm ); | 151 | static QString timeString( const QTime &t, bool ampm = false); |
162 | static QString shortTime( bool ampm, bool seconds ); | 152 | static QString shortTime( bool ampm, bool seconds ); |
163 | static QString shortTime( bool ampm ); | 153 | static QString shortTime( bool ampm = false); |
164 | 154 | ||
165 | static QString numberDateString( const QDate &d, DateFormat ); | 155 | static QString numberDateString( const QDate &d, DateFormat ); |
166 | static QString numberDateString( const QDate &d ) | 156 | static QString numberDateString( const QDate &d ) |
167 | { return numberDateString( d, currentDateFormat() ); } | 157 | { return numberDateString( d, currentDateFormat() ); } |
168 | static QString longNumberDateString( const QDate &d, DateFormat ); | 158 | static QString longNumberDateString( const QDate &d, DateFormat ); |
169 | static QString longNumberDateString( const QDate &d ) | 159 | static QString longNumberDateString( const QDate &d ) |
170 | { return longNumberDateString( d, currentDateFormat() ); } | 160 | { return longNumberDateString( d, currentDateFormat() ); } |
171 | 161 | ||
172 | static QString shortDate( const QDate &, DateFormat ); | 162 | static QString shortDate( const QDate &, DateFormat ); |
173 | static QString dateString( const QDate &, DateFormat ); | 163 | static QString dateString( const QDate &, DateFormat ); |
174 | static QString longDateString( const QDate &, DateFormat ); | 164 | static QString longDateString( const QDate &, DateFormat ); |
175 | 165 | ||
176 | private: | 166 | private: |
177 | static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); | 167 | static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); |
178 | 168 | ||
179 | 169 | ||
180 | }; | 170 | }; |
181 | 171 | ||
182 | #endif | 172 | #endif |