summaryrefslogtreecommitdiffabout
path: root/microkde
Side-by-side diff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 4960b9a..7bd8a70 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -309,56 +309,64 @@ QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat
break;
case 'a':
put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) );
break;
case 'A':
put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) );
break;
default:
buffer[index++] = rst.at( format_index );
break;
}
escape = false;
}
}
QString ret( buffer, index );
delete [] buffer;
return ret;
}
QString KLocale::formatDateTime(const QDateTime &pDateTime,
bool shortFormat,
bool includeSeconds,
IntDateFormat intIntDateFormat) const
{
- return QString( "%1 %2")
- .arg( formatDate( pDateTime.date(), shortFormat, intIntDateFormat ) )
- .arg( formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ) );
+ QString format("%1 %2");
+
+ if ( intIntDateFormat == Default )
+ format = "%1 %2";
+ else if ( intIntDateFormat == Format1 )
+ format = "%1 %2";
+ else if ( intIntDateFormat == ISODate )
+ format = "%1T%2";
+
+ return format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat ))
+ .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ));
}
QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const
{
- return formatDateTime(pDateTime, true, intIntDateFormat);
+ return formatDateTime(pDateTime, true, true, intIntDateFormat);
}
QDate KLocale::readDate(const QString &intstr, bool* ok) const
{
QDate date;
date = readDate(intstr, true, ok);
if (date.isValid()) return date;
return readDate(intstr, false, ok);
}
QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const
{
QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace();
return readDate( intstr, fmt, ok );
}
QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const
{
//kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl;
QString str = intstr.simplifyWhiteSpace().lower();
int day = -1, month = -1;
// allow the year to be omitted if not in the format
int year = QDate::currentDate().year();
uint strpos = 0;
@@ -549,48 +557,64 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
case 'S':
second = readInt(str, strpos);
if (second < 0 || second > 59)
goto error;
break;
}
}
if (g_12h)
{
hour %= 12;
if (pm) hour += 12;
}
if (ok) *ok = true;
return QTime(hour, minute, second);
error:
if (ok) *ok = false;
return QTime(-1, -1, -1); // return invalid date if it didn't work
// This will be removed in the near future, since it gives a warning on stderr.
// The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime.
}
+QDateTime KLocale::readDateTime(const QString &intstr,
+ bool shortFormat,
+ bool includeSeconds,
+ IntDateFormat intIntDateFormat,
+ bool* ok) const
+{
+ bool ok1, ok2;
+
+ QDate m_date = readDate(date, &ok1);
+ QTime m_time = KGlobal::locale()->readTime(time, &ok2);
+ if ((ok1 == false) || (ok2 == false))
+ qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
+
+}
+
+
bool KLocale::use12Clock() const
{
return !mHourF24Format ;;
}
bool KLocale::weekStartsMonday() const
{
return mWeekStartsMonday;
}
int KLocale::weekStartDay() const
{
if ( mWeekStartsMonday )
return 1;
return 7;
}
QString KLocale::weekDayName(int i,bool shortName) const
{
if ( shortName )
switch ( i )
{
case 1: return i18n("Monday", "Mon");
case 2: return i18n("Tuesday", "Tue");