Add QTimeZone::{systemTimeZone,utc}
[ChangeLog][QtCore][QTimeZone] Added methods systemTimeZone() and utc() that return QTimeZone objects for the system time zone and for UTC, respectively. Change-Id: Ic5d393bfd36e48a193fcffff13b96821bb8514b9 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
3d051d41a3
commit
514af281e3
@ -3186,13 +3186,11 @@ QTimeZone QDateTime::timeZone() const
|
||||
d->m_timeZone = QTimeZone(d->m_offsetFromUtc);
|
||||
return d->m_timeZone;
|
||||
case Qt::UTC:
|
||||
if (!d->m_timeZone.isValid())
|
||||
d->m_timeZone = QTimeZone(QTimeZonePrivate::utcQByteArray());
|
||||
return d->m_timeZone;
|
||||
case Qt::TimeZone :
|
||||
return QTimeZone::utc();
|
||||
case Qt::TimeZone:
|
||||
return d->m_timeZone;
|
||||
case Qt::LocalTime:
|
||||
return QTimeZone(QTimeZone::systemTimeZoneId());
|
||||
return QTimeZone::systemTimeZone();
|
||||
}
|
||||
return QTimeZone();
|
||||
}
|
||||
|
@ -788,6 +788,29 @@ QByteArray QTimeZone::systemTimeZoneId()
|
||||
return global_tz->backend->systemTimeZoneId();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.5
|
||||
Returns a QTimeZone object that refers to the local system time, as
|
||||
specified by systemTimeZoneId().
|
||||
|
||||
\sa utc()
|
||||
*/
|
||||
QTimeZone QTimeZone::systemTimeZone()
|
||||
{
|
||||
return QTimeZone(QTimeZone::systemTimeZoneId());
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.5
|
||||
Returns a QTimeZone object that refers to UTC (Universal Time Coordinated).
|
||||
|
||||
\sa systemTimeZone()
|
||||
*/
|
||||
QTimeZone QTimeZone::utc()
|
||||
{
|
||||
return QTimeZone(QTimeZonePrivate::utcQByteArray());
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if a given time zone \a ianaId is available on this system.
|
||||
|
||||
|
@ -117,6 +117,8 @@ public:
|
||||
OffsetDataList transitions(const QDateTime &fromDateTime, const QDateTime &toDateTime) const;
|
||||
|
||||
static QByteArray systemTimeZoneId();
|
||||
static QTimeZone systemTimeZone();
|
||||
static QTimeZone utc();
|
||||
|
||||
static bool isTimeZoneIdAvailable(const QByteArray &ianaId);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user