2f440169c0
In the process actually handle all time-spec cases in various places that only handled UTC or LocalTime, or at least note that they don't where that's not practical. Also tidy up header ordering and ensure QDateTime's header is included wherever it's used, while adding the include for QTimeZone where needed. Task-number: QTBUG-108199 Change-Id: Ic1a5cdf0aaf737bf1396aa8ac58ce2004cef7e19 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
#include <QtCore/QDateTime>
|
|
#include <QtCore/QTimeZone>
|
|
#include <QTest>
|
|
|
|
/*!
|
|
\internal
|
|
*/
|
|
class tst_DateTime: public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void dateTime() const;
|
|
void qurl() const;
|
|
void qurl_data() const;
|
|
};
|
|
|
|
void tst_DateTime::dateTime() const
|
|
{
|
|
const auto twoMinutes = std::chrono::minutes{2};
|
|
const QDateTime utc(QDate(2000, 5, 3), QTime(4, 3, 4), QTimeZone::UTC);
|
|
const QDateTime local(QDate(2000, 5, 3), QTime(4, 3, 4),
|
|
QTimeZone::fromDurationAheadOfUtc(twoMinutes));
|
|
|
|
QCOMPARE(local, utc);
|
|
}
|
|
|
|
void tst_DateTime::qurl() const
|
|
{
|
|
QFETCH(QUrl, operandA);
|
|
QFETCH(QUrl, operandB);
|
|
|
|
QCOMPARE(operandA, operandB);
|
|
}
|
|
|
|
void tst_DateTime::qurl_data() const
|
|
{
|
|
QTest::addColumn<QUrl>("operandA");
|
|
QTest::addColumn<QUrl>("operandB");
|
|
|
|
QTest::newRow("empty urls") << QUrl() << QUrl();
|
|
QTest::newRow("empty rhs") << QUrl(QLatin1String("http://example.com")) << QUrl();
|
|
QTest::newRow("empty lhs") << QUrl() << QUrl(QLatin1String("http://example.com"));
|
|
QTest::newRow("same urls") << QUrl(QLatin1String("http://example.com")) << QUrl(QLatin1String("http://example.com"));
|
|
}
|
|
|
|
QTEST_MAIN(tst_DateTime)
|
|
|
|
#include "tst_datetime.moc"
|