summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qdatetimeparser_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/time/qdatetimeparser_p.h')
-rw-r--r--src/corelib/time/qdatetimeparser_p.h73
1 files changed, 20 insertions, 53 deletions
diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h
index 6f44c34949..9720ee2ef1 100644
--- a/src/corelib/time/qdatetimeparser_p.h
+++ b/src/corelib/time/qdatetimeparser_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QDATETIMEPARSER_P_H
#define QDATETIMEPARSER_P_H
@@ -140,7 +104,7 @@ public:
struct Q_CORE_EXPORT SectionNode {
Section type;
mutable int pos;
- int count;
+ int count; // (used as Case(count) indicator for AmPmSection)
int zeroesAdded;
static QString name(Section s);
@@ -170,15 +134,11 @@ public:
PmText
};
- enum Case {
- UpperCase,
- LowerCase
- };
-
StateNode parse(const QString &input, int position,
const QDateTime &defaultValue, bool fixup) const;
- bool fromString(const QString &text, QDate *date, QTime *time) const;
- bool fromString(const QString &text, QDateTime* datetime) const;
+ bool fromString(const QString &text, QDate *date, QTime *time,
+ int baseYear = QLocale::DefaultTwoDigitBaseYear) const;
+ bool fromString(const QString &text, QDateTime *datetime, int baseYear) const;
bool parseFormat(QStringView format);
enum FieldInfoFlag {
@@ -210,16 +170,14 @@ private:
{}
};
ParsedSection parseSection(const QDateTime &currentValue, int sectionIndex, int offset) const;
- int findMonth(const QString &str1, int monthstart, int sectionIndex,
+ int findMonth(QStringView str, int monthstart, int sectionIndex,
int year, QString *monthName = nullptr, int *used = nullptr) const;
- int findDay(const QString &str1, int intDaystart, int sectionIndex,
+ int findDay(QStringView str, int intDaystart, int sectionIndex,
QString *dayName = nullptr, int *used = nullptr) const;
- ParsedSection findUtcOffset(QStringView str) const;
+ ParsedSection findUtcOffset(QStringView str, int mode) const;
ParsedSection findTimeZoneName(QStringView str, const QDateTime &when) const;
ParsedSection findTimeZone(QStringView str, const QDateTime &when,
- int maxVal, int minVal) const;
- // Implemented in qdatetime.cpp:
- static int startsWithLocalTimeZone(const QStringView name);
+ int maxVal, int minVal, int mode) const;
enum AmPmFinder {
Neither = -1,
@@ -239,6 +197,15 @@ private:
return potentialValue(QStringView(str), min, max, index, currentValue, insert);
}
+ enum Case {
+ NativeCase,
+ LowerCase,
+ UpperCase
+ };
+
+ QString getAmPmText(AmPm ap, Case cs) const;
+ QDateTime baseDate(const QTimeZone &zone) const;
+
friend class QDTPUnitTestParser;
protected: // for the benefit of QDateTimeEditPrivate
@@ -262,7 +229,6 @@ protected: // for the benefit of QDateTimeEditPrivate
return skipToNextSection(section, current, QStringView(sectionText));
}
QString stateName(State s) const;
- QString getAmPmText(AmPm ap, Case cs) const;
virtual QDateTime getMinimum() const;
virtual QDateTime getMaximum() const;
@@ -270,6 +236,7 @@ protected: // for the benefit of QDateTimeEditPrivate
virtual QLocale locale() const { return defaultLocale; }
mutable int currentSectionIndex = int(NoSectionIndex);
+ mutable int defaultCenturyStart = QLocale::DefaultTwoDigitBaseYear;
Sections display;
/*
This stores the most recently selected day.