diff options
Diffstat (limited to 'src/corelib/time/qdatetime.h')
-rw-r--r-- | src/corelib/time/qdatetime.h | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index 89ea4ee24a..3eae8ebf64 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -54,10 +54,11 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSDate); QT_BEGIN_NAMESPACE +class QCalendar; class QTimeZone; class QDateTime; -class Q_CORE_EXPORT QDate +class Q_CORE_EXPORT QDate // ### Qt 6: change to be used by value, not const & { public: enum MonthNameType { // ### Qt 6: remove, along with methods using it @@ -69,6 +70,7 @@ private: public: Q_DECL_CONSTEXPR QDate() : jd(nullJd()) {} QDate(int y, int m, int d); + QDate(int y, int m, int d, QCalendar cal); Q_DECL_CONSTEXPR bool isNull() const { return !isValid(); } Q_DECL_CONSTEXPR bool isValid() const { return jd >= minJd() && jd <= maxJd(); } @@ -82,6 +84,14 @@ public: int daysInYear() const; int weekNumber(int *yearNum = nullptr) const; + int year(QCalendar cal) const; + int month(QCalendar cal) const; + int day(QCalendar cal) const; + int dayOfWeek(QCalendar cal) const; + int dayOfYear(QCalendar cal) const; + int daysInMonth(QCalendar cal) const; + int daysInYear(QCalendar cal) const; + QDateTime startOfDay(Qt::TimeSpec spec = Qt::LocalTime, int offsetSeconds = 0) const; QDateTime endOfDay(Qt::TimeSpec spec = Qt::LocalTime, int offsetSeconds = 0) const; #if QT_CONFIG(timezone) @@ -103,8 +113,12 @@ public: QString toString(Qt::DateFormat f = Qt::TextDate) const; #if QT_STRINGVIEW_LEVEL < 2 QString toString(const QString &format) const; + QString toString(const QString &format, QCalendar cal) const; #endif + QString toString(QStringView format) const; + QString toString(Qt::DateFormat f, QCalendar cal) const; + QString toString(QStringView format, QCalendar cal) const; #endif #if QT_DEPRECATED_SINCE(5,0) QT_DEPRECATED_X("Use setDate() instead") inline bool setYMD(int y, int m, int d) @@ -112,6 +126,7 @@ public: #endif bool setDate(int year, int month, int day); + bool setDate(int year, int month, int day, QCalendar cal); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void getDate(int *year, int *month, int *day); // ### Qt 6: remove @@ -121,7 +136,9 @@ public: Q_REQUIRED_RESULT QDate addDays(qint64 days) const; Q_REQUIRED_RESULT QDate addMonths(int months) const; Q_REQUIRED_RESULT QDate addYears(int years) const; - qint64 daysTo(const QDate &) const; + Q_REQUIRED_RESULT QDate addMonths(int months, QCalendar cal) const; + Q_REQUIRED_RESULT QDate addYears(int years, QCalendar cal) const; + qint64 daysTo(const QDate &) const; // ### Qt 6: QDate Q_DECL_CONSTEXPR bool operator==(const QDate &other) const { return jd == other.jd; } Q_DECL_CONSTEXPR bool operator!=(const QDate &other) const { return jd != other.jd; } @@ -134,6 +151,7 @@ public: #if QT_CONFIG(datestring) static QDate fromString(const QString &s, Qt::DateFormat f = Qt::TextDate); static QDate fromString(const QString &s, const QString &format); + static QDate fromString(const QString &s, const QString &format, QCalendar cal); #endif static bool isValid(int y, int m, int d); static bool isLeapYear(int year); @@ -159,7 +177,7 @@ private: }; Q_DECLARE_TYPEINFO(QDate, Q_MOVABLE_TYPE); -class Q_CORE_EXPORT QTime +class Q_CORE_EXPORT QTime // ### Qt 6: change to be used by value, not const & { explicit Q_DECL_CONSTEXPR QTime(int ms) : mds(ms) {} @@ -185,9 +203,9 @@ public: bool setHMS(int h, int m, int s, int ms = 0); Q_REQUIRED_RESULT QTime addSecs(int secs) const; - int secsTo(const QTime &) const; + int secsTo(const QTime &) const; // ### Qt 6: plain QTime Q_REQUIRED_RESULT QTime addMSecs(int ms) const; - int msecsTo(const QTime &) const; + int msecsTo(const QTime &) const; // ### Qt 6: plain QTime Q_DECL_CONSTEXPR bool operator==(const QTime &other) const { return mds == other.mds; } Q_DECL_CONSTEXPR bool operator!=(const QTime &other) const { return mds != other.mds; } @@ -218,7 +236,7 @@ private: friend class QDateTime; friend class QDateTimePrivate; -#ifndef QT_NO_DATASTREAM +#ifndef QT_NO_DATASTREAM // ### Qt 6: plain QTime friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QTime &); friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QTime &); #endif @@ -269,7 +287,7 @@ class Q_CORE_EXPORT QDateTime public: QDateTime() noexcept(Data::CanBeSmall); - explicit QDateTime(const QDate &); + explicit QDateTime(const QDate &); // ### Qt 6: plain QDate, QTime 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); @@ -301,7 +319,7 @@ public: qint64 toMSecsSinceEpoch() const; qint64 toSecsSinceEpoch() const; - void setDate(const QDate &date); + void setDate(const QDate &date); // ### Qt 6: plain QDate void setTime(const QTime &time); void setTimeSpec(Qt::TimeSpec spec); void setOffsetFromUtc(int offsetSeconds); @@ -353,6 +371,7 @@ public: #if QT_CONFIG(datestring) static QDateTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate); static QDateTime fromString(const QString &s, const QString &format); + static QDateTime fromString(const QString &s, const QString &format, QCalendar cal); #endif #if QT_DEPRECATED_SINCE(5, 8) |