summaryrefslogtreecommitdiff
path: root/library/timestring.cpp
Side-by-side diff
Diffstat (limited to 'library/timestring.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/timestring.cpp51
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 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the Qtopia Environment.
**
@@ -119,5 +119,3 @@ QString DateFormat::numberDate(const QDate &d, int v) const
- int pad = 0;
- if (v & padNumber)
- pad = 2;
+ int pad = 2;
@@ -128,6 +126,11 @@ QString DateFormat::numberDate(const QDate &d, int v) const
case 0x0001:
- buf += QString("%1").arg(d.day(), pad);
+ if (pad==2) buf += QString().sprintf("%02d",d.day());
+ else buf += QString().sprintf("%d",d.day());
break;
case 0x0002:
- buf += QString("%1").arg(d.month(), pad);
+ if (i==0) { // no padding with only MM/DD/YY format
+ pad=0;
+ }
+ if (pad==2) buf += QString().sprintf("%02d",d.month());
+ else buf += QString().sprintf("%d",d.month());
break;
@@ -138,8 +141,3 @@ QString DateFormat::numberDate(const QDate &d, int v) const
year = year % 100;
-
- if (year < 10)
- buf += "0";
-
- buf += QString::number(year);
-
+ buf += QString().sprintf("%02d",year);
}
@@ -148,3 +146,3 @@ QString DateFormat::numberDate(const QDate &d, int v) const
if (i < 2)
- buf = _shortSeparator;
+ buf += _shortSeparator;
}
@@ -163,3 +161,3 @@ QString DateFormat::wordDate(const QDate &d, int v) const
buf += weekDay;
- if (_longOrder & 0x0007 == 0x0002)
+ if ((_longOrder & 0x0007) == 0x0002)
buf += ' ';
@@ -169,6 +167,2 @@ QString DateFormat::wordDate(const QDate &d, int v) const
- int pad = 0;
- if (v & padNumber)
- pad = 2;
-
for (int i = 0; i < 3; i++) {
@@ -177,6 +171,8 @@ QString DateFormat::wordDate(const QDate &d, int v) const
case 0x0001:
- buf += QString("%1").arg(d.day(), pad);
- if (i < 2) {
- if ((_shortOrder << ((i+1) * 3)) & 0x0007)
- buf += ", ";
+ if (i==1) {
+ buf += QString().sprintf("%02d, ",d.day());
+ } else {
+ buf += QString().sprintf("%2d",d.day());
+ if (separator()=='.') // 2002/1/11
+ buf += ". ";
else
@@ -359,2 +355,11 @@ QString TimeString::shortTime( bool ampm )
+QString TimeString::numberDateString( const QDate &d, DateFormat dtf )
+{
+ return dtf.numberDate(d);
+}
+QString TimeString::longNumberDateString( const QDate &d, DateFormat dtf )
+{
+ return dtf.numberDate(d,DateFormat::longNumber);
+}
+
#include "timestring.moc"