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>
127#ifdef QT_BUILD_INTERNAL
163 DateTimeParts result = DateTimePart::None;
164 for (
const TemporalField &it : range)
176
177
178
179
180
181
182
183
184
185
188template <
typename Payload>
199 QList<Field> m_fields;
201 QCalendar m_calendar;
202 std::optional<
int> m_baseYear;
203 explicit QDateTimePattern(
const QList<Field> &fs) : m_fields(fs) {}
204 explicit QDateTimePattern(
const QList<Field> &fs,
int centuryStart)
205 : m_fields(fs), m_baseYear(centuryStart) {}
210 constexpr DateTimeParts NeededParts = DateTimePart::Date | DateTimePart::Time;
211 const DateTimeParts got = hasFieldsFor(m_fields);
213 if (got.testFlags(NeededParts))
214 return supports(got, m_fields, m_baseYear.has_value());
227 std::optional<
int>
baseYear()
const noexcept {
return m_baseYear; }
241 auto pat = fromQtFormat(locale.dateTimeFormat(format));
242 pat.setLocale(locale);
250 QList<Field> m_fields;
252 explicit QTimePattern(
const QList<Field> &fs) : m_fields(fs) {}
257 return supports({DateTimePart::Time}, m_fields);
275 auto pat = fromQtFormat(locale.timeFormat(format));
276 pat.setLocale(locale);
284 QList<Field> m_fields;
286 QCalendar m_calendar;
287 std::optional<
int> m_baseYear;
288 explicit QDatePattern(
const QList<Field> &fs) : m_fields(fs) {}
289 explicit QDatePattern(
const QList<Field> &fs,
int centuryStart)
290 : m_fields(fs), m_baseYear(centuryStart) {}
295 return supports({DateTimePart::Date}, m_fields, m_baseYear.has_value());
307 std::optional<
int>
baseYear()
const noexcept {
return m_baseYear; }
320 auto pat = fromQtFormat(locale.dateFormat(format));
321 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.
constexpr auto EndTemporalFieldCategories
DateTimeParts hasFieldsFor(QSpan< const TemporalField > range)
Identify the parts to which the given fields contribute data.
QT_REQUIRE_CONFIG(datestring)