Doc: Fixed date format doc bug in QDateTime/Qt namespace
MM stands for month, SS is invalid mostly cherry picked from Qt4 commit 670f460fab6a386407c07281cf6417ccf6430970. Task-number: QTBUG-12236 Change-Id: I7af4be655d2d10f1befa1366abb48225c60d31dc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
acf80b9a2b
commit
a457bf3ff7
@ -592,7 +592,7 @@
|
||||
string, "ddd MMM d yyyy". See QDate::toString() for more information.
|
||||
|
||||
\value ISODate \l{ISO 8601} extended format: either \c{YYYY-MM-DD} for dates or
|
||||
\c{YYYY-MM-DDTHH:MM:SS}, \c{YYYY-MM-DDTHH:MM:SSTZD} (e.g., 1997-07-16T19:20:30+01:00)
|
||||
\c{YYYY-MM-DDTHH:mm:ss}, \c{YYYY-MM-DDTHH:mm:ssTZD} (e.g., 1997-07-16T19:20:30+01:00)
|
||||
for combined dates and times.
|
||||
|
||||
\value SystemLocaleShortDate The \l{QLocale::ShortFormat}{short format} used
|
||||
|
@ -182,7 +182,7 @@ static void rfcDateImpl(const QString &s, QDate *dd = 0, QTime *dt = 0, int *utc
|
||||
int minOffset = 0;
|
||||
bool positiveOffset = false;
|
||||
|
||||
// Matches "Wdy, DD Mon YYYY HH:MM:SS ±hhmm" (Wdy, being optional)
|
||||
// Matches "Wdy, DD Mon YYYY HH:mm:ss ±hhmm" (Wdy, being optional)
|
||||
QRegExp rex(QStringLiteral("^(?:[A-Z][a-z]+,)?[ \\t]*(\\d{1,2})[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d)(?::(\\d\\d))?)?[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
|
||||
if (s.indexOf(rex) == 0) {
|
||||
if (dd) {
|
||||
@ -203,7 +203,7 @@ static void rfcDateImpl(const QString &s, QDate *dd = 0, QTime *dt = 0, int *utc
|
||||
if (utcOffset)
|
||||
*utcOffset = ((hourOffset * 60 + minOffset) * (positiveOffset ? 60 : -60));
|
||||
} else {
|
||||
// Matches "Wdy Mon DD HH:MM:SS YYYY"
|
||||
// Matches "Wdy Mon DD HH:mm:ss YYYY"
|
||||
QRegExp rex(QStringLiteral("^[A-Z][a-z]+[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d):(\\d\\d))?[ \\t]+(\\d\\d\\d\\d)[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
|
||||
if (s.indexOf(rex) == 0) {
|
||||
if (dd) {
|
||||
@ -233,7 +233,7 @@ static void rfcDateImpl(const QString &s, QDate *dd = 0, QTime *dt = 0, int *utc
|
||||
}
|
||||
#endif // QT_NO_DATESTRING
|
||||
|
||||
// Return offset in [+-]HH:MM format
|
||||
// Return offset in [+-]HH:mm format
|
||||
// Qt::ISODate puts : between the hours and minutes, but Qt:TextDate does not
|
||||
static QString toOffsetString(Qt::DateFormat format, int offset)
|
||||
{
|
||||
@ -248,7 +248,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset)
|
||||
.arg((qAbs(offset) / 60) % 60, 2, 10, QLatin1Char('0'));
|
||||
}
|
||||
|
||||
// Parse offset in [+-]HH[[:]MM] format
|
||||
// Parse offset in [+-]HH[[:]mm] format
|
||||
static int fromOffsetString(const QString &offsetString, bool *valid)
|
||||
{
|
||||
*valid = false;
|
||||
@ -272,7 +272,7 @@ static int fromOffsetString(const QString &offsetString, bool *valid)
|
||||
// Split the hour and minute parts
|
||||
QStringList parts = offsetString.mid(1).split(QLatin1Char(':'));
|
||||
if (parts.count() == 1) {
|
||||
// [+-]HHMM or [+-]HH format
|
||||
// [+-]HHmm or [+-]HH format
|
||||
parts.append(parts.at(0).mid(2));
|
||||
parts[0] = parts.at(0).left(2);
|
||||
}
|
||||
@ -1598,12 +1598,12 @@ int QTime::msec() const
|
||||
Returns the time as a string. The \a format parameter determines
|
||||
the format of the string.
|
||||
|
||||
If \a format is Qt::TextDate, the string format is HH:MM:SS;
|
||||
If \a format is Qt::TextDate, the string format is HH:mm:ss;
|
||||
e.g. 1 second before midnight would be "23:59:59".
|
||||
|
||||
If \a format is Qt::ISODate, the string format corresponds to the
|
||||
ISO 8601 extended specification for representations of dates,
|
||||
which is also HH:MM:SS.
|
||||
which is also HH:mm:ss.
|
||||
|
||||
If the \a format is Qt::SystemLocaleShortDate or
|
||||
Qt::SystemLocaleLongDate, the string format depends on the locale
|
||||
@ -1925,13 +1925,13 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format,
|
||||
int msec = 0;
|
||||
|
||||
if (size == 5) {
|
||||
// HH:MM format
|
||||
// HH:mm format
|
||||
second = 0;
|
||||
msec = 0;
|
||||
} else if (string.at(5) == QLatin1Char(',') || string.at(5) == QLatin1Char('.')) {
|
||||
if (format == Qt::TextDate)
|
||||
return QTime();
|
||||
// ISODate HH:MM.SSSSSS format
|
||||
// ISODate HH:mm.ssssss format
|
||||
// We only want 5 digits worth of fraction of minute. This follows the existing
|
||||
// behavior that determines how milliseconds are read; 4 millisecond digits are
|
||||
// read and then rounded to 3. If we read at most 5 digits for fraction of minute,
|
||||
@ -1951,7 +1951,7 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format,
|
||||
second = secondNoMs;
|
||||
msec = qMin(qRound(secondFraction * 1000.0), 999);
|
||||
} else {
|
||||
// HH:MM:SS or HH:MM:SS.sssss
|
||||
// HH:mm:ss or HH:mm:ss.zzz
|
||||
second = string.mid(6, 2).toInt(&ok);
|
||||
if (!ok)
|
||||
return QTime();
|
||||
@ -3535,7 +3535,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
|
||||
|
||||
If the \a format is Qt::ISODate, the string format corresponds
|
||||
to the ISO 8601 extended specification for representations of
|
||||
dates and times, taking the form YYYY-MM-DDTHH:MM:SS[Z|[+|-]HH:MM],
|
||||
dates and times, taking the form YYYY-MM-DDTHH:mm:ss[Z|[+|-]HH:mm],
|
||||
depending on the timeSpec() of the QDateTime. If the timeSpec()
|
||||
is Qt::UTC, Z will be appended to the string; if the timeSpec() is
|
||||
Qt::OffsetFromUTC, the offset in hours and minutes from UTC will
|
||||
@ -4421,7 +4421,7 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format)
|
||||
|
||||
isoString = isoString.right(isoString.length() - 11);
|
||||
int offset = 0;
|
||||
// Check end of string for Time Zone definition, either Z for UTC or [+-]HH:MM for Offset
|
||||
// Check end of string for Time Zone definition, either Z for UTC or [+-]HH:mm for Offset
|
||||
if (isoString.endsWith(QLatin1Char('Z'))) {
|
||||
spec = Qt::UTC;
|
||||
isoString = isoString.left(isoString.size() - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user