Commit bb2fbaec authored by David Jarvie's avatar David Jarvie
Browse files

Replace deprecated Qt calls

parent 7ecc875a
......@@ -3301,31 +3301,33 @@ void KADateTimeTest::strings_format()
qputenv("TZ", ":America/Los_Angeles");
::tzset();
QLocale locale;
// toString()
QString all = QStringLiteral("%Y.%y.%m.%:m.%B.%b.%d.%e.%A.%a-%H.%k.%I.%l.%M.%S?%:s?%P.%p.%:u.%z.%Z.%:Z.%:A.%:a.%:B.%:b/%:S.%:z.%%.");
KADateTime dt(QDate(1999, 2, 3), QTime(6, 5, 0), KADateTime::LocalZone);
QString s = dt.toString(all);
QCOMPARE(s, QStringLiteral("1999.99.02.2.%1.%2.03.3.%3.%4-06.6.06.6.05.00?000?am.AM.-08.-0800.PST.America/Los_Angeles.Wednesday.Wed.February.Feb/.-08:00.%.")
.arg(QDate::longMonthName(2))
.arg(QDate::shortMonthName(2))
.arg(QDate::longDayName(3))
.arg(QDate::shortDayName(3)));
.arg(locale.monthName(2, QLocale::LongFormat))
.arg(locale.monthName(2, QLocale::ShortFormat))
.arg(locale.dayName(3, QLocale::LongFormat))
.arg(locale.dayName(3, QLocale::ShortFormat)));
KADateTime dtzone(QDate(1970, 4, 30), QTime(12, 45, 16, 25), london);
s = dtzone.toString(all);
QCOMPARE(s, QStringLiteral("1970.70.04.4.%1.%2.30.30.%3.%4-12.12.12.12.45.16?025?pm.PM.+01.+0100.BST.Europe/London.Thursday.Thu.April.Apr/:16.+01:00.%.")
.arg(QDate::longMonthName(4))
.arg(QDate::shortMonthName(4))
.arg(QDate::longDayName(4))
.arg(QDate::shortDayName(4)));
.arg(locale.monthName(4, QLocale::LongFormat))
.arg(locale.monthName(4, QLocale::ShortFormat))
.arg(locale.dayName(4, QLocale::LongFormat))
.arg(locale.dayName(4, QLocale::ShortFormat)));
KADateTime dtutc(QDate(2000, 12, 31), QTime(13, 45, 16, 100), KADateTime::UTC);
s = dtutc.toString(all);
QCOMPARE(s, QStringLiteral("2000.00.12.12.%1.%2.31.31.%3.%4-13.13.01.1.45.16?100?pm.PM.+00.+0000.UTC.UTC.Sunday.Sun.December.Dec/:16.+00:00.%.")
.arg(QDate::longMonthName(12))
.arg(QDate::shortMonthName(12))
.arg(QDate::longDayName(7))
.arg(QDate::shortDayName(7)));
.arg(locale.monthName(12, QLocale::LongFormat))
.arg(locale.monthName(12, QLocale::ShortFormat))
.arg(locale.dayName(7, QLocale::LongFormat))
.arg(locale.dayName(7, QLocale::ShortFormat)));
// fromString() without QList<QTimeZone> parameter
dt = KADateTime::fromString(QStringLiteral("2005/9/05/20:2,03"), QStringLiteral("%Y/%:m/%d/%S:%k,%M"));
......@@ -3334,16 +3336,16 @@ void KADateTimeTest::strings_format()
QCOMPARE(dt.timeType(), KADateTime::LocalZone);
dt = KADateTime::fromString(QStringLiteral("%1pm05ab%2t/052/20:2,03+10")
.arg(QDate::longDayName(1))
.arg(QDate::longMonthName(9)),
.arg(locale.dayName(1, QLocale::LongFormat))
.arg(locale.monthName(9, QLocale::LongFormat)),
QStringLiteral("%a%p%yab%Bt/%e2/%S:%l,%M %z"));
QCOMPARE(dt.date(), QDate(2005, 9, 5));
QCOMPARE(dt.time(), QTime(14, 3, 20));
QCOMPARE(dt.timeType(), KADateTime::OffsetFromUTC);
QCOMPARE(dt.utcOffset(), 10 * 3600);
dt = KADateTime::fromString(QStringLiteral("%1pm05ab%2t/052/20:2,03+10")
.arg(QDate::shortDayName(1))
.arg(QDate::shortMonthName(9)),
.arg(locale.dayName(1, QLocale::ShortFormat))
.arg(locale.monthName(9, QLocale::ShortFormat)),
QStringLiteral("%a%p%yab%Bt/%d2/%s:%l,%:M %z"));
QCOMPARE(dt.date(), QDate(2005, 9, 5));
QCOMPARE(dt.time(), QTime(14, 3, 20));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment