path: root/src/corelib/tools/qdatetime_p.h
diff options
authorJohn Layt <>2013-02-25 13:36:29 +0000
committerThe Qt Project <>2013-08-28 19:08:14 +0200
commit13c16bbd06e0034210ba2164f1be208c49a6e3a7 (patch)
tree2ab887adab4ad7f38b60ff7c903e55623dd6aa72 /src/corelib/tools/qdatetime_p.h
parent80cb575953e3a282593570e1583938b6475bc0d3 (diff)
QDateTime - Improve and expose Qt::OffsetFromUtc
The Qt::OffsetFromUtc TimeSpec was made public in Qt 4.4 but the access methods were never made public in the apidox effectively meaning the feature was never used. The implementation was also incomplete and inconsistent. This change cleans up the implementation and exports new public API for using the TimeSpec using new method names consistent with the new QTimeZone support. This change increases the QDataStream Version number for Qt 5.2 to 15. The behavior of one constructor has changed slightly to be consistent with the rest of the feature, but this behavior was never documented. [ChangeLog][QtCore][QDateTime] Fully implement support for Qt::TimeSpec of Qt::OffsetFromUTC, added new methods for offsetFromUTC(), toTimeSpec(), and toOffsetFromUTC(). Task-number: QTBUG-26161 Task-number: QTBUG-29666 Change-Id: If3cc7fc9778ca2b831644408ae749448d5975a3a Reviewed-by: Thiago Macieira <> Reviewed-by: Mitch Curtis <>
Diffstat (limited to 'src/corelib/tools/qdatetime_p.h')
1 files changed, 11 insertions, 9 deletions
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index c70571d509..f3abcf02d8 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -81,25 +81,27 @@ class QDateTimePrivate : public QSharedData
enum Spec { LocalUnknown = -1, LocalStandard = 0, LocalDST = 1, UTC = 2, OffsetFromUTC = 3};
- QDateTimePrivate() : spec(LocalUnknown), utcOffset(0) {}
+ QDateTimePrivate() : spec(LocalUnknown), m_offsetFromUtc(0) {}
+ QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
+ int offsetSeconds);
QDateTimePrivate(const QDateTimePrivate &other)
- : QSharedData(other), date(, time(other.time), spec(other.spec), utcOffset(other.utcOffset)
+ : QSharedData(other), date(, time(other.time), spec(other.spec),
+ m_offsetFromUtc(other.m_offsetFromUtc)
QDate date;
QTime time;
Spec spec;
- /*!
- \internal
- \since 4.4
- The offset in seconds. Applies only when timeSpec() is OffsetFromUTC.
- */
- int utcOffset;
+ int m_offsetFromUtc;
+ // Get current date/time in LocalTime and put result in outDate and outTime
Spec getLocal(QDate &outDate, QTime &outTime) const;
+ // Get current date/time in UTC and put result in outDate and outTime
void getUTC(QDate &outDate, QTime &outTime) const;
+ // Add msecs to given datetime and return result
static QDateTime addMSecs(const QDateTime &dt, qint64 msecs);
+ // Add msecs to given datetime and put result in utcDate and utcTime
static void addMSecs(QDate &utcDate, QTime &utcTime, qint64 msecs);
static inline qint64 minJd() { return QDate::minJd(); }