summaryrefslogtreecommitdiff
path: root/library/timestring.cpp
Side-by-side diff
Diffstat (limited to 'library/timestring.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/timestring.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/library/timestring.cpp b/library/timestring.cpp
index 4c6fa72..6443b6b 100644
--- a/library/timestring.cpp
+++ b/library/timestring.cpp
@@ -11,25 +11,25 @@
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "timestring.h"
#include <qobject.h>
-#include "qpeapplication.h" //for qApp
+#include <qpe/qpeapplication.h> //for qApp
#include "config.h"
class TimeStringFormatKeeper : public QObject
{
Q_OBJECT
public:
static DateFormat currentFormat()
{
if ( !self )
self = new TimeStringFormatKeeper;
return self->format;
@@ -40,98 +40,98 @@ private slots:
format = f;
}
private:
static TimeStringFormatKeeper *self;
DateFormat format;
TimeStringFormatKeeper()
: QObject( qApp )
{
Config config("qpe");
config.setGroup( "Date" );
format = DateFormat(QChar(config.readEntry("Separator", "/")[0]),
- (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
+ (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
(DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ),
this, SLOT( formatChanged( DateFormat ) ) );
}
};
TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0;
QString DateFormat::toNumberString() const
{
QString buf = "";
// for each part of the order
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
- switch((_shortOrder >> (i * 3)) & 0x0007) {
+ switch((_shortOrder >> (i * 3)) & 0x0007) {
case 0x0001:
buf += QObject::tr( "D" );
break;
case 0x0002:
buf += QObject::tr( "M" );
break;
case 0x0004:
buf += QObject::tr( "Y" );
break;
}
if (i < 2)
buf += _shortSeparator;
}
return buf;
}
QString DateFormat::toWordString() const
{
QString buf = "";
// for each part of the order
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
- switch((_longOrder >> (i * 3)) & 0x0007) {
+ switch((_longOrder >> (i * 3)) & 0x0007) {
case 0x0001:
buf += QObject::tr( "day" );
- if (i < 2) {
+ if (i < 2) {
if ((_shortOrder << ((i+1) * 3)) & 0x0007)
buf += ", ";
- else
+ else
buf += " ";
}
break;
case 0x0002:
buf += QObject::tr( "month" );
- if (i < 2)
+ if (i < 2)
buf += " ";
break;
case 0x0004:
buf += QObject::tr( "year" );
- if (i < 2)
+ if (i < 2)
buf += ", ";
break;
}
}
return buf;
}
QString DateFormat::numberDate(const QDate &d, int v) const
{
QString buf = "";
int pad = 2;
// for each part of the order
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
- switch((_shortOrder >> (i * 3)) & 0x0007) {
+ switch((_shortOrder >> (i * 3)) & 0x0007) {
case 0x0001:
if (pad==2) buf += QString().sprintf("%02d",d.day());
else buf += QString().sprintf("%d",d.day());
break;
case 0x0002:
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;
case 0x0004:
@@ -152,83 +152,83 @@ QString DateFormat::numberDate(const QDate &d, int v) const
QString DateFormat::wordDate(const QDate &d, int v) const
{
QString buf = "";
// for each part of the order
if (v & showWeekDay) {
QString weekDay = d.dayName(d.dayOfWeek());
if (!(v & longWord)) {
weekDay = weekDay.left(3);
}
buf += weekDay;
if ((_longOrder & 0x0007) == 0x0002)
buf += ' ';
- else
+ else
buf += ", ";
}
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
- switch((_longOrder >> (i * 3)) & 0x0007) {
+ switch((_longOrder >> (i * 3)) & 0x0007) {
case 0x0001:
if (i==1) {
buf += QString().sprintf("%02d, ",d.day());
} else {
buf += QString().sprintf("%2d",d.day());
- if (separator()=='.') // 2002/1/11
+ if (separator()=='.') // 2002/1/11
buf += ". ";
- else
+ else
buf += " ";
}
break;
case 0x0002:
{
QString monthName = d.monthName(d.month());
if (!(v & longWord)) {
monthName = monthName.left(3);
}
buf += monthName;
}
- if (i < 2)
+ if (i < 2)
buf += " ";
break;
case 0x0004:
{
int year = d.year();
if (!(v & longNumber))
year = year % 100;
if (year < 10)
buf += "0";
buf += QString::number(year);
}
- if (i < 2)
+ if (i < 2)
buf += ", ";
break;
}
}
return buf;
}
#ifndef QT_NO_DATASTREAM
void DateFormat::save(QDataStream &d) const
{
d << _shortSeparator.unicode();
uint v= _shortOrder;
d << v;
v = _longOrder;
d << v;
}
-void DateFormat::load(QDataStream &d)
+void DateFormat::load(QDataStream &d)
{
ushort value;
d >> value;
_shortSeparator = QChar(value);
uint v = 0;
d >> v;
_shortOrder = (Order)v;
v = 0;
d >> v;
_longOrder = (Order)v;
}
@@ -248,25 +248,25 @@ QString TimeString::shortDate( const QDate &d, DateFormat dtf )
{
return dtf.wordDate(d);
}
QString TimeString::dateString( const QDate &d, DateFormat dtf )
{
return dtf.wordDate(d, DateFormat::longNumber | DateFormat::longWord);
}
QString TimeString::longDateString( const QDate &d, DateFormat dtf )
{
- return dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber
+ return dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber
| DateFormat::longWord);
}
DateFormat TimeString::currentDateFormat()
{
return TimeStringFormatKeeper::currentFormat();
}
QString TimeString::dateString( const QDateTime &dt, bool ampm, bool seconds, DateFormat dtf )
{
const QDate& d = dt.date();