4#ifndef QTTEMPORALPATTERN_P_H
5#define QTTEMPORALPATTERN_P_H
18#include <QtCore/qcalendar.h>
19#include <QtCore/qdatetime.h>
20#include <QtCore/qflags.h>
21#include <QtCore/qlist.h>
22#include <QtCore/qlocale.h>
23#include <QtCore/qmetaobject.h>
24#include <QtCore/qspan.h>
25#include <QtCore/qstring.h>
26#include <QtCore/qstringview.h>
123#ifdef QT_BUILD_INTERNAL
159 DateTimeParts result = DateTimePart::None;
160 for (
const TemporalField &it : range)
172
173
174
175
176
177
178
179
180
181
184template <
typename Payload>
195 QList<Field> m_fields;
197 QCalendar m_calendar;
198 std::optional<
int> m_baseYear;
199 explicit QDateTimePattern(
const QList<Field> &fs) : m_fields(fs) {}
200 explicit QDateTimePattern(
const QList<Field> &fs,
int centuryStart)
201 : m_fields(fs), m_baseYear(centuryStart) {}
206 constexpr DateTimeParts NeededParts = DateTimePart::Date | DateTimePart::Time;
207 const DateTimeParts got = hasFieldsFor(m_fields);
209 if (got.testFlags(NeededParts))
210 return supports(got, m_fields, m_baseYear.has_value());
223 std::optional<
int>
baseYear()
const noexcept {
return m_baseYear; }
237 auto pat = fromQtFormat(locale.dateTimeFormat(format));
238 pat.setLocale(locale);
246 QList<Field> m_fields;
248 explicit QTimePattern(
const QList<Field> &fs) : m_fields(fs) {}
253 return supports({DateTimePart::Time}, m_fields);
271 auto pat = fromQtFormat(locale.timeFormat(format));
272 pat.setLocale(locale);
280 QList<Field> m_fields;
282 QCalendar m_calendar;
283 std::optional<
int> m_baseYear;
284 explicit QDatePattern(
const QList<Field> &fs) : m_fields(fs) {}
285 explicit QDatePattern(
const QList<Field> &fs,
int centuryStart)
286 : m_fields(fs), m_baseYear(centuryStart) {}
291 return supports({DateTimePart::Date}, m_fields, m_baseYear.has_value());
303 std::optional<
int>
baseYear()
const noexcept {
return m_baseYear; }
316 auto pat = fromQtFormat(locale.dateFormat(format));
317 pat.setLocale(locale);
A description of a serialization format for a date.
void setBaseYear(int centuryStart)
const QLocale & locale() const noexcept
Returns the current locale in use by this pattern.
QCalendar calendar() const noexcept
Returns the current calendar in use by this pattern.
bool isValid() const noexcept
static QDatePattern forLocale(const QLocale &locale, QLocale::FormatType format=QLocale::LongFormat)
Construct a QDatePattern appropriate to the given locale.
void setCalendar(QCalendar cal)
void setLocale(const QLocale &loc)
void clearBaseYear() noexcept
std::optional< int > baseYear() const noexcept
A description of a serialization format for a datetime.
bool isValid() const noexcept
void clearBaseYear() noexcept
void setBaseYear(int centuryStart)
QCalendar calendar() const noexcept
Returns the current calendar in use by this pattern.
void setCalendar(QCalendar cal)
static QDateTimePattern forLocale(const QLocale &locale, QLocale::FormatType format=QLocale::LongFormat)
Construct a QDateTimePattern appropriate to the given locale.
std::optional< int > baseYear() const noexcept
void setLocale(const QLocale &loc)
const QLocale & locale() const noexcept
Returns the current locale in use by this pattern.
A description of a serialization format for a time.
void setLocale(const QLocale &loc)
bool isValid() const noexcept
static QTimePattern forLocale(const QLocale &locale, QLocale::FormatType format=QLocale::LongFormat)
Construct a QTimePattern appropriate to the given locale.
const QLocale & locale() const noexcept
Returns the current locale in use by this pattern.
Supporting types and functions for temporal patterns.
DateTimeParts hasFieldsFor(QSpan< const TemporalField > range)
Identify the parts to which the given fields contribute data.
QT_REQUIRE_CONFIG(datestring)