From 6c3a9df3fee0dc387bde3e16d185952ade4ea2fd Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 12 Aug 2013 14:20:56 +0200 Subject: QDateTime - Store Qt::TimeSpec, remove Daylight Status Change storing the spec from QDateTimePrivate::Spec to Qt::TimeSpec. Remove the storage and use of the Daylight Status as it is almost never set or used, and would be inaccurate if the tz were to change. It will be replaced later with proper daylight transition support. This simplifies the code and makes the msecs storage change easier. Change-Id: I78a70905025d7eddf1c2dc6001f6b490e5a2b3b8 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime_p.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 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 f765403d37..e6cece141d 100644 --- a/src/corelib/tools/qdatetime_p.h +++ b/src/corelib/tools/qdatetime_p.h @@ -62,19 +62,35 @@ QT_BEGIN_NAMESPACE class QDateTimePrivate : public QSharedData { public: - enum Spec { LocalUnknown = -1, LocalStandard = 0, LocalDST = 1, UTC = 2, OffsetFromUTC = 3}; + // Never change or delete this enum, it is required for backwards compatible + // serialization of QDateTime before 5.2, so is essentially public API + enum Spec { + LocalUnknown = -1, + LocalStandard = 0, + LocalDST = 1, + UTC = 2, + OffsetFromUTC = 3 + }; - QDateTimePrivate() : spec(LocalUnknown), m_offsetFromUtc(0) {} + // Daylight Time Status + enum DaylightStatus { + NoDaylightTime, + UnknownDaylightTime, + StandardTime, + DaylightTime + }; + + QDateTimePrivate() : m_spec(Qt::LocalTime), m_offsetFromUtc(0) {} QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec, int offsetSeconds); QDateTimePrivate(const QDateTimePrivate &other) - : QSharedData(other), date(other.date), time(other.time), spec(other.spec), + : QSharedData(other), date(other.date), time(other.time), m_spec(other.m_spec), m_offsetFromUtc(other.m_offsetFromUtc) {} QDate date; QTime time; - Spec spec; + Qt::TimeSpec m_spec; int m_offsetFromUtc; // Get current date/time in LocalTime and put result in outDate and outTime @@ -85,6 +101,8 @@ public: // Add msecs to given datetime and put result in utcDate and utcTime static void addMSecs(QDate &utcDate, QTime &utcTime, qint64 msecs); + void setTimeSpec(Qt::TimeSpec spec, int offsetSeconds); + static inline qint64 minJd() { return QDate::minJd(); } static inline qint64 maxJd() { return QDate::maxJd(); } }; -- cgit v1.2.3