Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QDateTimePattern Class Reference

A description of a serialization format for a datetime. More...

#include <qttemporalpattern_p.h>

Collaboration diagram for QDateTimePattern:

Public Member Functions

bool isNull () const noexcept
 Returns true if this pattern has no fields, otherwise false.
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< QDateTime > parse (QStringView text, const QDateTime &defaults={}) const
Q_CORE_EXPORT QString serialize (const QDateTime &datetime) const
 Serialize the given datetime to a string representation.

Static Public Member Functions

static Q_CORE_EXPORT QDateTimePattern fromQtFormat (QStringView format)
 Construct a QDateTimePattern described by the given format string.
static QDateTimePattern forLocale (const QLocale &locale, QLocale::FormatType format=QLocale::LongFormat)
 Construct a QDateTimePattern appropriate to the given locale.

Detailed Description

A description of a serialization format for a datetime.

Since
6.12

Definition at line 201 of file qttemporalpattern_p.h.

Member Function Documentation

◆ baseYear()

std::optional< int > QDateTimePattern::baseYear ( ) const
inlinenoexcept

get-base-year

Definition at line 233 of file qttemporalpattern_p.h.

◆ calendar()

QCalendar QDateTimePattern::calendar ( ) const
inlinenoexcept

Returns the current calendar in use by this pattern.

See also
setCalendar()

Definition at line 236 of file qttemporalpattern_p.h.

◆ clearBaseYear()

void QDateTimePattern::clearBaseYear ( )
inlinenoexcept

clear-base-year

Definition at line 232 of file qttemporalpattern_p.h.

◆ forLocale()

QDateTimePattern QDateTimePattern::forLocale ( const QLocale & locale,
QLocale::FormatType format = QLocale::LongFormat )
inlinestatic

Construct a QDateTimePattern appropriate to the given locale.

The format can be used to select how compact or expansive the pattern is.

See also
fromQtFormat()

Definition at line 244 of file qttemporalpattern_p.h.

◆ fromQtFormat()

QDateTimePattern QDateTimePattern::fromQtFormat ( QStringView format)
static

Construct a QDateTimePattern described by the given format string.

If the format is empty or malformed, the returned pattern's isNull() shall be true. Otherwise, isNull() shall be false.

See also
forLocale(), isNull()

Definition at line 994 of file qttemporalpattern.cpp.

◆ isNull()

bool QDateTimePattern::isNull ( ) const
inlinenoexcept

Returns true if this pattern has no fields, otherwise false.

See also
fromQtFormat()

Definition at line 223 of file qttemporalpattern_p.h.

◆ isValid()

bool QDateTimePattern::isValid ( ) const
inlinenoexcept

{is-valid} {datetime}

base-year-disambiguates

Timezone abbreviations are ambiguous.

See also
isNull()

Definition at line 224 of file qttemporalpattern_p.h.

References QtTemporalPattern::Clear.

◆ locale()

const QLocale & QDateTimePattern::locale ( ) const
inlinenoexcept

Returns the current locale in use by this pattern.

\fn QDateTimePattern::setLocale(const QLocale &loc) noexcept

! [set-locale] Sets the locale, for use for fields whose representation depends on locale, to loc. By default the application's current default locale is used.

See also
QLocale::setDefault() ! [set-locale]
setLocale()

Definition at line 229 of file qttemporalpattern_p.h.

◆ parse()

QtTemporalPattern::ParseResult< QDateTime > QDateTimePattern::parse ( QStringView text,
const QDateTime & defaults = {} ) const
Parse and return the datetime represented by \a text.

! [parser-defaults] If defaults is provided and valid, any fields the format described by this pattern does not provide will be copied from defaults to construct the returned value. ! [parser-defaults]

Definition at line 954 of file qttemporalpattern.cpp.

◆ serialize()

QString QDateTimePattern::serialize ( const QDateTime & datetime) const

Serialize the given datetime to a string representation.

Definition at line 979 of file qttemporalpattern.cpp.

◆ setBaseYear()

void QDateTimePattern::setBaseYear ( int centuryStart)
inline

set-base-year

Definition at line 231 of file qttemporalpattern_p.h.

◆ setCalendar()

void QDateTimePattern::setCalendar ( QCalendar calendar)
inline

set-calendar

Definition at line 235 of file qttemporalpattern_p.h.

◆ setLocale()

void QDateTimePattern::setLocale ( const QLocale & loc)
inline

Definition at line 228 of file qttemporalpattern_p.h.


The documentation for this class was generated from the following files: