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>
132#ifdef QT_BUILD_INTERNAL
168 DateTimeParts result = DateTimePart::None;
169 for (
const TemporalField &it : range)
181
182
183
184
185
186
187
188
189
190
193template <
typename Payload>
204 QList<Field> m_fields;
206 QCalendar m_calendar;
207 std::optional<
int> m_baseYear;
208 explicit QDateTimePattern(
const QList<Field> &fs) : m_fields(fs) {}
209 explicit QDateTimePattern(
const QList<Field> &fs,
int centuryStart)
210 : m_fields(fs), m_baseYear(centuryStart) {}
215 constexpr DateTimeParts NeededParts = DateTimePart::Date | DateTimePart::Time;
216 const DateTimeParts got = hasFieldsFor(m_fields);
218 if (got.testFlags(NeededParts))
219 return supports(got, m_fields, m_baseYear.has_value());
223 bool isNull()
const noexcept {
return m_fields.isEmpty(); }
233 std::optional<
int>
baseYear()
const noexcept {
return m_baseYear; }
247 auto pat = fromQtFormat(locale.dateTimeFormat(format));
248 pat.setLocale(locale);
256 QList<Field> m_fields;
258 explicit QTimePattern(
const QList<Field> &fs) : m_fields(fs) {}
263 return supports({DateTimePart::Time}, m_fields);
266 bool isNull()
const noexcept {
return m_fields.isEmpty(); }
282 auto pat = fromQtFormat(locale.timeFormat(format));
283 pat.setLocale(locale);
291 QList<Field> m_fields;
293 QCalendar m_calendar;
294 std::optional<
int> m_baseYear;
295 explicit QDatePattern(
const QList<Field> &fs) : m_fields(fs) {}
296 explicit QDatePattern(
const QList<Field> &fs,
int centuryStart)
297 : m_fields(fs), m_baseYear(centuryStart) {}
302 return supports({DateTimePart::Date}, m_fields, m_baseYear.has_value());
305 bool isNull()
const noexcept {
return m_fields.isEmpty(); }
315 std::optional<
int>
baseYear()
const noexcept {
return m_baseYear; }
328 auto pat = fromQtFormat(locale.dateFormat(format));
329 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)