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.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/corelib/tools/qdatetime.h') diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 4b97cd797d..b9f6995155 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE +class QTimeZone; class Q_CORE_EXPORT QDate { @@ -208,6 +209,9 @@ public: 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); +#ifndef QT_BOOTSTRAPPED + QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone); +#endif // QT_BOOTSTRAPPED QDateTime(const QDateTime &other); ~QDateTime(); @@ -222,6 +226,9 @@ public: QTime time() const; Qt::TimeSpec timeSpec() const; int offsetFromUtc() const; +#ifndef QT_BOOTSTRAPPED + QTimeZone timeZone() const; +#endif // QT_BOOTSTRAPPED QString timeZoneAbbreviation() const; bool isDaylightTime() const; @@ -233,6 +240,9 @@ public: void setTime(const QTime &time); void setTimeSpec(Qt::TimeSpec spec); void setOffsetFromUtc(int offsetSeconds); +#ifndef QT_BOOTSTRAPPED + void setTimeZone(const QTimeZone &toZone); +#endif // QT_BOOTSTRAPPED void setMSecsSinceEpoch(qint64 msecs); // ### Qt 6: use quint64 instead of uint void setTime_t(uint secsSince1Jan1970UTC); @@ -251,6 +261,9 @@ public: inline QDateTime toLocalTime() const { return toTimeSpec(Qt::LocalTime); } inline QDateTime toUTC() const { return toTimeSpec(Qt::UTC); } QDateTime toOffsetFromUtc(int offsetSeconds) const; +#ifndef QT_BOOTSTRAPPED + QDateTime toTimeZone(const QTimeZone &toZone) const; +#endif // QT_BOOTSTRAPPED qint64 daysTo(const QDateTime &) const; qint64 secsTo(const QDateTime &) const; @@ -279,9 +292,15 @@ public: // ### Qt 6: Merge with above with default spec = Qt::LocalTime static QDateTime fromTime_t(uint secsSince1Jan1970UTC, Qt::TimeSpec spec, int offsetFromUtc = 0); +#ifndef QT_BOOTSTRAPPED + static QDateTime fromTime_t(uint secsSince1Jan1970UTC, const QTimeZone &timeZone); +#endif static QDateTime fromMSecsSinceEpoch(qint64 msecs); // ### Qt 6: Merge with above with default spec = Qt::LocalTime static QDateTime fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetFromUtc = 0); +#ifndef QT_BOOTSTRAPPED + static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone); +#endif static qint64 currentMSecsSinceEpoch() Q_DECL_NOTHROW; private: -- cgit v1.2.3