Use actual ± instead of +/- or [+-] in QDateTime docs and comments

Several places already did, and it reads better, so be consistent.

Change-Id: Ic272b2d342cec06ec657c3d0995258b975e0bf87
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2023-09-27 18:47:25 +02:00
parent ffe8932ef3
commit c6c0a7bd01

View File

@ -280,7 +280,7 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s)
} }
#endif // datestring #endif // datestring
// Return offset in [+-]HH:mm format // Return offset in ±HH:mm format
static QString toOffsetString(Qt::DateFormat format, int offset) static QString toOffsetString(Qt::DateFormat format, int offset)
{ {
return QString::asprintf("%c%02d%s%02d", return QString::asprintf("%c%02d%s%02d",
@ -292,7 +292,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset)
} }
#if QT_CONFIG(datestring) #if QT_CONFIG(datestring)
// Parse offset in [+-]HH[[:]mm] format // Parse offset in ±HH[[:]mm] format
static int fromOffsetString(QStringView offsetString, bool *valid) noexcept static int fromOffsetString(QStringView offsetString, bool *valid) noexcept
{ {
*valid = false; *valid = false;
@ -318,7 +318,7 @@ static int fromOffsetString(QStringView offsetString, bool *valid) noexcept
qsizetype hhLen = time.indexOf(u':'); qsizetype hhLen = time.indexOf(u':');
qsizetype mmIndex; qsizetype mmIndex;
if (hhLen == -1) if (hhLen == -1)
mmIndex = hhLen = 2; // [+-]HHmm or [+-]HH format mmIndex = hhLen = 2; // ±HHmm or ±HH format
else else
mmIndex = hhLen + 1; mmIndex = hhLen + 1;
@ -1491,7 +1491,7 @@ QDate QDate::addYears(int nyears, QCalendar cal) const
int old_y = parts.year; int old_y = parts.year;
parts.year += nyears; parts.year += nyears;
// If we just crossed (or hit) a missing year zero, adjust year by +/- 1: // If we just crossed (or hit) a missing year zero, adjust year by ±1:
if (!cal.hasYearZero() && ((old_y > 0) != (parts.year > 0) || !parts.year)) if (!cal.hasYearZero() && ((old_y > 0) != (parts.year > 0) || !parts.year))
parts.year += nyears > 0 ? +1 : -1; parts.year += nyears > 0 ? +1 : -1;
@ -1514,7 +1514,7 @@ QDate QDate::addYears(int nyears) const
int old_y = parts.year; int old_y = parts.year;
parts.year += nyears; parts.year += nyears;
// If we just crossed (or hit) a missing year zero, adjust year by +/- 1: // If we just crossed (or hit) a missing year zero, adjust year by ±1:
if ((old_y > 0) != (parts.year > 0) || !parts.year) if ((old_y > 0) != (parts.year > 0) || !parts.year)
parts.year += nyears > 0 ? +1 : -1; parts.year += nyears > 0 ? +1 : -1;
@ -3393,10 +3393,10 @@ QDateTime::Data QDateTimePrivate::create(QDate toDate, QTime toTime, const QTime
The range of values that QDateTime can represent is dependent on the The range of values that QDateTime can represent is dependent on the
internal storage implementation. QDateTime is currently stored in a qint64 internal storage implementation. QDateTime is currently stored in a qint64
as a serial msecs value encoding the date and time. This restricts the date as a serial msecs value encoding the date and time. This restricts the date
range to about +/- 292 million years, compared to the QDate range of +/- 2 range to about ±292 million years, compared to the QDate range of ±2 billion
billion years. Care must be taken when creating a QDateTime with extreme years. Care must be taken when creating a QDateTime with extreme values that
values that you do not overflow the storage. The exact range of supported you do not overflow the storage. The exact range of supported values varies
values varies depending on the time representation used. depending on the time representation used.
\section2 Use of Timezones \section2 Use of Timezones
@ -3445,10 +3445,10 @@ QDateTime::Data QDateTimePrivate::create(QDate toDate, QTime toTime, const QTime
There is no explicit size restriction on an offset from UTC, but there is an There is no explicit size restriction on an offset from UTC, but there is an
implicit limit imposed when using the toString() and fromString() methods implicit limit imposed when using the toString() and fromString() methods
which use a [+|-]hh:mm format, effectively limiting the range to +/- 99 which use a ±hh:mm format, effectively limiting the range to ± 99 hours and
hours and 59 minutes and whole minutes only. Note that currently no time 59 minutes and whole minutes only. Note that currently no time zone has an
zone has an offset outside the range of ±14 hours and all known offsets are offset outside the range of ±14 hours and all known offsets are multiples of
multiples of five minutes. five minutes.
\sa QDate, QTime, QDateTimeEdit, QTimeZone \sa QDate, QTime, QDateTimeEdit, QTimeZone
*/ */
@ -3746,7 +3746,7 @@ int QDateTime::offsetFromUtc() const
\list \list
\li For Qt::UTC it is "UTC". \li For Qt::UTC it is "UTC".
\li For Qt::OffsetFromUTC it will be in the format "UTC[+-]00:00". \li For Qt::OffsetFromUTC it will be in the format "UTC±00:00".
\li For Qt::LocalTime, the host system is queried. \li For Qt::LocalTime, the host system is queried.
\li For Qt::TimeZone, the associated QTimeZone object is queried. \li For Qt::TimeZone, the associated QTimeZone object is queried.
\endlist \endlist
@ -4089,15 +4089,14 @@ void QDateTime::setSecsSinceEpoch(qint64 secs)
formatting is "Wed May 20 03:40:13 1998". For localized formatting, see formatting is "Wed May 20 03:40:13 1998". For localized formatting, see
\l{QLocale::toString()}. \l{QLocale::toString()}.
If the \a format is Qt::ISODate, the string format corresponds If the \a format is Qt::ISODate, the string format corresponds to the ISO
to the ISO 8601 extended specification for representations of 8601 extended specification for representations of dates and times, taking
dates and times, taking the form yyyy-MM-ddTHH:mm:ss[Z|[+|-]HH:mm], the form yyyy-MM-ddTHH:mm:ss[Z|±HH:mm], depending on the timeSpec() of the
depending on the timeSpec() of the QDateTime. If the timeSpec() QDateTime. If the timeSpec() is Qt::UTC, Z will be appended to the string;
is Qt::UTC, Z will be appended to the string; if the timeSpec() is if the timeSpec() is Qt::OffsetFromUTC, the offset in hours and minutes from
Qt::OffsetFromUTC, the offset in hours and minutes from UTC will UTC will be appended to the string. To include milliseconds in the ISO 8601
be appended to the string. To include milliseconds in the ISO 8601
date, use the \a format Qt::ISODateWithMs, which corresponds to date, use the \a format Qt::ISODateWithMs, which corresponds to
yyyy-MM-ddTHH:mm:ss.zzz[Z|[+|-]HH:mm]. yyyy-MM-ddTHH:mm:ss.zzz[Z|±HH:mm].
If the \a format is Qt::RFC2822Date, the string is formatted If the \a format is Qt::RFC2822Date, the string is formatted
following \l{RFC 2822}. following \l{RFC 2822}.
@ -5176,7 +5175,7 @@ QDateTime QDateTime::fromString(QStringView string, Qt::DateFormat format)
} }
isoString = isoString.sliced(1); // trim 'T' (or space) isoString = isoString.sliced(1); // trim 'T' (or space)
// 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(u'Z', Qt::CaseInsensitive)) { if (isoString.endsWith(u'Z', Qt::CaseInsensitive)) {
zone = QTimeZone::UTC; zone = QTimeZone::UTC;
isoString.chop(1); // trim 'Z' isoString.chop(1); // trim 'Z'