author | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
commit | 6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (unidiff) | |
tree | 6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/timestring.cpp | |
parent | d10cddb3c9ce75bc90b14add14bc133737fe35aa (diff) | |
download | opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2 |
Qtopia1-6 merge
still to test
bic changes to be resolved
more changes to be made?
-rw-r--r-- | library/timestring.cpp | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/library/timestring.cpp b/library/timestring.cpp index d5d78ae..4c6fa72 100644 --- a/library/timestring.cpp +++ b/library/timestring.cpp | |||
@@ -1,8 +1,8 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of 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 |
@@ -116,38 +116,36 @@ QString DateFormat::toWordString() const | |||
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 = 0; | 120 | int pad = 2; |
121 | if (v & padNumber) | ||
122 | pad = 2; | ||
123 | 121 | ||
124 | // for each part of the order | 122 | // for each part of the order |
125 | for (int i = 0; i < 3; i++) { | 123 | for (int i = 0; i < 3; i++) { |
126 | // switch on the relavent 3 bits. | 124 | // switch on the relavent 3 bits. |
127 | switch((_shortOrder >> (i * 3)) & 0x0007) { | 125 | switch((_shortOrder >> (i * 3)) & 0x0007) { |
128 | case 0x0001: | 126 | case 0x0001: |
129 | buf += QString("%1").arg(d.day(), pad); | 127 | if (pad==2) buf += QString().sprintf("%02d",d.day()); |
128 | else buf += QString().sprintf("%d",d.day()); | ||
130 | break; | 129 | break; |
131 | case 0x0002: | 130 | case 0x0002: |
132 | buf += QString("%1").arg(d.month(), pad); | 131 | if (i==0) { // no padding with only MM/DD/YY format |
132 | pad=0; | ||
133 | } | ||
134 | if (pad==2) buf += QString().sprintf("%02d",d.month()); | ||
135 | else buf += QString().sprintf("%d",d.month()); | ||
133 | break; | 136 | break; |
134 | case 0x0004: | 137 | case 0x0004: |
135 | { | 138 | { |
136 | int year = d.year(); | 139 | int year = d.year(); |
137 | if (!(v & longNumber)) | 140 | if (!(v & longNumber)) |
138 | year = year % 100; | 141 | year = year % 100; |
139 | 142 | buf += QString().sprintf("%02d",year); | |
140 | if (year < 10) | ||
141 | buf += "0"; | ||
142 | |||
143 | buf += QString::number(year); | ||
144 | |||
145 | } | 143 | } |
146 | break; | 144 | break; |
147 | } | 145 | } |
148 | if (i < 2) | 146 | if (i < 2) |
149 | buf = _shortSeparator; | 147 | buf += _shortSeparator; |
150 | } | 148 | } |
151 | return buf; | 149 | return buf; |
152 | } | 150 | } |
153 | 151 | ||
@@ -160,26 +158,24 @@ QString DateFormat::wordDate(const QDate &d, int v) const | |||
160 | if (!(v & longWord)) { | 158 | if (!(v & longWord)) { |
161 | weekDay = weekDay.left(3); | 159 | weekDay = weekDay.left(3); |
162 | } | 160 | } |
163 | buf += weekDay; | 161 | buf += weekDay; |
164 | if (_longOrder & 0x0007 == 0x0002) | 162 | if ((_longOrder & 0x0007) == 0x0002) |
165 | buf += ' '; | 163 | buf += ' '; |
166 | else | 164 | else |
167 | buf += ", "; | 165 | buf += ", "; |
168 | } | 166 | } |
169 | 167 | ||
170 | int pad = 0; | ||
171 | if (v & padNumber) | ||
172 | pad = 2; | ||
173 | |||
174 | for (int i = 0; i < 3; i++) { | 168 | for (int i = 0; i < 3; i++) { |
175 | // switch on the relavent 3 bits. | 169 | // switch on the relavent 3 bits. |
176 | switch((_longOrder >> (i * 3)) & 0x0007) { | 170 | switch((_longOrder >> (i * 3)) & 0x0007) { |
177 | case 0x0001: | 171 | case 0x0001: |
178 | buf += QString("%1").arg(d.day(), pad); | 172 | if (i==1) { |
179 | if (i < 2) { | 173 | buf += QString().sprintf("%02d, ",d.day()); |
180 | if ((_shortOrder << ((i+1) * 3)) & 0x0007) | 174 | } else { |
181 | buf += ", "; | 175 | buf += QString().sprintf("%2d",d.day()); |
176 | if (separator()=='.') // 2002/1/11 | ||
177 | buf += ". "; | ||
182 | else | 178 | else |
183 | buf += " "; | 179 | buf += " "; |
184 | } | 180 | } |
185 | break; | 181 | break; |
@@ -356,5 +352,14 @@ QString TimeString::shortTime( bool ampm ) | |||
356 | { | 352 | { |
357 | return shortTime(ampm,FALSE); | 353 | return shortTime(ampm,FALSE); |
358 | } | 354 | } |
359 | 355 | ||
356 | QString TimeString::numberDateString( const QDate &d, DateFormat dtf ) | ||
357 | { | ||
358 | return dtf.numberDate(d); | ||
359 | } | ||
360 | QString TimeString::longNumberDateString( const QDate &d, DateFormat dtf ) | ||
361 | { | ||
362 | return dtf.numberDate(d,DateFormat::longNumber); | ||
363 | } | ||
364 | |||
360 | #include "timestring.moc" | 365 | #include "timestring.moc" |