![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
A description of a serialization format for a date. More...
#include <qttemporalpattern_p.h>
Public Member Functions | |
| bool | isValid () const noexcept |
| void | setLocale (const QLocale &loc) |
| const QLocale & | locale () const noexcept |
| Returns the current locale in use by this pattern. | |
| void | setBaseYear (int centuryStart) |
| void | clearBaseYear () noexcept |
| std::optional< int > | baseYear () const noexcept |
| void | setCalendar (QCalendar cal) |
| QCalendar | calendar () const noexcept |
| Returns the current calendar in use by this pattern. | |
| Q_CORE_EXPORT QtTemporalPattern::ParseResult< QDate > | parse (QStringView text, QDate defaults={}) const |
| Parse and return the date represented by text. | |
| Q_CORE_EXPORT QString | serialize (const QDate &date) const |
| Serialize the given date to a string representation. | |
Static Public Member Functions | |
| static Q_CORE_EXPORT QDatePattern | fromQtFormat (QStringView format) |
| Construct a QDatePattern described by the given format string. | |
| static QDatePattern | forLocale (const QLocale &locale, QLocale::FormatType format=QLocale::LongFormat) |
| Construct a QDatePattern appropriate to the given locale. | |
A description of a serialization format for a date.
Definition at line 277 of file qttemporalpattern_p.h.
|
inlinenoexcept |
Definition at line 303 of file qttemporalpattern_p.h.
|
inlinenoexcept |
Returns the current calendar in use by this pattern.
\fn QDatePattern::setCalendar(QCalendar calendar) noexcept
! [set-calendar] Sets the calendar used by this pattern. This influences the names and lengths of months and how these vary from year to year. In some cases it may also influence the number of months in the year or even the pattern and names of days of the week.
By default the Gregorian calendar is used.
Definition at line 306 of file qttemporalpattern_p.h.
|
inlinenoexcept |
Definition at line 302 of file qttemporalpattern_p.h.
|
inlinestatic |
Construct a QDatePattern appropriate to the given locale.
The format can be used to select how compact or expansive the pattern is.
Definition at line 314 of file qttemporalpattern_p.h.
|
static |
Construct a QDatePattern described by the given format string.
Definition at line 1196 of file qttemporalpattern.cpp.
|
inlinenoexcept |
Definition at line 294 of file qttemporalpattern_p.h.
References QtTemporalPattern::Clear.
|
inlinenoexcept |
Returns the current locale in use by this pattern.
Definition at line 299 of file qttemporalpattern_p.h.
| QtTemporalPattern::ParseResult< QDate > QDatePattern::parse | ( | QStringView | text, |
| QDate | defaults = {} ) const |
Parse and return the date represented by text.
\fn QDatePattern::setBaseYear(int centuryStart) noexcept
! [set-base-year] Configures the handling of two-digit years, if any are present in the pattern.
If a two-digit year is present, the year ending in those two digits in the range from centuryStart to {centuryStart + 99} shall be its default interpretation. This may be amended if the month, day of the month and day of the week indicate some other nearby century.
{calendar()}, whose year numbering need not match that of the Gregorian calendar.Calling this method makes no difference unless the pattern does in fact use a two-digit year, nor does it affect serialization.
\fn QDatePattern::clearBaseYear() noexcept
! [clear-base-year] Leaves the handling of two-digit years to other fields to disambiguate.
This is the default state, so has no effect unless \l setBaseYear() has previously been called.
If a two-digit year is present, this leaves unspecified which hundred years to presume it lies within. If a two-digit year is present and other fields of the pattern do not suffice to make clear which hundred years to select based on the given last two digits, the text produced when serializing with this format shall generally be ambiguous. While readers of the text may be able to disambiguate the year anyway, there is scope for misunderstanding if their heuristics for doing so do not match your expectation. On parsing, the pattern may deliver a result that is off by some whole number of centuries from what the parsed text's author intended.
\fn QDatePattern::baseYear() const noexcept
! [get-base-year]
Returns the current base year, with respect to \c{calendar()}, used by this
pattern if it needs to resolve a two-digit year. The result is \c
{std::nullopt} when no base year is set, which is the default state.
\sa setBaseYear()
! [get-base-year]
parser-defaults
Definition at line 1164 of file qttemporalpattern.cpp.
Serialize the given date to a string representation.
Definition at line 1184 of file qttemporalpattern.cpp.
|
inline |
Definition at line 301 of file qttemporalpattern_p.h.
Definition at line 305 of file qttemporalpattern_p.h.
\fn QDatePattern::isValid() const noexcept
\include qttemporalpattern.cpp {is-valid} {date}
! [base-year-disambiguates] The ambiguity of two-digit years may be resolved by configuring the hundred years among which to select a matching years. ! [base-year-disambiguates]
\sa setBaseYear()
set-locale
Definition at line 298 of file qttemporalpattern_p.h.