summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qdatetime.h
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2013-02-25 13:36:29 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-28 19:08:14 +0200
commit13c16bbd06e0034210ba2164f1be208c49a6e3a7 (patch)
tree2ab887adab4ad7f38b60ff7c903e55623dd6aa72 /src/corelib/tools/qdatetime.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 <thiago.macieira@intel.com> Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Diffstat (limited to 'src/corelib/tools/qdatetime.h')
-rw-r--r--src/corelib/tools/qdatetime.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index e5c1e104a2..83c92858ee 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -203,6 +203,8 @@ public:
QDateTime();
explicit QDateTime(const QDate &);
QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime);
+ // ### Qt 6: Merge with above with default offsetSeconds = 0
+ QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds);
QDateTime(const QDateTime &other);
~QDateTime();
@@ -216,15 +218,20 @@ public:
QDate date() const;
QTime time() const;
Qt::TimeSpec timeSpec() const;
+ int offsetFromUtc() const;
+
qint64 toMSecsSinceEpoch() const;
// ### Qt 6: use quint64 instead of uint
uint toTime_t() const;
+
void setDate(const QDate &date);
void setTime(const QTime &time);
void setTimeSpec(Qt::TimeSpec spec);
+ void setOffsetFromUtc(int offsetSeconds);
void setMSecsSinceEpoch(qint64 msecs);
// ### Qt 6: use quint64 instead of uint
void setTime_t(uint secsSince1Jan1970UTC);
+
#ifndef QT_NO_DATESTRING
QString toString(Qt::DateFormat f = Qt::TextDate) const;
QString toString(const QString &format) const;
@@ -234,9 +241,12 @@ public:
QDateTime addYears(int years) const;
QDateTime addSecs(qint64 secs) const;
QDateTime addMSecs(qint64 msecs) const;
+
QDateTime toTimeSpec(Qt::TimeSpec spec) const;
inline QDateTime toLocalTime() const { return toTimeSpec(Qt::LocalTime); }
inline QDateTime toUTC() const { return toTimeSpec(Qt::UTC); }
+ QDateTime toOffsetFromUtc(int offsetSeconds) const;
+
qint64 daysTo(const QDateTime &) const;
qint64 secsTo(const QDateTime &) const;
qint64 msecsTo(const QDateTime &) const;
@@ -248,8 +258,10 @@ public:
inline bool operator>(const QDateTime &other) const { return other < *this; }
inline bool operator>=(const QDateTime &other) const { return !(*this < other); }
- void setUtcOffset(int seconds);
- int utcOffset() const;
+#if QT_DEPRECATED_SINCE(5, 2)
+ QT_DEPRECATED void setUtcOffset(int seconds);
+ QT_DEPRECATED int utcOffset() const;
+#endif // QT_DEPRECATED_SINCE
static QDateTime currentDateTime();
static QDateTime currentDateTimeUtc();