Include offset-zone's ID in the available IDs for an offset
While it would be perverse for availableTimeZoneIds() to list all supported UTC-offset zone IDs, it makes reasonably good sense for its offset-specific overload to include the ID QTimeZone would use for the relevant UTC-offset, since passing this ID to the ID-based constructor will indeed get a zone with this offset. In particular, it already does include the offset-zone's ID if there is an IANA UTC-offset zone with the given offset; and its list is apt to be empty otherwise. Only applies to IDs we would in fact accept, checked with offsetFromUtcString() to match the QTZ constructor's check. Change-Id: I77bb60b166c3d3af5824d84952e1e10a5d32a5ad Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
df73672f97
commit
905fb43594
@ -1504,9 +1504,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)
|
||||
|
@ -989,6 +989,12 @@ QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds(qint32 offsetSeconds
|
||||
}
|
||||
result << id.toByteArray();
|
||||
}
|
||||
// CLDR only has round multiples of a quarter hour, and only some of
|
||||
// those. For anything else, throw in the ID we would use for this offset
|
||||
// (if we'd accept that ID).
|
||||
QByteArray isoName = isoOffsetFormat(offsetSeconds, QTimeZone::ShortName).toUtf8();
|
||||
if (offsetFromUtcString(isoName) == qint64(offsetSeconds) && !result.contains(isoName))
|
||||
result << isoName;
|
||||
// Not guaranteed to be sorted, so sort:
|
||||
std::sort(result.begin(), result.end());
|
||||
// ### assuming no duplicates
|
||||
|
Loading…
Reference in New Issue
Block a user