summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qtimezone.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/time/qtimezone.cpp')
-rw-r--r--src/corelib/time/qtimezone.cpp321
1 files changed, 204 insertions, 117 deletions
diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp
index c5fc6e20a5..3a68277a6c 100644
--- a/src/corelib/time/qtimezone.cpp
+++ b/src/corelib/time/qtimezone.cpp
@@ -22,13 +22,6 @@ using namespace Qt::StringLiterals;
// Create default time zone using appropriate backend
static QTimeZonePrivate *newBackendTimeZone()
{
-#ifdef QT_NO_SYSTEMLOCALE
-#if QT_CONFIG(icu)
- return new QIcuTimeZonePrivate();
-#else
- return new QUtcTimeZonePrivate();
-#endif
-#else
#if defined(Q_OS_DARWIN)
return new QMacTimeZonePrivate();
#elif defined(Q_OS_ANDROID)
@@ -41,21 +34,13 @@ static QTimeZonePrivate *newBackendTimeZone()
return new QWinTimeZonePrivate();
#else
return new QUtcTimeZonePrivate();
-#endif // System Locales
-#endif // QT_NO_SYSTEMLOCALE
+#endif // Backend selection
}
// Create named time zone using appropriate backend
static QTimeZonePrivate *newBackendTimeZone(const QByteArray &ianaId)
{
Q_ASSERT(!ianaId.isEmpty());
-#ifdef QT_NO_SYSTEMLOCALE
-#if QT_CONFIG(icu)
- return new QIcuTimeZonePrivate(ianaId);
-#else
- return new QUtcTimeZonePrivate(ianaId);
-#endif
-#else
#if defined(Q_OS_DARWIN)
return new QMacTimeZonePrivate(ianaId);
#elif defined(Q_OS_ANDROID)
@@ -68,8 +53,7 @@ static QTimeZonePrivate *newBackendTimeZone(const QByteArray &ianaId)
return new QWinTimeZonePrivate(ianaId);
#else
return new QUtcTimeZonePrivate(ianaId);
-#endif // System Locales
-#endif // QT_NO_SYSTEMLOCALE
+#endif // Backend selection
}
class QTimeZoneSingleton
@@ -77,10 +61,11 @@ class QTimeZoneSingleton
public:
QTimeZoneSingleton() : backend(newBackendTimeZone()) {}
- // The global_tz is the tz to use in static methods such as availableTimeZoneIds() and
- // isTimeZoneIdAvailable() and to create named IANA time zones. This is usually the host
- // system, but may be different if the host resources are insufficient or if
- // QT_NO_SYSTEMLOCALE is set. A simple UTC backend is used if no alternative is available.
+ // The global_tz is the tz to use in static methods such as
+ // availableTimeZoneIds() and isTimeZoneIdAvailable() and to create named
+ // IANA time zones. This is usually the host system, but may be different if
+ // the host resources are insufficient. A simple UTC backend is used if no
+ // alternative is available.
QExplicitlySharedDataPointer<QTimeZonePrivate> backend;
};
@@ -95,6 +80,8 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz);
\brief QTimeZone identifies how a time representation relates to UTC.
+ \compares equality
+
When dates and times are combined, the meaning of the result depends on how
time is being represented. There are various international standards for
representing time; one of these, UTC, corresponds to the traditional
@@ -177,7 +164,7 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz);
A default UTC time zone backend is provided which is always available when
feature \c timezone is enabled. This provides a set of generic Offset From
- UTC time zones in the range UTC-14:00 to UTC+14:00. These time zones can be
+ UTC time zones in the range UTC-16:00 to UTC+16:00. These time zones can be
created using either the standard ISO format names, such as "UTC+00:00", as
listed by availableTimeZoneIds(), or using a name of similar form in
combination with the number of offset seconds.
@@ -254,17 +241,34 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz);
*/
/*!
- \enum QTimeZone::anonymous
+ \variable QTimeZone::MinUtcOffsetSecs
+ \brief Timezone offsets from UTC are expected to be no lower than this.
+
+ The lowest UTC offset of any early 21st century timezone is -12 hours (Baker
+ Island, USA), or 12 hours west of Greenwich.
+
+ Historically, until 1844, The Philippines (then controlled by Spain) used
+ the same date as Spain's American holdings, so had offsets close to 16 hours
+ west of Greenwich. As The Philippines was using local solar mean time, it is
+ possible some outlying territory of it may have been operating at more than
+ 16 hours west of Greenwich, but no early 21st century timezone traces its
+ history back to such an extreme.
+
+ \sa MaxUtcOffsetSecs
+*/
+/*!
+ \variable QTimeZone::MaxUtcOffsetSecs
+ \brief Timezone offsets from UTC are expected to be no higher than this.
+
+ The highest UTC offset of any early 21st century timezone is +14 hours
+ (Christmas Island, Kiribati, Kiritimati), or 14 hours east of Greenwich.
- This enumeration provides constants bounding the range of plausible timezone
- offsets from UTC, measured in seconds.
- Sane UTC offsets range from -14 to +14 hours.
- No known zone has offset > 12 hrs West of Greenwich (Baker Island, USA).
- No known zone has offset > 14 hrs East of Greenwich (Kiritimati, Christmas Island, Kiribati).
- Note that there are zones whose offsets differ by more than a day.
+ Historically, before 1867, when Russia sold Alaska to America, Alaska used
+ the same date as Russia, so had offsets over 15 hours east of Greenwich. As
+ Alaska was using local solar mean time, its offsets varied, but all were
+ less than 16 hours east of Greenwich.
- \value MinUtcOffsetSecs -14 * 3600,
- \value MaxUtcOffsetSecs +14 * 3600
+ \sa MinUtcOffsetSecs
*/
#if QT_CONFIG(timezone)
@@ -435,22 +439,27 @@ QTimeZone::Data &QTimeZone::Data::operator=(QTimeZonePrivate *dptr) noexcept
Creates a time zone instance with the requested IANA ID \a ianaId.
The ID must be one of the available system IDs or a valid UTC-with-offset
- ID, otherwise an invalid time zone will be returned.
+ ID, otherwise an invalid time zone will be returned. For UTC-with-offset
+ IDs, when they are not in fact IANA IDs, the \c{id()} of the resulting
+ instance may differ from the ID passed to the constructor.
This constructor is only available when feature \c timezone is enabled.
- \sa availableTimeZoneIds()
+ \sa availableTimeZoneIds(), id()
*/
QTimeZone::QTimeZone(const QByteArray &ianaId)
{
- // Try and see if it's a CLDR UTC offset ID - just as quick by creating as
- // by looking up.
+ // Try and see if it's a recognized UTC offset ID - just as quick by
+ // creating as by looking up.
d = new QUtcTimeZonePrivate(ianaId);
- // If not a CLDR UTC offset ID then try creating it with the system backend.
- // Relies on backend not creating valid TZ with invalid name.
- if (!d->isValid())
- d = ianaId.isEmpty() ? newBackendTimeZone() : newBackendTimeZone(ianaId);
+ // If not recognized, try creating it with the system backend.
+ if (!d->isValid()) {
+ if (ianaId.isEmpty())
+ d = newBackendTimeZone();
+ else // Constructor MUST produce invalid for unsupported ID.
+ d = newBackendTimeZone(ianaId);
+ }
// Can also handle UTC with arbitrary (valid) offset, but only do so as
// fall-back, since either of the above may handle it more informatively.
if (!d->isValid()) {
@@ -468,13 +477,15 @@ QTimeZone::QTimeZone(const QByteArray &ianaId)
/*!
Creates a time zone instance with the given offset, \a offsetSeconds, from UTC.
- The \a offsetSeconds from UTC must be in the range -14 hours to +14 hours
+ The \a offsetSeconds from UTC must be in the range -16 hours to +16 hours
otherwise an invalid time zone will be returned.
This constructor is only available when feature \c timezone is enabled. The
returned instance is equivalent to the lightweight time representation
\c{QTimeZone::fromSecondsAfterUtc(offsetSeconds)}, albeit implemented as a
time zone.
+
+ \sa MinUtcOffsetSecs, MaxUtcOffsetSecs, id()
*/
QTimeZone::QTimeZone(int offsetSeconds)
@@ -486,27 +497,32 @@ QTimeZone::QTimeZone(int offsetSeconds)
/*!
Creates a custom time zone instance at fixed offset from UTC.
- The returned time zone has an ID of \a ianaId and an offset from UTC of \a
+ The returned time zone has an ID of \a zoneId and an offset from UTC of \a
offsetSeconds. The \a name will be the name used by displayName() for the
LongName, the \a abbreviation will be used by displayName() for the
ShortName and by abbreviation(), and the optional \a territory will be used
by territory(). The \a comment is an optional note that may be displayed in
a GUI to assist users in selecting a time zone.
- The \a ianaId must not be one of the available system IDs returned by
- availableTimeZoneIds(). The \a offsetSeconds from UTC must be in the range
- -14 hours to +14 hours.
+ The \a zoneId \e{must not} be one of the available system IDs returned by
+ availableTimeZoneIds(). The \a offsetSeconds from UTC must be in the range
+ -16 hours to +16 hours.
If the custom time zone does not have a specific territory then set it to the
default value of QLocale::AnyTerritory.
This constructor is only available when feature \c timezone is enabled.
+
+ \sa id(), offsetFromUtc(), displayName(), abbreviation(), territory(), comment(),
+ MinUtcOffsetSecs, MaxUtcOffsetSecs
*/
-QTimeZone::QTimeZone(const QByteArray &ianaId, int offsetSeconds, const QString &name,
+QTimeZone::QTimeZone(const QByteArray &zoneId, int offsetSeconds, const QString &name,
const QString &abbreviation, QLocale::Territory territory, const QString &comment)
- : d(isTimeZoneIdAvailable(ianaId) ? nullptr // Don't let client code hijack a real zone name.
- : new QUtcTimeZonePrivate(ianaId, offsetSeconds, name, abbreviation, territory, comment))
+ : d(QUtcTimeZonePrivate().isTimeZoneIdAvailable(zoneId)
+ || global_tz->backend->isTimeZoneIdAvailable(zoneId)
+ ? nullptr // Don't let client code hijack a real zone name.
+ : new QUtcTimeZonePrivate(zoneId, offsetSeconds, name, abbreviation, territory, comment))
{
}
@@ -529,16 +545,12 @@ QTimeZone::QTimeZone(QTimeZonePrivate &dd)
In all cases, the result's \l timeSpec() is Qt::TimeZone. When this
QTimeZone's timeSpec() is Qt::TimeZone, this QTimeZone itself is returned.
+ If timeSpec() is Qt::LocalTime then systemTimeZone() is returned.
If timeSpec() is Qt::UTC, QTimeZone::utc() is returned. If it is
Qt::OffsetFromUTC then QTimeZone(int) is passed its offset and the result is
returned.
- If timeSpec() is Qt::LocalTime then an instance of the current system time
- zone will be returned. This will not change to reflect any subsequent change
- to the system time zone. It represents the local time that was in effect
- when asBackendZone() was called.
-
When using a lightweight time representation - local time, UTC time or time
at a fixed offset from UTC - using methods only supported when feature \c
timezone is enabled may be more expensive than using a corresponding time
@@ -603,17 +615,18 @@ QTimeZone QTimeZone::asBackendZone() const
Returns a time representation at a fixed \a offset, in seconds, ahead of
UTC.
- The \a offset from UTC must be in the range -14 hours to +14 hours otherwise an
- invalid time zone will be returned. The returned QTimeZone is a lightweight
- time representation, not a time zone (backed by system-supplied or standard
- data).
+ The \a offset from UTC must be in the range -16 hours to +16 hours otherwise
+ an invalid time zone will be returned. The returned QTimeZone is a
+ lightweight time representation, not a time zone (backed by system-supplied
+ or standard data).
If the offset is 0, the \l timeSpec() of the returned instance will be
Qt::UTC. Otherwise, if \a offset is valid, timeSpec() is
Qt::OffsetFromUTC. An invalid time zone, when returned, has Qt::TimeZone as
its timeSpec().
- \sa QTimeZone(int), asBackendZone(), fixedSecondsAheadOfUtc()
+ \sa QTimeZone(int), asBackendZone(), fixedSecondsAheadOfUtc(),
+ MinUtcOffsetSecs, MaxUtcOffsetSecs
*/
/*!
@@ -707,7 +720,9 @@ QTimeZone &QTimeZone::operator=(const QTimeZone &other)
*/
/*!
- Returns \c true if this time representation is equal to the \a other.
+ \fn bool QTimeZone::operator==(const QTimeZone &lhs, const QTimeZone &rhs)
+
+ Returns \c true if \a lhs time zone is equal to the \a rhs time zone.
Two representations are different if they are internally described
differently, even if they agree in their representation of all moments of
@@ -715,33 +730,31 @@ QTimeZone &QTimeZone::operator=(const QTimeZone &other)
time zone but the two will not be equal.
*/
-bool QTimeZone::operator==(const QTimeZone &other) const
-{
- if (d.isShort())
- return other.d.isShort() && d.s == other.d.s;
-
- if (!other.d.isShort()) {
- if (d.d == other.d.d)
- return true;
-#if QT_CONFIG(timezone)
- return d.d && other.d.d && *d.d == *other.d.d;
-#endif
- }
-
- return false;
-}
-
/*!
- Returns \c true if this time zone is not equal to the \a other time zone.
+ \fn bool QTimeZone::operator!=(const QTimeZone &lhs, const QTimeZone &rhs)
+
+ Returns \c true if \a lhs time zone is not equal to the \a rhs time zone.
Two representations are different if they are internally described
differently, even if they agree in their representation of all moments of
time. In particular, a lightweight time representation may coincide with a
time zone but the two will not be equal.
*/
-bool QTimeZone::operator!=(const QTimeZone &other) const // ### Qt 7: inline
+
+bool comparesEqual(const QTimeZone &lhs, const QTimeZone &rhs) noexcept
{
- return !(*this == other);
+ if (lhs.d.isShort())
+ return rhs.d.isShort() && lhs.d.s == rhs.d.s;
+
+ if (!rhs.d.isShort()) {
+ if (lhs.d.d == rhs.d.d)
+ return true;
+#if QT_CONFIG(timezone)
+ return lhs.d.d && rhs.d.d && *lhs.d.d == *rhs.d.d;
+#endif
+ }
+
+ return false;
}
/*!
@@ -764,6 +777,28 @@ bool QTimeZone::isValid() const
IANA IDs are used on all platforms. On Windows these are translated from
the Windows ID into the best match IANA ID for the time zone and territory.
+ If this timezone instance was not constructed from an IANA ID, its ID is
+ determined by how it was constructed. In most cases, the ID passed when
+ constructing the instance is used. (The constructor for a custom zone uses
+ the ID it is passed, which must not be an IANA ID.) There are two
+ exceptions.
+ \list
+ \li Instances constructed by passing only a UTC offset in seconds have no ID
+ passed when constructing.
+ \li The constructor taking only an IANA ID will also accept some UTC-offset
+ IDs that are not in fact IANA IDs: its handling of these is equivalent
+ to passing the corresponding offset in seconds, as for the first
+ exception.
+ \endlist
+
+ In the two exceptional cases, if there is an IANA UTC-offset zone with the
+ specified offset, the instance constructed uses that IANA zone's ID, even
+ though this may differ from the (non-IANA) UTC-offset ID passed to the
+ constructor. Otherwise, the instance uses an ID synthesized from its offset,
+ with the form UTC±hh:mm:ss, omitting any trailing :00 for zero seconds or
+ minutes. Again, this may differ from the UTC-offset ID passed to the
+ constructor.
+
This method is only available when feature \c timezone is enabled.
*/
@@ -792,6 +827,14 @@ QByteArray QTimeZone::id() const
Returns the territory for the time zone.
+ A return of \l {QLocale::}{AnyTerritory} means the zone has no known
+ territorial association. In some cases this may be because the zone has no
+ associated territory - for example, UTC - or because the zone is used in
+ several territories - for example, CET. In other cases, the QTimeZone
+ backend may not know which territory the zone is associated with - for
+ example, because it is not the primary zone of the territory in which it is
+ used.
+
This method is only available when feature \c timezone is enabled.
*/
QLocale::Territory QTimeZone::territory() const
@@ -865,7 +908,7 @@ QString QTimeZone::displayName(const QDateTime &atDateTime, NameType nameType,
return systemTimeZone().displayName(atDateTime, nameType, locale);
case Qt::UTC:
case Qt::OffsetFromUTC:
- return QUtcTimeZonePrivate(d.s.offset).QTimeZonePrivate::displayName(
+ return QUtcTimeZonePrivate(d.s.offset).displayName(
atDateTime.toMSecsSinceEpoch(), nameType, locale);
case Qt::TimeZone:
Q_UNREACHABLE();
@@ -1110,9 +1153,12 @@ bool QTimeZone::isDaylightTime(const QDateTime &atDateTime) const
}
/*!
- Returns the effective offset details at the given \a forDateTime. This is
- the equivalent of calling offsetFromUtc(), abbreviation(), etc individually but is
- more efficient.
+ Returns the effective offset details at the given \a forDateTime.
+
+ This is the equivalent of calling abbreviation() and all three offset
+ functions individually but is more efficient. If this data is not available
+ for the given datetime, an invalid OffsetData will be returned with an
+ invalid QDateTime as its \c atUtc.
This method is only available when feature \c timezone is enabled.
@@ -1132,9 +1178,9 @@ QTimeZone::OffsetData QTimeZone::offsetData(const QDateTime &forDateTime) const
Q_UNREACHABLE();
break;
}
- } else if (hasTransitions()) {
- return QTimeZonePrivate::toOffsetData(d->data(forDateTime.toMSecsSinceEpoch()));
}
+ if (isValid())
+ return QTimeZonePrivate::toOffsetData(d->data(forDateTime.toMSecsSinceEpoch()));
return QTimeZonePrivate::invalidOffsetData();
}
@@ -1175,7 +1221,7 @@ bool QTimeZone::hasTransitions() const
Transition after it.
If there is no transition after the given \a afterDateTime then an invalid
- OffsetData will be returned with an invalid QDateTime.
+ OffsetData will be returned with an invalid QDateTime as its \c atUtc.
The given \a afterDateTime is exclusive.
@@ -1210,7 +1256,7 @@ QTimeZone::OffsetData QTimeZone::nextTransition(const QDateTime &afterDateTime)
Transition before it.
If there is no transition before the given \a beforeDateTime then an invalid
- OffsetData will be returned with an invalid QDateTime.
+ OffsetData will be returned with an invalid QDateTime as its \c atUtc.
The given \a beforeDateTime is exclusive.
@@ -1243,7 +1289,9 @@ QTimeZone::OffsetData QTimeZone::previousTransition(const QDateTime &beforeDateT
/*!
Returns a list of all time zone transitions between the given datetimes.
- The given \a fromDateTime and \a toDateTime are inclusive.
+ The given \a fromDateTime and \a toDateTime are inclusive. The \c atUtc
+ member of each entry describes the moment of the transition, at which the
+ offsets and abbreviation given by other members take effect.
This method is only available when feature \c timezone is enabled.
@@ -1280,13 +1328,25 @@ QTimeZone::OffsetDataList QTimeZone::transitions(const QDateTime &fromDateTime,
/*!
Returns the current system time zone IANA ID.
- On Windows this ID is translated from the Windows ID using an internal
- translation table and the user's selected country. As a consequence there
- is a small chance any Windows install may have IDs not known by Qt, in
- which case "UTC" will be returned.
+ Equivalent to calling systemTimeZone().id(), but may bypass some computation
+ to obtain it. Constructing a QTimeZone from the returned byte array will
+ produce the same result as systemTimeZone().
+
+ If the backend is unable to determine the correct system zone, the result is
+ empty. In this case, systemTimeZone().isValid() is false and a warning is
+ output if either this method of systemTimeZone() is called.
+
+ If the backend is able to determine the correct system zone but not its
+ name, an empty byte array is returned. For example, on Windows, the system
+ native ID is converted to an IANA ID - if the system ID isn't known to the
+ internal translation code, the result shall be empty. In this case,
+ systemTimeZone().isValid() shall be true.
This method is only available when feature \c timezone is enabled.
+ \note Prior to Qt 6.7, when the result could not be determined, the
+ misleading result "UTC" was returned.
+
\sa systemTimeZone()
*/
@@ -1296,12 +1356,7 @@ QByteArray QTimeZone::systemTimeZoneId()
if (!sys.isEmpty())
return sys;
// The system zone, despite the empty ID, may know its real ID anyway:
- auto zone = systemTimeZone();
- if (zone.isValid() && !zone.id().isEmpty())
- return zone.id();
- // TODO: "-00:00", meaning "unspecified local zone" in some RFC, may be more apt.
- // If all else fails, guess UTC.
- return QTimeZonePrivate::utcQByteArray();
+ return systemTimeZone().id();
}
/*!
@@ -1314,11 +1369,29 @@ QByteArray QTimeZone::systemTimeZoneId()
representation \c {QTimeZone(QTimeZone::LocalTime)}, albeit implemented as a
time zone.
- \sa utc(), Initialization, asBackendZone()
+ The returned object will not change to reflect any subsequent change to the
+ system time zone. It represents the local time that was in effect when
+ asBackendZone() was called. On misconfigured systems, such as those that
+ lack the timezone data relied on by the backend for which Qt was compiled,
+ it may be invalid. In such a case, a warning is output.
+
+ \sa utc(), Initialization, asBackendZone(), systemTimeZoneId()
*/
QTimeZone QTimeZone::systemTimeZone()
{
- return QTimeZone(global_tz->backend->systemTimeZoneId());
+ // Use ID even if empty, as default constructor is invalid but empty-ID
+ // constructor goes to backend's default constructor, which may succeed.
+ const auto sys = QTimeZone(global_tz->backend->systemTimeZoneId());
+ if (!sys.isValid()) {
+ static bool neverWarned = true;
+ if (neverWarned) {
+ // Racey but, at worst, merely repeats the warning.
+ neverWarned = false;
+ qWarning("Unable to determine system time zone: "
+ "please check your system configuration.");
+ }
+ }
+ return sys;
}
/*!
@@ -1340,6 +1413,9 @@ QTimeZone QTimeZone::utc()
/*!
Returns \c true if a given time zone \a ianaId is available on this system.
+ This may include some non-IANA IDs, notably UTC-offset IDs, that are not
+ listed in \l availableTimeZoneIds().
+
This method is only available when feature \c timezone is enabled.
\sa availableTimeZoneIds()
@@ -1350,7 +1426,7 @@ bool QTimeZone::isTimeZoneIdAvailable(const QByteArray &ianaId)
#if defined(Q_OS_UNIX) && !(defined(Q_OS_ANDROID) || defined(Q_OS_DARWIN))
// Keep #if-ery consistent with selection of QTzTimeZonePrivate in
// newBackendTimeZone(). Skip the pre-check, as the TZ backend accepts POSIX
- // zone IDs, which need not be valid IANA IDs.
+ // zone IDs, which need not be valid IANA IDs. See also QTBUG-112006.
#else
// isValidId is not strictly required, but faster to weed out invalid
// IDs as availableTimeZoneIds() may be slow
@@ -1358,6 +1434,7 @@ bool QTimeZone::isTimeZoneIdAvailable(const QByteArray &ianaId)
return false;
#endif
return QUtcTimeZonePrivate().isTimeZoneIdAvailable(ianaId)
+ || QUtcTimeZonePrivate::offsetFromUtcString(ianaId) != QTimeZonePrivate::invalidSeconds()
|| global_tz->backend->isTimeZoneIdAvailable(ianaId);
}
@@ -1376,6 +1453,10 @@ static QList<QByteArray> set_union(const QList<QByteArray> &l1, const QList<QByt
This method is only available when feature \c timezone is enabled.
+ \note the QTimeZone constructor will also accept some UTC-offset IDs that
+ are not in the list returned - it would be impractical to list all possible
+ UTC-offset IDs.
+
\sa isTimeZoneIdAvailable()
*/
@@ -1388,14 +1469,14 @@ QList<QByteArray> QTimeZone::availableTimeZoneIds()
/*!
Returns a list of all available IANA time zone IDs for a given \a territory.
- As a special case, a \a territory of Qt::AnyTerritory returns those time zones
- that do not have any territory related to them, such as UTC. If you require
- a list of all time zone IDs for all countries then use the standard
- availableTimeZoneIds() method.
+ As a special case, a \a territory of \l {QLocale::}{AnyTerritory} selects
+ those time zones that have no known territorial association, such as UTC. If
+ you require a list of all time zone IDs for all territories then use the
+ standard availableTimeZoneIds() method.
This method is only available when feature \c timezone is enabled.
- \sa isTimeZoneIdAvailable()
+ \sa isTimeZoneIdAvailable(), territory()
*/
QList<QByteArray> QTimeZone::availableTimeZoneIds(QLocale::Territory territory)
@@ -1408,9 +1489,13 @@ QList<QByteArray> QTimeZone::availableTimeZoneIds(QLocale::Territory territory)
Returns a list of all available IANA time zone IDs with a given standard
time offset of \a offsetSeconds.
+ Where the given offset is supported, \c{QTimeZone(offsetSeconds).id()} is
+ included in the list, even if it is not an IANA ID. This only arises when
+ there is no IANA UTC-offset ID with the given offset.
+
This method is only available when feature \c timezone is enabled.
- \sa isTimeZoneIdAvailable()
+ \sa isTimeZoneIdAvailable(), QTimeZone(int)
*/
QList<QByteArray> QTimeZone::availableTimeZoneIds(int offsetSeconds)
@@ -1436,9 +1521,9 @@ QByteArray QTimeZone::ianaIdToWindowsId(const QByteArray &ianaId)
Returns the default IANA ID for a given \a windowsId.
Because a Windows ID can cover several IANA IDs in several different
- countries, this function returns the most frequently used IANA ID with no
- regard for the country and should thus be used with care. It is usually
- best to request the default for a specific country.
+ territories, this function returns the most frequently used IANA ID with no
+ regard for the territory and should thus be used with care. It is usually
+ best to request the default for a specific territory.
This method is only available when feature \c timezone is enabled.
@@ -1456,15 +1541,16 @@ QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId)
Because a Windows ID can cover several IANA IDs within a given territory,
the most frequently used IANA ID in that territory is returned.
- As a special case, QLocale::AnyTerritory returns the default of those IANA IDs
- that do not have any specific territory.
+ As a special case, \l{QLocale::}{AnyTerritory} returns the default of those
+ IANA IDs that have no known territorial association.
This method is only available when feature \c timezone is enabled.
- \sa ianaIdToWindowsId(), windowsIdToIanaIds()
+ \sa ianaIdToWindowsId(), windowsIdToIanaIds(), territory()
*/
-QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId, QLocale::Territory territory)
+QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId,
+ QLocale::Territory territory)
{
return QTimeZonePrivate::windowsIdToDefaultIanaId(windowsId, territory);
}
@@ -1487,18 +1573,19 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId)
/*!
Returns all the IANA IDs for a given \a windowsId and \a territory.
- As a special case QLocale::AnyTerritory returns those IANA IDs that do
- not have any specific territory.
+ As a special case, \l{QLocale::}{AnyTerritory} selects those IANA IDs that
+ have no known territorial association.
The returned list is in order of frequency of usage, i.e. larger zones
within a territory are listed first.
This method is only available when feature \c timezone is enabled.
- \sa ianaIdToWindowsId(), windowsIdToDefaultIanaId()
+ \sa ianaIdToWindowsId(), windowsIdToDefaultIanaId(), territory()
*/
-QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId, QLocale::Territory territory)
+QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ QLocale::Territory territory)
{
return QTimeZonePrivate::windowsIdToIanaIds(windowsId, territory);
}