summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore/klocale.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdecore/klocale.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 7bd8a70..17031c7 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -534,218 +534,240 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
g_12h = false;
hour = readInt(str, strpos);
if (hour < 0 || hour > 23)
goto error;
break;
case 'l':
case 'I':
g_12h = true;
hour = readInt(str, strpos);
if (hour < 1 || hour > 12)
goto error;
break;
case 'M':
minute = readInt(str, strpos);
if (minute < 0 || minute > 59)
goto error;
break;
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);
+ // AT the moment we can not read any other format then ISODate
+ if ( intIntDateFormat != ISODate )
+ {
+ qDebug("KLocale::readDateTime, only ISODate is supported.");
+ return QDateTime();
+ }
+
+ int pos = intstr.find("T");
+ QString date = intstr.left(pos);
+ QString time = intstr.mid(pos+1);
+
+ QString dformat = dateFormat(intIntDateFormat);
+ QString tformat = timeFormat(intIntDateFormat);
+
+ QDate m_date = readDate(date, dformat, &ok1);
+ QTime m_time = readTime(time, tformat, &ok2);
+
+ if (ok)
+ {
if ((ok1 == false) || (ok2 == false))
- qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
+ *ok = false;
+ else
+ *ok = true;
+ }
+ QDateTime m_dt;
+ m_dt.setDate(m_date);
+ m_dt.setTime(m_time);
+ qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
+ return m_dt;
}
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");
case 3: return i18n("Wednesday", "Wed");
case 4: return i18n("Thursday", "Thu");
case 5: return i18n("Friday", "Fri");
case 6: return i18n("Saturday", "Sat");
case 7: return i18n("Sunday", "Sun");
}
else
switch ( i )
{
case 1: return i18n("Monday");
case 2: return i18n("Tuesday");
case 3: return i18n("Wednesday");
case 4: return i18n("Thursday");
case 5: return i18n("Friday");
case 6: return i18n("Saturday");
case 7: return i18n("Sunday");
}
return QString::null;
}
QString KLocale::monthName(int i,bool shortName) const
{
if ( shortName )
switch ( i )
{
case 1: return i18n("January", "Jan");
case 2: return i18n("February", "Feb");
case 3: return i18n("March", "Mar");
case 4: return i18n("April", "Apr");
case 5: return i18n("May short", "May");
case 6: return i18n("June", "Jun");
case 7: return i18n("July", "Jul");
case 8: return i18n("August", "Aug");
case 9: return i18n("September", "Sep");
case 10: return i18n("October", "Oct");
case 11: return i18n("November", "Nov");
case 12: return i18n("December", "Dec");
}
else
switch (i)
{
case 1: return i18n("January");
case 2: return i18n("February");
case 3: return i18n("March");
case 4: return i18n("April");
case 5: return i18n("May long", "May");
case 6: return i18n("June");
case 7: return i18n("July");
case 8: return i18n("August");
case 9: return i18n("September");
case 10: return i18n("October");
case 11: return i18n("November");
case 12: return i18n("December");
}
return QString::null;
}
QString KLocale::country() const
{
return QString::null;
}
QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
{
const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
+ if ( dformat == ISODate )
+ return "%Y-%m-%d";
+
if ( QApplication::desktop()->width() < 480 ) {
if ( dformat == Default )
return "%a %d %b %Y";
else if ( dformat == Format1 )
return "%a %b %d %Y";
- else if ( dformat == ISODate )
- return "%a %Y %b %d";
} else {
-
if ( dformat == Default )
return "%A %d %B %Y";
else if ( dformat == Format1 )
return "%A %B %d %Y";
- else if ( dformat == ISODate )
- return "%A %Y %B %d";
+
}
return mDateFormat ;
}
QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const
{
const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
if ( dformat == Default )
return "%d.%m.%Y";
else if ( dformat == Format1 )
return "%m.%d.%Y";
else if ( dformat == ISODate ) // = Qt::ISODate
return "%Y-%m-%d";
return mDateFormatShort ;
}
QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const
{
const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat;
if ( tformat == Default )
if ( mHourF24Format)
return "%H:%M:%S";
else
return "%I:%M:%S%p";
else if ( tformat == Format1 )
if ( mHourF24Format)
return "%H:%M:%S";
else
return "%I:%M:%S%p";
else if ( tformat == ISODate ) // = Qt::ISODate
if ( mHourF24Format)
return "%H:%M:%S";
else
return "%I:%M:%S%p";
}
void KLocale::insertCatalogue ( const QString & )
{
}
KCalendarSystem *KLocale::calendar()