author | eilers <eilers> | 2003-08-08 14:45:49 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-08 14:45:49 (UTC) |
commit | 14d394e6c107b037a09a31a92605034fe50f7813 (patch) (unidiff) | |
tree | 800699cf4dc9681c3eb023340634dd6a15fd04c8 /library/timestring.cpp | |
parent | dbc6ea35f5535a1f69deb7ebbafc0f721721dbf2 (diff) | |
download | opie-14d394e6c107b037a09a31a92605034fe50f7813.zip opie-14d394e6c107b037a09a31a92605034fe50f7813.tar.gz opie-14d394e6c107b037a09a31a92605034fe50f7813.tar.bz2 |
Merged branches from BRANCH_1_0
-rw-r--r-- | library/timestring.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/timestring.cpp b/library/timestring.cpp index 6443b6b..8f60b72 100644 --- a/library/timestring.cpp +++ b/library/timestring.cpp | |||
@@ -1,365 +1,365 @@ | |||
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 | #include "timestring.h" | 21 | #include "timestring.h" |
22 | #include <qobject.h> | 22 | #include <qobject.h> |
23 | #include <qpe/qpeapplication.h> //for qApp | 23 | #include <qpe/qpeapplication.h> //for qApp |
24 | #include "config.h" | 24 | #include "config.h" |
25 | 25 | ||
26 | 26 | ||
27 | class TimeStringFormatKeeper : public QObject | 27 | class TimeStringFormatKeeper : public QObject |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | static DateFormat currentFormat() | 31 | static DateFormat currentFormat() |
32 | { | 32 | { |
33 | if ( !self ) | 33 | if ( !self ) |
34 | self = new TimeStringFormatKeeper; | 34 | self = new TimeStringFormatKeeper; |
35 | return self->format; | 35 | return self->format; |
36 | } | 36 | } |
37 | private slots: | 37 | private slots: |
38 | void formatChanged( DateFormat f ) | 38 | void formatChanged( DateFormat f ) |
39 | { | 39 | { |
40 | format = f; | 40 | format = f; |
41 | } | 41 | } |
42 | private: | 42 | private: |
43 | static TimeStringFormatKeeper *self; | 43 | static TimeStringFormatKeeper *self; |
44 | DateFormat format; | 44 | DateFormat format; |
45 | 45 | ||
46 | TimeStringFormatKeeper() | 46 | TimeStringFormatKeeper() |
47 | : QObject( qApp ) | 47 | : QObject( qApp ) |
48 | { | 48 | { |
49 | Config config("qpe"); | 49 | Config config("qpe"); |
50 | config.setGroup( "Date" ); | 50 | config.setGroup( "Date" ); |
51 | format = DateFormat(QChar(config.readEntry("Separator", "/")[0]), | 51 | format = DateFormat(QChar(config.readEntry("Separator", "/")[0]), |
52 | (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), | 52 | (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), |
53 | (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); | 53 | (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); |
54 | 54 | ||
55 | connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ), | 55 | connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ), |
56 | this, SLOT( formatChanged( DateFormat ) ) ); | 56 | this, SLOT( formatChanged( DateFormat ) ) ); |
57 | } | 57 | } |
58 | }; | 58 | }; |
59 | 59 | ||
60 | TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0; | 60 | TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0; |
61 | 61 | ||
62 | QString DateFormat::toNumberString() const | 62 | QString DateFormat::toNumberString() const |
63 | { | 63 | { |
64 | QString buf = ""; | 64 | QString buf = ""; |
65 | // for each part of the order | 65 | // for each part of the order |
66 | for (int i = 0; i < 3; i++) { | 66 | for (int i = 0; i < 3; i++) { |
67 | // switch on the relavent 3 bits. | 67 | // switch on the relavent 3 bits. |
68 | switch((_shortOrder >> (i * 3)) & 0x0007) { | 68 | switch((_shortOrder >> (i * 3)) & 0x0007) { |
69 | case 0x0001: | 69 | case 0x0001: |
70 | buf += QObject::tr( "D" ); | 70 | buf += QObject::tr( "D" ); |
71 | break; | 71 | break; |
72 | case 0x0002: | 72 | case 0x0002: |
73 | buf += QObject::tr( "M" ); | 73 | buf += QObject::tr( "M" ); |
74 | break; | 74 | break; |
75 | case 0x0004: | 75 | case 0x0004: |
76 | buf += QObject::tr( "Y" ); | 76 | buf += QObject::tr( "Y" ); |
77 | break; | 77 | break; |
78 | } | 78 | } |
79 | if (i < 2) | 79 | if (i < 2) |
80 | buf += _shortSeparator; | 80 | buf += _shortSeparator; |
81 | } | 81 | } |
82 | return buf; | 82 | return buf; |
83 | } | 83 | } |
84 | 84 | ||
85 | QString DateFormat::toWordString() const | 85 | QString DateFormat::toWordString() const |
86 | { | 86 | { |
87 | QString buf = ""; | 87 | QString buf = ""; |
88 | // for each part of the order | 88 | // for each part of the order |
89 | for (int i = 0; i < 3; i++) { | 89 | for (int i = 0; i < 3; i++) { |
90 | // switch on the relavent 3 bits. | 90 | // switch on the relavent 3 bits. |
91 | switch((_longOrder >> (i * 3)) & 0x0007) { | 91 | switch((_longOrder >> (i * 3)) & 0x0007) { |
92 | case 0x0001: | 92 | case 0x0001: |
93 | buf += QObject::tr( "day" ); | 93 | buf += QObject::tr( "day" ); |
94 | if (i < 2) { | 94 | if (i < 2) { |
95 | if ((_shortOrder << ((i+1) * 3)) & 0x0007) | 95 | if ((_shortOrder << ((i+1) * 3)) & 0x0007) |
96 | buf += ", "; | 96 | buf += ", "; |
97 | else | 97 | else |
98 | buf += " "; | 98 | buf += " "; |
99 | } | 99 | } |
100 | break; | 100 | break; |
101 | case 0x0002: | 101 | case 0x0002: |
102 | buf += QObject::tr( "month" ); | 102 | buf += QObject::tr( "month" ); |
103 | if (i < 2) | 103 | if (i < 2) |
104 | buf += " "; | 104 | buf += " "; |
105 | break; | 105 | break; |
106 | case 0x0004: | 106 | case 0x0004: |
107 | buf += QObject::tr( "year" ); | 107 | buf += QObject::tr( "year" ); |
108 | if (i < 2) | 108 | if (i < 2) |
109 | buf += ", "; | 109 | buf += ", "; |
110 | break; | 110 | break; |
111 | } | 111 | } |
112 | } | 112 | } |
113 | return buf; | 113 | return buf; |
114 | } | 114 | } |
115 | 115 | ||
116 | QString DateFormat::numberDate(const QDate &d, int v) const | 116 | QString DateFormat::numberDate(const QDate &d, int v) const |
117 | { | 117 | { |
118 | QString buf = ""; | 118 | QString buf = ""; |
119 | 119 | ||
120 | int pad = 2; | 120 | int pad = 2; |
121 | 121 | ||
122 | // for each part of the order | 122 | // for each part of the order |
123 | for (int i = 0; i < 3; i++) { | 123 | for (int i = 0; i < 3; i++) { |
124 | // switch on the relavent 3 bits. | 124 | // switch on the relavent 3 bits. |
125 | switch((_shortOrder >> (i * 3)) & 0x0007) { | 125 | switch((_shortOrder >> (i * 3)) & 0x0007) { |
126 | case 0x0001: | 126 | case 0x0001: |
127 | if (pad==2) buf += QString().sprintf("%02d",d.day()); | 127 | if (pad==2) buf += QString().sprintf("%02d",d.day()); |
128 | else buf += QString().sprintf("%d",d.day()); | 128 | else buf += QString().sprintf("%d",d.day()); |
129 | break; | 129 | break; |
130 | case 0x0002: | 130 | case 0x0002: |
131 | if (i==0) { // no padding with only MM/DD/YY format | 131 | if (i==0) { // no padding with only MM/DD/YY format |
132 | pad=0; | 132 | pad=0; |
133 | } | 133 | } |
134 | if (pad==2) buf += QString().sprintf("%02d",d.month()); | 134 | if (pad==2) buf += QString().sprintf("%02d",d.month()); |
135 | else buf += QString().sprintf("%d",d.month()); | 135 | else buf += QString().sprintf("%d",d.month()); |
136 | break; | 136 | break; |
137 | case 0x0004: | 137 | case 0x0004: |
138 | { | 138 | { |
139 | int year = d.year(); | 139 | int year = d.year(); |
140 | if (!(v & longNumber)) | 140 | if (!(v & longNumber)) |
141 | year = year % 100; | 141 | year = year % 100; |
142 | buf += QString().sprintf("%02d",year); | 142 | buf += QString().sprintf("%02d",year); |
143 | } | 143 | } |
144 | break; | 144 | break; |
145 | } | 145 | } |
146 | if (i < 2) | 146 | if (i < 2) |
147 | buf += _shortSeparator; | 147 | buf += _shortSeparator; |
148 | } | 148 | } |
149 | return buf; | 149 | return buf; |
150 | } | 150 | } |
151 | 151 | ||
152 | QString DateFormat::wordDate(const QDate &d, int v) const | 152 | QString DateFormat::wordDate(const QDate &d, int v) const |
153 | { | 153 | { |
154 | QString buf = ""; | 154 | QString buf = ""; |
155 | // for each part of the order | 155 | // for each part of the order |
156 | if (v & showWeekDay) { | 156 | if (v & showWeekDay) { |
157 | QString weekDay = d.dayName(d.dayOfWeek()); | 157 | QString weekDay = d.dayName(d.dayOfWeek()); |
158 | if (!(v & longWord)) { | 158 | if (!(v & longWord)) { |
159 | weekDay = weekDay.left(3); | 159 | weekDay = weekDay.left(3); |
160 | } | 160 | } |
161 | buf += weekDay; | 161 | buf += weekDay; |
162 | if ((_longOrder & 0x0007) == 0x0002) | 162 | if ((_longOrder & 0x0007) == 0x0002) |
163 | buf += ' '; | 163 | buf += ' '; |
164 | else | 164 | else |
165 | buf += ", "; | 165 | buf += ", "; |
166 | } | 166 | } |
167 | 167 | ||
168 | for (int i = 0; i < 3; i++) { | 168 | for (int i = 0; i < 3; i++) { |
169 | // switch on the relavent 3 bits. | 169 | // switch on the relavent 3 bits. |
170 | switch((_longOrder >> (i * 3)) & 0x0007) { | 170 | switch((_longOrder >> (i * 3)) & 0x0007) { |
171 | case 0x0001: | 171 | case 0x0001: |
172 | if (i==1) { | 172 | if (i==1) { |
173 | buf += QString().sprintf("%02d, ",d.day()); | 173 | buf += QString().sprintf("%02d, ",d.day()); |
174 | } else { | 174 | } else { |
175 | buf += QString().sprintf("%2d",d.day()); | 175 | buf += QString().sprintf("%2d",d.day()); |
176 | if (separator()=='.') // 2002/1/11 | 176 | if (separator()=='.') // 2002/1/11 |
177 | buf += ". "; | 177 | buf += ". "; |
178 | else | 178 | else |
179 | buf += " "; | 179 | buf += " "; |
180 | } | 180 | } |
181 | break; | 181 | break; |
182 | case 0x0002: | 182 | case 0x0002: |
183 | { | 183 | { |
184 | QString monthName = d.monthName(d.month()); | 184 | QString monthName = d.monthName(d.month()); |
185 | if (!(v & longWord)) { | 185 | if (!(v & longWord)) { |
186 | monthName = monthName.left(3); | 186 | monthName = monthName.left(3); |
187 | } | 187 | } |
188 | buf += monthName; | 188 | buf += monthName; |
189 | } | 189 | } |
190 | if (i < 2) | 190 | if (i < 2) |
191 | buf += " "; | 191 | buf += " "; |
192 | break; | 192 | break; |
193 | case 0x0004: | 193 | case 0x0004: |
194 | { | 194 | { |
195 | int year = d.year(); | 195 | int year = d.year(); |
196 | if (!(v & longNumber)) | 196 | if (!(v & longNumber)) |
197 | year = year % 100; | 197 | year = year % 100; |
198 | 198 | ||
199 | if (year < 10) | 199 | if (year < 10) |
200 | buf += "0"; | 200 | buf += "0"; |
201 | 201 | ||
202 | buf += QString::number(year); | 202 | buf += QString::number(year); |
203 | } | 203 | } |
204 | if (i < 2) | 204 | if (i < 2) |
205 | buf += ", "; | 205 | buf += ", "; |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | return buf; | 209 | return buf; |
210 | } | 210 | } |
211 | 211 | ||
212 | #ifndef QT_NO_DATASTREAM | 212 | #ifndef QT_NO_DATASTREAM |
213 | void DateFormat::save(QDataStream &d) const | 213 | void DateFormat::save(QDataStream &d) const |
214 | { | 214 | { |
215 | d << _shortSeparator.unicode(); | 215 | d << _shortSeparator.unicode(); |
216 | uint v= _shortOrder; | 216 | uint v= _shortOrder; |
217 | d << v; | 217 | d << v; |
218 | v = _longOrder; | 218 | v = _longOrder; |
219 | d << v; | 219 | d << v; |
220 | } | 220 | } |
221 | 221 | ||
222 | void DateFormat::load(QDataStream &d) | 222 | void DateFormat::load(QDataStream &d) |
223 | { | 223 | { |
224 | ushort value; | 224 | ushort value; |
225 | d >> value; | 225 | d >> value; |
226 | _shortSeparator = QChar(value); | 226 | _shortSeparator = QChar(value); |
227 | uint v = 0; | 227 | uint v = 0; |
228 | d >> v; | 228 | d >> v; |
229 | _shortOrder = (Order)v; | 229 | _shortOrder = (Order)v; |
230 | v = 0; | 230 | v = 0; |
231 | d >> v; | 231 | d >> v; |
232 | _longOrder = (Order)v; | 232 | _longOrder = (Order)v; |
233 | } | 233 | } |
234 | 234 | ||
235 | QDataStream &operator<<(QDataStream &s, const DateFormat&df) | 235 | QDataStream &operator<<(QDataStream &s, const DateFormat&df) |
236 | { | 236 | { |
237 | df.save(s); | 237 | df.save(s); |
238 | return s; | 238 | return s; |
239 | } | 239 | } |
240 | QDataStream &operator>>(QDataStream &s, DateFormat&df) | 240 | QDataStream &operator>>(QDataStream &s, DateFormat&df) |
241 | { | 241 | { |
242 | df.load(s); | 242 | df.load(s); |
243 | return s; | 243 | return s; |
244 | } | 244 | } |
245 | #endif | 245 | #endif |
246 | 246 | ||
247 | QString TimeString::shortDate( const QDate &d, DateFormat dtf ) | 247 | QString TimeString::shortDate( const QDate &d, DateFormat dtf ) |
248 | { | 248 | { |
249 | return dtf.wordDate(d); | 249 | return dtf.wordDate(d); |
250 | } | 250 | } |
251 | 251 | ||
252 | QString TimeString::dateString( const QDate &d, DateFormat dtf ) | 252 | QString TimeString::dateString( const QDate &d, DateFormat dtf ) |
253 | { | 253 | { |
254 | return dtf.wordDate(d, DateFormat::longNumber | DateFormat::longWord); | 254 | return QObject::tr( dtf.wordDate(d, DateFormat::longNumber | DateFormat::longWord) ); |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | QString TimeString::longDateString( const QDate &d, DateFormat dtf ) | 258 | QString TimeString::longDateString( const QDate &d, DateFormat dtf ) |
259 | { | 259 | { |
260 | return dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber | 260 | return QObject::tr( dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber |
261 | | DateFormat::longWord); | 261 | | DateFormat::longWord) ); |
262 | } | 262 | } |
263 | 263 | ||
264 | DateFormat TimeString::currentDateFormat() | 264 | DateFormat TimeString::currentDateFormat() |
265 | { | 265 | { |
266 | return TimeStringFormatKeeper::currentFormat(); | 266 | return TimeStringFormatKeeper::currentFormat(); |
267 | } | 267 | } |
268 | 268 | ||
269 | 269 | ||
270 | QString TimeString::dateString( const QDateTime &dt, bool ampm, bool seconds, DateFormat dtf ) | 270 | QString TimeString::dateString( const QDateTime &dt, bool ampm, bool seconds, DateFormat dtf ) |
271 | { | 271 | { |
272 | const QDate& d = dt.date(); | 272 | const QDate& d = dt.date(); |
273 | const QTime& t = dt.time(); | 273 | const QTime& t = dt.time(); |
274 | 274 | ||
275 | // based on QDateTime::toString() | 275 | // based on QDateTime::toString() |
276 | QString buf = timeString(t,ampm,seconds); | 276 | QString buf = timeString(t,ampm,seconds); |
277 | buf += " "; | 277 | buf += " "; |
278 | buf += longDateString( d, dtf ); | 278 | buf += longDateString( d, dtf ); |
279 | 279 | ||
280 | return buf; | 280 | return buf; |
281 | } | 281 | } |
282 | 282 | ||
283 | QString TimeString::timeString( const QTime &t, bool ampm, bool seconds ) | 283 | QString TimeString::timeString( const QTime &t, bool ampm, bool seconds ) |
284 | { | 284 | { |
285 | if ( !ampm ) { | 285 | if ( !ampm ) { |
286 | if ( seconds ) | 286 | if ( seconds ) |
287 | return t.toString(); | 287 | return t.toString(); |
288 | QString r = QString::number(t.hour()); | 288 | QString r = QString::number(t.hour()); |
289 | if ( t.hour() < 10 ) r.prepend( "0" ); | 289 | if ( t.hour() < 10 ) r.prepend( "0" ); |
290 | r.append( ":" ); | 290 | r.append( ":" ); |
291 | if ( t.minute() < 10 ) r.append( "0" ); | 291 | if ( t.minute() < 10 ) r.append( "0" ); |
292 | r.append(QString::number(t.minute())); | 292 | r.append(QString::number(t.minute())); |
293 | return r; | 293 | return r; |
294 | } | 294 | } |
295 | // ### else the hard case that should disappear in Qt 3.0 | 295 | // ### else the hard case that should disappear in Qt 3.0 |
296 | QString argString = seconds ? "%4:%5:%6 %7" : "%4:%5 %7"; | 296 | QString argString = seconds ? "%4:%5:%6 %7" : "%4:%5 %7"; |
297 | int hour = t.hour(); | 297 | int hour = t.hour(); |
298 | QString strMin = QString::number( t.minute() ); | 298 | QString strMin = QString::number( t.minute() ); |
299 | QString strSec = QString::number( t.second() ); | 299 | QString strSec = QString::number( t.second() ); |
300 | if ( hour > 12 ) | 300 | if ( hour > 12 ) |
301 | argString = argString.arg( hour - 12, 2 ); | 301 | argString = argString.arg( hour - 12, 2 ); |
302 | else { | 302 | else { |
303 | if ( hour == 0 ) | 303 | if ( hour == 0 ) |
304 | argString = argString.arg( 12 ); | 304 | argString = argString.arg( 12 ); |
305 | else | 305 | else |
306 | argString = argString.arg( hour, 2 ); | 306 | argString = argString.arg( hour, 2 ); |
307 | } | 307 | } |
308 | if ( t.minute() < 10 ) | 308 | if ( t.minute() < 10 ) |
309 | strMin.prepend( "0" ); | 309 | strMin.prepend( "0" ); |
310 | if ( t.second() < 10 ) | 310 | if ( t.second() < 10 ) |
311 | strSec.prepend( "0" ); | 311 | strSec.prepend( "0" ); |
312 | argString = argString.arg( strMin ); | 312 | argString = argString.arg( strMin ); |
313 | if ( seconds ) | 313 | if ( seconds ) |
314 | argString = argString.arg( strSec ); | 314 | argString = argString.arg( strSec ); |
315 | if ( hour >= 12 ) | 315 | if ( hour >= 12 ) |
316 | argString = argString.arg( QObject::tr("PM") ); | 316 | argString = argString.arg( QObject::tr("PM") ); |
317 | else | 317 | else |
318 | argString = argString.arg( QObject::tr("AM") ); | 318 | argString = argString.arg( QObject::tr("AM") ); |
319 | return argString; | 319 | return argString; |
320 | } | 320 | } |
321 | 321 | ||
322 | QString TimeString::shortTime( bool ampm, bool seconds ) | 322 | QString TimeString::shortTime( bool ampm, bool seconds ) |
323 | { | 323 | { |
324 | static const char* const day[] = { | 324 | static const char* const day[] = { |
325 | QT_TRANSLATE_NOOP( "QObject", "Mon" ), | 325 | QT_TRANSLATE_NOOP( "QObject", "Mon" ), |
326 | QT_TRANSLATE_NOOP( "QObject", "Tue" ), | 326 | QT_TRANSLATE_NOOP( "QObject", "Tue" ), |
327 | QT_TRANSLATE_NOOP( "QObject", "Wed" ), | 327 | QT_TRANSLATE_NOOP( "QObject", "Wed" ), |
328 | QT_TRANSLATE_NOOP( "QObject", "Thu" ), | 328 | QT_TRANSLATE_NOOP( "QObject", "Thu" ), |
329 | QT_TRANSLATE_NOOP( "QObject", "Fri" ), | 329 | QT_TRANSLATE_NOOP( "QObject", "Fri" ), |
330 | QT_TRANSLATE_NOOP( "QObject", "Sat" ), | 330 | QT_TRANSLATE_NOOP( "QObject", "Sat" ), |
331 | QT_TRANSLATE_NOOP( "QObject", "Sun" ) | 331 | QT_TRANSLATE_NOOP( "QObject", "Sun" ) |
332 | }; | 332 | }; |
333 | // just create a shorter time String | 333 | // just create a shorter time String |
334 | QDateTime dtTmp = QDateTime::currentDateTime(); | 334 | QDateTime dtTmp = QDateTime::currentDateTime(); |
335 | QString strTime; | 335 | QString strTime; |
336 | strTime = QObject::tr( day[dtTmp.date().dayOfWeek()-1] ) + " " + | 336 | strTime = QObject::tr( day[dtTmp.date().dayOfWeek()-1] ) + " " + |
337 | timeString( dtTmp.time(), ampm, seconds ); | 337 | timeString( dtTmp.time(), ampm, seconds ); |
338 | return strTime; | 338 | return strTime; |
339 | } | 339 | } |
340 | 340 | ||
341 | QString TimeString::dateString( const QDateTime &t, bool ampm ) | 341 | QString TimeString::dateString( const QDateTime &t, bool ampm ) |
342 | { | 342 | { |
343 | return dateString(t,ampm,FALSE); | 343 | return dateString(t,ampm,FALSE); |
344 | } | 344 | } |
345 | 345 | ||
346 | QString TimeString::timeString( const QTime &t, bool ampm) | 346 | QString TimeString::timeString( const QTime &t, bool ampm) |
347 | { | 347 | { |
348 | return timeString(t,ampm,FALSE); | 348 | return timeString(t,ampm,FALSE); |
349 | } | 349 | } |
350 | 350 | ||
351 | QString TimeString::shortTime( bool ampm ) | 351 | QString TimeString::shortTime( bool ampm ) |
352 | { | 352 | { |
353 | return shortTime(ampm,FALSE); | 353 | return shortTime(ampm,FALSE); |
354 | } | 354 | } |
355 | 355 | ||
356 | QString TimeString::numberDateString( const QDate &d, DateFormat dtf ) | 356 | QString TimeString::numberDateString( const QDate &d, DateFormat dtf ) |
357 | { | 357 | { |
358 | return dtf.numberDate(d); | 358 | return dtf.numberDate(d); |
359 | } | 359 | } |
360 | QString TimeString::longNumberDateString( const QDate &d, DateFormat dtf ) | 360 | QString TimeString::longNumberDateString( const QDate &d, DateFormat dtf ) |
361 | { | 361 | { |
362 | return dtf.numberDate(d,DateFormat::longNumber); | 362 | return dtf.numberDate(d,DateFormat::longNumber); |
363 | } | 363 | } |
364 | 364 | ||
365 | #include "timestring.moc" | 365 | #include "timestring.moc" |