diff options
Diffstat (limited to 'src/corelib/time/qdatetime.cpp')
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 31206f779d..64943bdaaf 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -346,11 +346,10 @@ static constexpr int daysInUsualMonth(int month) // (February isn't usual.) setDate(). The fromString() function returns a QDate given a string and a date format which is used to interpret the date within the string. - The year(), month(), and day() functions provide access to the - year, month, and day numbers. Also, dayOfWeek() and dayOfYear() - functions are provided. The same information is provided in - textual format by the toString(), shortDayName(), longDayName(), - shortMonthName(), and longMonthName() functions. + The year(), month(), and day() functions provide access to the year, month, + and day numbers. Also, dayOfWeek() and dayOfYear() functions are + provided. The same information is provided in textual format by + toString(). The day and month numbers can be mapped to names using QLocale. QDate provides a full set of operators to compare two QDate objects where smaller means earlier, and larger means later. @@ -1076,11 +1075,10 @@ static QString toStringIsoDate(qint64 jd) Returns the date as a string. The \a format parameter determines the format of the string. - If the \a format is Qt::TextDate, the string is formatted in - the default way. QDate::shortDayName() and QDate::shortMonthName() - are used to generate the string, so the day and month names will - be localized names using the system locale, i.e. QLocale::system(). An - example of this formatting is "Sat May 20 1995". + If the \a format is Qt::TextDate, the string is formatted in the default + way. The day and month names will be localized names using the system + locale, i.e. QLocale::system(). An example of this formatting + is "Sat May 20 1995". If the \a format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of @@ -1112,7 +1110,7 @@ static QString toStringIsoDate(qint64 jd) range 0 to 9999. This restriction may apply to locale-aware formats as well, depending on the locale settings. - \sa fromString(), shortDayName(), shortMonthName(), QLocale::toString() + \sa fromString(), QLocale::toString() */ QString QDate::toString(Qt::DateFormat format) const { @@ -1131,7 +1129,7 @@ QString QDate::toString(Qt::DateFormat format) const case Qt::DefaultLocaleLongDate: return QLocale().toString(*this, QLocale::LongFormat); case Qt::RFC2822Date: - return QLocale::c().toString(*this, QStringViewLiteral("dd MMM yyyy")); + return QLocale::c().toString(*this, u"dd MMM yyyy"); default: #if QT_CONFIG(textdate) case Qt::TextDate: @@ -3272,10 +3270,9 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT provides functions for comparing datetimes and for manipulating a datetime by adding a number of seconds, days, months, or years. - QDateTime can describe datetimes with respect to - \l{Qt::LocalTime}{local time}, to \l{Qt::UTC}{UTC}, to a specified - \l{Qt::OffsetFromUTC}{offset from UTC} or to a specified - \l{Qt::TimeZone}{time zone}, in conjunction + QDateTime can describe datetimes with respect to \l{Qt::LocalTime}{local + time}, to \l{Qt::UTC}{UTC}, to a specified \l{Qt::OffsetFromUTC}{offset + from UTC} or to a specified \l{Qt::TimeZone}{time zone}, in conjunction with the QTimeZone class. For example, a time zone of "Europe/Berlin" will apply the daylight-saving rules as used in Germany since 1970. In contrast, an offset from UTC of +3600 seconds is one hour ahead of UTC (usually @@ -4065,12 +4062,10 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC) Returns the datetime as a string in the \a format given. - If the \a format is Qt::TextDate, the string is formatted in - the default way. QDate::shortDayName(), QDate::shortMonthName(), - and QTime::toString() are used to generate the string, so the - day and month names will be localized names using the system locale, - i.e. QLocale::system(). An example of this formatting is - "Wed May 20 03:40:13 1998". + If the \a format is Qt::TextDate, the string is formatted in the default + way. The day and month names will be localized names using the system + locale, i.e. QLocale::system(). An example of this formatting is "Wed May 20 + 03:40:13 1998". If the \a format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of @@ -4127,7 +4122,7 @@ QString QDateTime::toString(Qt::DateFormat format) const case Qt::DefaultLocaleLongDate: return QLocale().toString(*this, QLocale::LongFormat); case Qt::RFC2822Date: { - buf = QLocale::c().toString(*this, QStringViewLiteral("dd MMM yyyy hh:mm:ss ")); + buf = QLocale::c().toString(*this, u"dd MMM yyyy hh:mm:ss "); buf += toOffsetString(Qt::TextDate, offsetFromUtc()); return buf; } @@ -5239,18 +5234,14 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) \row \li dd \li the day as number with a leading zero (01 to 31) \row \li ddd \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). - Uses QDate::shortDayName(). \row \li dddd \li the long localized day name (e.g. 'Monday' to 'Sunday'). - Uses QDate::longDayName(). \row \li M \li the month as number without a leading zero (1-12) \row \li MM \li the month as number with a leading zero (01-12) \row \li MMM \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). - Uses QDate::shortMonthName(). \row \li MMMM \li the long localized month name (e.g. 'January' to 'December'). - Uses QDate::longMonthName(). \row \li yy \li the year as two digit number (00-99) \row \li yyyy \li the year as four digit number \endtable @@ -5631,7 +5622,7 @@ QDebug operator<<(QDebug dbg, const QTime &time) QDebugStateSaver saver(dbg); dbg.nospace() << "QTime("; if (time.isValid()) - dbg.nospace() << time.toString(QStringViewLiteral("HH:mm:ss.zzz")); + dbg.nospace() << time.toString(u"HH:mm:ss.zzz"); else dbg.nospace() << "Invalid"; dbg.nospace() << ')'; @@ -5644,7 +5635,7 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) dbg.nospace() << "QDateTime("; if (date.isValid()) { const Qt::TimeSpec ts = date.timeSpec(); - dbg.noquote() << date.toString(QStringViewLiteral("yyyy-MM-dd HH:mm:ss.zzz t")) + dbg.noquote() << date.toString(u"yyyy-MM-dd HH:mm:ss.zzz t") << ' ' << ts; switch (ts) { case Qt::UTC: |