From 55f5b29d7975d7e642ec258e44ca23726e1dfa0d Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 11 Feb 2013 13:44:37 +0000 Subject: QDateTime - Add QTimeZone support Add support to QDateTime for time zones using the new QTimeZone class. [ChangeLog][QtCore][QDateTime] Add support for a new Qt::TimeZone spec to be used with QTimeZone to define times in a specific time zone. Change-Id: I21bfa52a8ba8989b55bb74e025d1f2b2b623b2a7 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime_p.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/corelib/tools/qdatetime_p.h') diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h index 7fd36bc4e0..f52108d764 100644 --- a/src/corelib/tools/qdatetime_p.h +++ b/src/corelib/tools/qdatetime_p.h @@ -57,6 +57,8 @@ #include "QtCore/qatomic.h" #include "QtCore/qdatetime.h" +#include "qtimezone.h" + QT_BEGIN_NAMESPACE class QDateTimePrivate : public QSharedData @@ -69,7 +71,8 @@ public: LocalStandard = 0, LocalDST = 1, UTC = 2, - OffsetFromUTC = 3 + OffsetFromUTC = 3, + TimeZone = 4 }; // Daylight Time Status @@ -86,7 +89,8 @@ public: NullTime = 0x02, ValidDate = 0x04, ValidTime = 0x08, - ValidDateTime = 0x10 + ValidDateTime = 0x10, + TimeZoneCached = 0x20 }; Q_DECLARE_FLAGS(StatusFlags, StatusFlag) @@ -99,16 +103,26 @@ public: QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec, int offsetSeconds); +#ifndef QT_BOOTSTRAPPED + QDateTimePrivate(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone); +#endif // QT_BOOTSTRAPPED + QDateTimePrivate(const QDateTimePrivate &other) : QSharedData(other), m_msecs(other.m_msecs), m_spec(other.m_spec), m_offsetFromUtc(other.m_offsetFromUtc), +#ifndef QT_BOOTSTRAPPED + m_timeZone(other.m_timeZone), +#endif // QT_BOOTSTRAPPED m_status(other.m_status) {} qint64 m_msecs; Qt::TimeSpec m_spec; int m_offsetFromUtc; +#ifndef QT_BOOTSTRAPPED + QTimeZone m_timeZone; +#endif // QT_BOOTSTRAPPED StatusFlags m_status; void setTimeSpec(Qt::TimeSpec spec, int offsetSeconds); @@ -129,6 +143,14 @@ public: inline bool isValidDateTime() const { return (m_status & ValidDateTime) == ValidDateTime; } inline void setValidDateTime() { m_status = m_status | ValidDateTime; } inline void clearValidDateTime() { m_status = m_status & ~ValidDateTime; } + inline bool isTimeZoneCached() const { return (m_status & TimeZoneCached) == TimeZoneCached; } + inline void setTimeZoneCached() { m_status = m_status | TimeZoneCached; } + inline void clearTimeZoneCached() { m_status = m_status & ~TimeZoneCached; } + +#ifndef QT_BOOTSTRAPPED + static qint64 zoneMSecsToEpochMSecs(qint64 msecs, const QTimeZone &zone, + QDate *localDate, QTime *localTime); +#endif // QT_BOOTSTRAPPED static inline qint64 minJd() { return QDate::minJd(); } static inline qint64 maxJd() { return QDate::maxJd(); } -- cgit v1.2.3