-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,5 +1,5 @@ | |||
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 | ** |
@@ -119,5 +119,3 @@ QString DateFormat::numberDate(const QDate &d, int v) const | |||
119 | 119 | ||
120 | int pad = 0; | 120 | int pad = 2; |
121 | if (v & padNumber) | ||
122 | pad = 2; | ||
123 | 121 | ||
@@ -128,6 +126,11 @@ QString DateFormat::numberDate(const QDate &d, int v) const | |||
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; |
@@ -138,8 +141,3 @@ QString DateFormat::numberDate(const QDate &d, int v) const | |||
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 | } |
@@ -148,3 +146,3 @@ QString DateFormat::numberDate(const QDate &d, int v) const | |||
148 | if (i < 2) | 146 | if (i < 2) |
149 | buf = _shortSeparator; | 147 | buf += _shortSeparator; |
150 | } | 148 | } |
@@ -163,3 +161,3 @@ QString DateFormat::wordDate(const QDate &d, int v) const | |||
163 | buf += weekDay; | 161 | buf += weekDay; |
164 | if (_longOrder & 0x0007 == 0x0002) | 162 | if ((_longOrder & 0x0007) == 0x0002) |
165 | buf += ' '; | 163 | buf += ' '; |
@@ -169,6 +167,2 @@ QString DateFormat::wordDate(const QDate &d, int v) const | |||
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++) { |
@@ -177,6 +171,8 @@ QString DateFormat::wordDate(const QDate &d, int v) const | |||
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 |
@@ -359,2 +355,11 @@ QString TimeString::shortTime( bool ampm ) | |||
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" |