5#ifndef QTTEMPORALPATTERN_P_H
6#define QTTEMPORALPATTERN_P_H
19#include <QtCore/qcalendar.h>
20#include <QtCore/qdatetime.h>
21#include <QtCore/qflags.h>
22#include <QtCore/qlist.h>
23#include <QtCore/qlocale.h>
24#include <QtCore/qmetaobject.h>
25#include <QtCore/qspan.h>
26#include <QtCore/qstring.h>
27#include <QtCore/qstringview.h>
136#ifdef QT_BUILD_INTERNAL
172 DateTimeParts result = DateTimePart::None;
173 for (
const TemporalField &it : range)
185
186
187
188
189
190
191
192
193
194
195
198template <
typename Payload>
209 QList<Field> m_fields;
211 QCalendar m_calendar;
212 std::optional<
int> m_baseYear;
213 explicit QDateTimePattern(
const QList<Field> &fs) : m_fields(fs) {}
214 explicit QDateTimePattern(
const QList<Field> &fs,
int centuryStart)
215 : m_fields(fs), m_baseYear(centuryStart) {}
220 constexpr DateTimeParts NeededParts = DateTimePart::Date | DateTimePart::Time;
221 const DateTimeParts got = hasFieldsFor(m_fields);
223 if (got.testFlags(NeededParts))
224 return supports(got, m_fields, m_baseYear.has_value());
228 bool isNull()
const noexcept {
return m_fields.isEmpty(); }
238 std::optional<
int>
baseYear()
const noexcept {
return m_baseYear; }
252 auto pat = fromQtFormat(locale.dateTimeFormat(format));
253 pat.setLocale(locale);
261 QList<Field> m_fields;
263 explicit QTimePattern(
const QList<Field> &fs) : m_fields(fs) {}
268 return supports({DateTimePart::Time}, m_fields);
271 bool isNull()
const noexcept {
return m_fields.isEmpty(); }
287 auto pat = fromQtFormat(locale.timeFormat(format));
288 pat.setLocale(locale);
296 QList<Field> m_fields;
298 QCalendar m_calendar;
299 std::optional<
int> m_baseYear;
300 explicit QDatePattern(
const QList<Field> &fs) : m_fields(fs) {}
301 explicit QDatePattern(
const QList<Field> &fs,
int centuryStart)
302 : m_fields(fs), m_baseYear(centuryStart) {}
307 return supports({DateTimePart::Date}, m_fields, m_baseYear.has_value());
310 bool isNull()
const noexcept {
return m_fields.isEmpty(); }
320 std::optional<
int>
baseYear()
const noexcept {
return m_baseYear; }
333 auto pat = fromQtFormat(locale.dateFormat(format));
334 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
bool isNull() const noexcept
Returns true if this pattern has no fields, otherwise false.
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.
bool isNull() const noexcept
Returns true if this pattern has no fields, otherwise false.
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.
bool isNull() const noexcept
Returns true if this pattern has no fields, otherwise false.
const QLocale & locale() const noexcept
Returns the current locale in use by this pattern.
Supporting types and functions for temporal patterns.
constexpr auto EndTemporalFieldCategories
DateTimeParts hasFieldsFor(QSpan< const TemporalField > range)
Identify the parts to which the given fields contribute data.
QT_REQUIRE_CONFIG(datestring)