Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qdatetime.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// Copyright (C) 2021 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QDATETIME_H
6#define QDATETIME_H
7
8#include <QtCore/qcalendar.h>
9#include <QtCore/qnamespace.h>
10#include <QtCore/qshareddata.h>
11#include <QtCore/qstring.h>
12
13#include <limits>
14#include <chrono>
15
16#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
19#endif
20
22
23class QTimeZone;
24class QDateTime;
25
26class Q_CORE_EXPORT QDate
27{
28 explicit constexpr QDate(qint64 julianDay) : jd(julianDay) {}
29public:
30 constexpr QDate() : jd(nullJd()) {}
31 QDate(int y, int m, int d);
32 QDate(int y, int m, int d, QCalendar cal);
33#if __cpp_lib_chrono >= 201907L || defined(Q_QDOC)
35 Q_IMPLICIT QDate(std::chrono::year_month_day ymd)
36 {
37 if (!ymd.ok())
38 jd = nullJd();
39 else
40 *this = fromStdSysDays(ymd);
41 }
42
44 Q_IMPLICIT QDate(std::chrono::year_month_day_last ymdl)
45 {
46 if (!ymdl.ok())
47 jd = nullJd();
48 else
49 *this = fromStdSysDays(ymdl);
50 }
51
53 Q_IMPLICIT QDate(std::chrono::year_month_weekday ymw)
54 {
55 if (!ymw.ok())
56 jd = nullJd();
57 else
58 *this = fromStdSysDays(ymw);
59 }
60
62 Q_IMPLICIT QDate(std::chrono::year_month_weekday_last ymwl)
63 {
64 if (!ymwl.ok())
65 jd = nullJd();
66 else
67 *this = fromStdSysDays(ymwl);
68 }
69
71 static QDate fromStdSysDays(const std::chrono::sys_days &days)
72 {
73 const QDate epoch(unixEpochJd());
74 return epoch.addDays(days.time_since_epoch().count());
75 }
76
78 std::chrono::sys_days toStdSysDays() const
79 {
80 const QDate epoch(unixEpochJd());
81 return std::chrono::sys_days(std::chrono::days(epoch.daysTo(*this)));
82 }
83#endif
84
85 constexpr bool isNull() const { return !isValid(); }
86 constexpr bool isValid() const { return jd >= minJd() && jd <= maxJd(); }
87
88 // Gregorian-optimized:
89 int year() const;
90 int month() const;
91 int day() const;
92 int dayOfWeek() const;
93 int dayOfYear() const;
94 int daysInMonth() const;
95 int daysInYear() const;
96 int weekNumber(int *yearNum = nullptr) const; // ISO 8601, always Gregorian
97
98 int year(QCalendar cal) const;
99 int month(QCalendar cal) const;
100 int day(QCalendar cal) const;
101 int dayOfWeek(QCalendar cal) const;
102 int dayOfYear(QCalendar cal) const;
103 int daysInMonth(QCalendar cal) const;
104 int daysInYear(QCalendar cal) const;
105
106#if QT_DEPRECATED_SINCE(6, 9)
107 QT_DEPRECATED_VERSION_X_6_9("Pass QTimeZone instead")
108 QDateTime startOfDay(Qt::TimeSpec spec, int offsetSeconds = 0) const;
110 QDateTime endOfDay(Qt::TimeSpec spec, int offsetSeconds = 0) const;
111#endif
112
113 QDateTime startOfDay(const QTimeZone &zone) const;
114 QDateTime endOfDay(const QTimeZone &zone) const;
115 QDateTime startOfDay() const;
116 QDateTime endOfDay() const;
117
118#if QT_CONFIG(datestring)
120 QString toString(const QString &format, QCalendar cal = QCalendar()) const
121 { return toString(qToStringViewIgnoringNull(format), cal); }
123#endif
124 bool setDate(int year, int month, int day); // Gregorian-optimized
125 bool setDate(int year, int month, int day, QCalendar cal);
126
127 void getDate(int *year, int *month, int *day) const;
128
129 [[nodiscard]] QDate addDays(qint64 days) const;
130#if __cpp_lib_chrono >= 201907L || defined(Q_QDOC)
132 [[nodiscard]] QDate addDuration(std::chrono::days days) const
133 {
134 return addDays(days.count());
135 }
136#endif
137 // Gregorian-optimized:
138 [[nodiscard]] QDate addMonths(int months) const;
139 [[nodiscard]] QDate addYears(int years) const;
140 [[nodiscard]] QDate addMonths(int months, QCalendar cal) const;
141 [[nodiscard]] QDate addYears(int years, QCalendar cal) const;
142 qint64 daysTo(QDate d) const;
143
145#if QT_CONFIG(datestring)
148 { return fromString(string.toString(), format, cal); }
149 static QDate fromString(const QString &string, QStringView format, QCalendar cal = QCalendar());
151 { return fromString(qToStringViewIgnoringNull(string), format); }
152 static QDate fromString(const QString &string, const QString &format,
153 QCalendar cal = QCalendar())
154 { return fromString(string, qToStringViewIgnoringNull(format), cal); }
155#endif
156 static bool isValid(int y, int m, int d);
157 static bool isLeapYear(int year);
158
159 static constexpr inline QDate fromJulianDay(qint64 jd_)
160 { return jd_ >= minJd() && jd_ <= maxJd() ? QDate(jd_) : QDate() ; }
161 constexpr inline qint64 toJulianDay() const { return jd; }
162
163private:
164 // using extra parentheses around min to avoid expanding it if it is a macro
165 static constexpr inline qint64 nullJd() { return (std::numeric_limits<qint64>::min)(); }
166 static constexpr inline qint64 minJd() { return Q_INT64_C(-784350574879); }
167 static constexpr inline qint64 maxJd() { return Q_INT64_C( 784354017364); }
168 static constexpr inline qint64 unixEpochJd() { return Q_INT64_C(2440588); }
169
170 qint64 jd;
171
172 friend class QDateTime;
173 friend class QDateTimePrivate;
174
175 friend constexpr bool operator==(QDate lhs, QDate rhs) { return lhs.jd == rhs.jd; }
176 friend constexpr bool operator!=(QDate lhs, QDate rhs) { return lhs.jd != rhs.jd; }
177 friend constexpr bool operator< (QDate lhs, QDate rhs) { return lhs.jd < rhs.jd; }
178 friend constexpr bool operator<=(QDate lhs, QDate rhs) { return lhs.jd <= rhs.jd; }
179 friend constexpr bool operator> (QDate lhs, QDate rhs) { return lhs.jd > rhs.jd; }
180 friend constexpr bool operator>=(QDate lhs, QDate rhs) { return lhs.jd >= rhs.jd; }
181#ifndef QT_NO_DATASTREAM
182 friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QDate);
183 friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDate &);
184#endif
185};
187
188class Q_CORE_EXPORT QTime
189{
190 explicit constexpr QTime(int ms) : mds(ms)
191 {}
192public:
193 constexpr QTime(): mds(NullTime)
194 {}
195 QTime(int h, int m, int s = 0, int ms = 0);
196
197 constexpr bool isNull() const { return mds == NullTime; }
198 bool isValid() const;
199
200 int hour() const;
201 int minute() const;
202 int second() const;
203 int msec() const;
204#if QT_CONFIG(datestring)
206 QString toString(const QString &format) const
209#endif
210 bool setHMS(int h, int m, int s, int ms = 0);
211
212 [[nodiscard]] QTime addSecs(int secs) const;
213 int secsTo(QTime t) const;
214 [[nodiscard]] QTime addMSecs(int ms) const;
215 int msecsTo(QTime t) const;
216
217 static constexpr inline QTime fromMSecsSinceStartOfDay(int msecs) { return QTime(msecs); }
218 constexpr inline int msecsSinceStartOfDay() const { return mds == NullTime ? 0 : mds; }
219
221#if QT_CONFIG(datestring)
224 { return fromString(string.toString(), format); }
225 static QTime fromString(const QString &string, QStringView format);
227 { return fromString(qToStringViewIgnoringNull(string), format); }
228 static QTime fromString(const QString &string, const QString &format)
229 { return fromString(string, qToStringViewIgnoringNull(format)); }
230#endif
231 static bool isValid(int h, int m, int s, int ms = 0);
232
233private:
234 enum TimeFlag { NullTime = -1 };
235 constexpr inline int ds() const { return mds == -1 ? 0 : mds; }
236 int mds;
237
238 friend constexpr bool operator==(QTime lhs, QTime rhs) { return lhs.mds == rhs.mds; }
239 friend constexpr bool operator!=(QTime lhs, QTime rhs) { return lhs.mds != rhs.mds; }
240 friend constexpr bool operator< (QTime lhs, QTime rhs) { return lhs.mds < rhs.mds; }
241 friend constexpr bool operator<=(QTime lhs, QTime rhs) { return lhs.mds <= rhs.mds; }
242 friend constexpr bool operator> (QTime lhs, QTime rhs) { return lhs.mds > rhs.mds; }
243 friend constexpr bool operator>=(QTime lhs, QTime rhs) { return lhs.mds >= rhs.mds; }
244
245 friend class QDateTime;
246 friend class QDateTimePrivate;
247#ifndef QT_NO_DATASTREAM
248 friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QTime);
249 friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QTime &);
250#endif
251};
253
254class QDateTimePrivate;
255
256class Q_CORE_EXPORT QDateTime
257{
258 struct ShortData {
259#if QT_VERSION >= QT_VERSION_CHECK(7,0,0) || defined(QT_BOOTSTRAPPED)
260# if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
261 qint64 status : 8;
262# endif
263 qint64 msecs : 56;
264
265# if Q_BYTE_ORDER == Q_BIG_ENDIAN
266 qint64 status : 8;
267# endif
268#else
269# if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
270 quintptr status : 8;
271# endif
272 // note: this is only 24 bits on 32-bit systems...
273 qintptr msecs : sizeof(void *) * 8 - 8;
274
275# if Q_BYTE_ORDER == Q_BIG_ENDIAN
276 quintptr status : 8;
277# endif
278#endif
279 friend constexpr bool operator==(const ShortData &lhs, const ShortData &rhs)
280 { return lhs.status == rhs.status && lhs.msecs == rhs.msecs; }
281 };
282
283 union Data {
284 // To be of any use, we need at least 60 years around 1970, which
285 // is 1,893,456,000,000 ms. That requires 41 bits to store, plus
286 // the sign bit. With the status byte, the minimum size is 50 bits.
287 static constexpr bool CanBeSmall = sizeof(ShortData) * 8 > 50;
288
289 Data() noexcept;
290 Data(const QTimeZone &);
291 Data(const Data &other) noexcept;
292 Data(Data &&other) noexcept;
293 Data &operator=(const Data &other) noexcept;
294 Data &operator=(Data &&other) noexcept { swap(other); return *this; }
295 ~Data();
296
297 void swap(Data &other) noexcept
298 { std::swap(data, other.data); }
299
300 bool isShort() const;
301 void detach();
302 QTimeZone timeZone() const;
303
304 const QDateTimePrivate *operator->() const;
305 QDateTimePrivate *operator->();
306
309 };
310
311public:
312 QDateTime() noexcept;
313#if QT_DEPRECATED_SINCE(6, 9)
314 QT_DEPRECATED_VERSION_X_6_9("Pass QTimeZone instead")
315 QDateTime(QDate date, QTime time, Qt::TimeSpec spec, int offsetSeconds = 0);
316#endif
317 QDateTime(QDate date, QTime time, const QTimeZone &timeZone);
319 QDateTime(const QDateTime &other) noexcept;
320 QDateTime(QDateTime &&other) noexcept;
321 ~QDateTime();
322
323 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QDateTime)
324 QDateTime &operator=(const QDateTime &other) noexcept;
325
326 void swap(QDateTime &other) noexcept { d.swap(other.d); }
327
328 bool isNull() const;
329 bool isValid() const;
330
331 QDate date() const;
332 QTime time() const;
333 Qt::TimeSpec timeSpec() const;
334 int offsetFromUtc() const;
335 QTimeZone timeRepresentation() const;
336#if QT_CONFIG(timezone)
337 QTimeZone timeZone() const;
338#endif // timezone
339 QString timeZoneAbbreviation() const;
340 bool isDaylightTime() const;
341
342 qint64 toMSecsSinceEpoch() const;
343 qint64 toSecsSinceEpoch() const;
344
345 void setDate(QDate date);
346 void setTime(QTime time);
347#if QT_DEPRECATED_SINCE(6, 9)
348 QT_DEPRECATED_VERSION_X_6_9("Use setTimeZone() instead")
349 void setTimeSpec(Qt::TimeSpec spec);
350 QT_DEPRECATED_VERSION_X_6_9("Use setTimeZone() instead")
351 void setOffsetFromUtc(int offsetSeconds);
352#endif
353 void setTimeZone(const QTimeZone &toZone);
354 void setMSecsSinceEpoch(qint64 msecs);
355 void setSecsSinceEpoch(qint64 secs);
356
357#if QT_CONFIG(datestring)
359 QString toString(const QString &format, QCalendar cal = QCalendar()) const
360 { return toString(qToStringViewIgnoringNull(format), cal); }
362#endif
363 [[nodiscard]] QDateTime addDays(qint64 days) const;
364 [[nodiscard]] QDateTime addMonths(int months) const;
365 [[nodiscard]] QDateTime addYears(int years) const;
366 [[nodiscard]] QDateTime addSecs(qint64 secs) const;
367 [[nodiscard]] QDateTime addMSecs(qint64 msecs) const;
368 [[nodiscard]] QDateTime addDuration(std::chrono::milliseconds msecs) const
369 {
370 return addMSecs(msecs.count());
371 }
372
373#if QT_DEPRECATED_SINCE(6, 9)
374 QT_DEPRECATED_VERSION_X_6_9("Use toTimeZone instead")
375 QDateTime toTimeSpec(Qt::TimeSpec spec) const;
376#endif
377 QDateTime toLocalTime() const;
378 QDateTime toUTC() const;
379 QDateTime toOffsetFromUtc(int offsetSeconds) const;
380 QDateTime toTimeZone(const QTimeZone &toZone) const;
381
382 qint64 daysTo(const QDateTime &) const;
383 qint64 secsTo(const QDateTime &) const;
384 qint64 msecsTo(const QDateTime &) const;
385
387 static QDateTime currentDateTime();
388 static QDateTime currentDateTimeUtc();
389#if QT_CONFIG(datestring)
392 QCalendar cal = QCalendar())
393 { return fromString(string.toString(), format, cal); }
394 static QDateTime fromString(const QString &string, QStringView format,
395 QCalendar cal = QCalendar());
397 { return fromString(qToStringViewIgnoringNull(string), format); }
398 static QDateTime fromString(const QString &string, const QString &format,
399 QCalendar cal = QCalendar())
400 { return fromString(string, qToStringViewIgnoringNull(format), cal); }
401#endif
402
403#if QT_DEPRECATED_SINCE(6, 9)
404 QT_DEPRECATED_VERSION_X_6_9("Pass QTimeZone instead of time-spec, offset")
405 static QDateTime fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetFromUtc = 0);
406 QT_DEPRECATED_VERSION_X_6_9("Pass QTimeZone instead of time-spec, offset")
407 static QDateTime fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spec, int offsetFromUtc = 0);
408#endif
409
410 static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone);
411 static QDateTime fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone);
412 static QDateTime fromMSecsSinceEpoch(qint64 msecs);
413 static QDateTime fromSecsSinceEpoch(qint64 secs);
414
416 static qint64 currentSecsSinceEpoch() noexcept;
417
418#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
419 static QDateTime fromCFDate(CFDateRef date);
420 CFDateRef toCFDate() const Q_DECL_CF_RETURNS_RETAINED;
421 static QDateTime fromNSDate(const NSDate *date);
422 NSDate *toNSDate() const Q_DECL_NS_RETURNS_AUTORELEASED;
423#endif
424
425#if __cpp_lib_chrono >= 201907L || defined(Q_QDOC)
426#if __cpp_concepts >= 201907L || defined(Q_QDOC)
427 // Generic clock, as long as it's compatible with us (= system_clock)
428 template <typename Clock, typename Duration>
429 static QDateTime fromStdTimePoint(const std::chrono::time_point<Clock, Duration> &time)
430 requires
431 requires(const std::chrono::time_point<Clock, Duration> &t) {
432 // the clock can be converted to system_clock
433 std::chrono::clock_cast<std::chrono::system_clock>(t);
434 // the duration can be converted to milliseconds
435 requires std::is_convertible_v<Duration, std::chrono::milliseconds>;
436 }
437 {
438 const auto sysTime = std::chrono::clock_cast<std::chrono::system_clock>(time);
439 // clock_cast can change the duration, so convert it again to milliseconds
440 const auto timeInMSec = std::chrono::time_point_cast<std::chrono::milliseconds>(sysTime);
441 return fromMSecsSinceEpoch(timeInMSec.time_since_epoch().count(), Qt::UTC);
442 }
443#endif // __cpp_concepts
444
445 // local_time
447 static QDateTime fromStdTimePoint(const std::chrono::local_time<std::chrono::milliseconds> &time)
448 {
449 return fromStdLocalTime(time);
450 }
451
453 static QDateTime fromStdLocalTime(const std::chrono::local_time<std::chrono::milliseconds> &time)
454 {
455 QDateTime result(QDate(1970, 1, 1), QTime(0, 0, 0));
456 return result.addMSecs(time.time_since_epoch().count());
457 }
458
459#if QT_CONFIG(timezone) && (__cpp_lib_chrono >= 201907L || defined(Q_QDOC))
460 // zoned_time. defined in qtimezone.h
462 static QDateTime fromStdZonedTime(const std::chrono::zoned_time<
463 std::chrono::milliseconds,
464 const std::chrono::time_zone *
465 > &time);
466#endif // QT_CONFIG(timezone)
467
469 std::chrono::sys_time<std::chrono::milliseconds> toStdSysMilliseconds() const
470 {
471 const std::chrono::milliseconds duration(toMSecsSinceEpoch());
472 return std::chrono::sys_time<std::chrono::milliseconds>(duration);
473 }
474
476 std::chrono::sys_seconds toStdSysSeconds() const
477 {
478 const std::chrono::seconds duration(toSecsSinceEpoch());
479 return std::chrono::sys_seconds(duration);
480 }
481#endif // __cpp_lib_chrono >= 201907L
482
483 friend std::chrono::milliseconds operator-(const QDateTime &lhs, const QDateTime &rhs)
484 {
485 return std::chrono::milliseconds(rhs.msecsTo(lhs));
486 }
487
488 friend QDateTime operator+(const QDateTime &dateTime, std::chrono::milliseconds duration)
489 {
490 return dateTime.addMSecs(duration.count());
491 }
492
493 friend QDateTime operator+(std::chrono::milliseconds duration, const QDateTime &dateTime)
494 {
495 return dateTime + duration;
496 }
497
498 QDateTime &operator+=(std::chrono::milliseconds duration)
499 {
500 *this = addMSecs(duration.count());
501 return *this;
502 }
503
504 friend QDateTime operator-(const QDateTime &dateTime, std::chrono::milliseconds duration)
505 {
506 return dateTime.addMSecs(-duration.count());
507 }
508
509 QDateTime &operator-=(std::chrono::milliseconds duration)
510 {
511 *this = addMSecs(-duration.count());
512 return *this;
513 }
514
515 // (1<<63) ms is 292277024.6 (average Gregorian) years, counted from the start of 1970, so
516 // Last is floor(1970 + 292277024.6); no year 0, so First is floor(1970 - 1 - 292277024.6)
517 enum class YearRange : qint32 { First = -292275056, Last = +292278994 };
518
519private:
520 bool equals(const QDateTime &other) const;
521 bool precedes(const QDateTime &other) const;
522 friend class QDateTimePrivate;
523
524 Data d;
525
526 friend bool operator==(const QDateTime &lhs, const QDateTime &rhs) { return lhs.equals(rhs); }
527 friend bool operator!=(const QDateTime &lhs, const QDateTime &rhs) { return !(lhs == rhs); }
528 friend bool operator<(const QDateTime &lhs, const QDateTime &rhs) { return lhs.precedes(rhs); }
529 friend bool operator<=(const QDateTime &lhs, const QDateTime &rhs) { return !(rhs < lhs); }
530 friend bool operator>(const QDateTime &lhs, const QDateTime &rhs) { return rhs.precedes(lhs); }
531 friend bool operator>=(const QDateTime &lhs, const QDateTime &rhs) { return !(lhs < rhs); }
532
533#ifndef QT_NO_DATASTREAM
534 friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
535 friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDateTime &);
536#endif
537
538#if !defined(QT_NO_DEBUG_STREAM) && QT_CONFIG(datestring)
539 friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &);
540#endif
541};
542Q_DECLARE_SHARED(QDateTime)
543
544#ifndef QT_NO_DATASTREAM
549Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
551#endif // QT_NO_DATASTREAM
552
553#if !defined(QT_NO_DEBUG_STREAM) && QT_CONFIG(datestring)
554Q_CORE_EXPORT QDebug operator<<(QDebug, QDate);
555Q_CORE_EXPORT QDebug operator<<(QDebug, QTime);
556Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &);
557#endif
558
559// QDateTime is not noexcept for now -- to be revised once
560// timezone and calendaring support is added
561Q_CORE_EXPORT size_t qHash(const QDateTime &key, size_t seed = 0);
562Q_CORE_EXPORT size_t qHash(QDate key, size_t seed = 0) noexcept;
563Q_CORE_EXPORT size_t qHash(QTime key, size_t seed = 0) noexcept;
564
566
567#endif // QDATETIME_H
The QCalendar class describes calendar systems.
Definition qcalendar.h:53
\inmodule QtCore\reentrant
Definition qdatastream.h:30
\inmodule QtCore\reentrant
Definition qdatetime.h:257
friend bool operator>(const QDateTime &lhs, const QDateTime &rhs)
Returns true if lhs is later than rhs; otherwise returns false.
Definition qdatetime.h:530
friend bool operator<=(const QDateTime &lhs, const QDateTime &rhs)
Returns true if lhs is earlier than or equal to rhs; otherwise returns false.
Definition qdatetime.h:529
QDateTime & operator+=(std::chrono::milliseconds duration)
Definition qdatetime.h:498
QDateTime addMSecs(qint64 msecs) const
Returns a QDateTime object containing a datetime msecs milliseconds later than the datetime of this o...
friend bool operator!=(const QDateTime &lhs, const QDateTime &rhs)
Returns true if lhs is different from rhs; otherwise returns false.
Definition qdatetime.h:527
friend bool operator>=(const QDateTime &lhs, const QDateTime &rhs)
Returns true if lhs is later than or equal to rhs; otherwise returns false.
Definition qdatetime.h:531
qint64 msecsTo(const QDateTime &) const
Returns the number of milliseconds from this datetime to the other datetime.
friend QDateTime operator+(const QDateTime &dateTime, std::chrono::milliseconds duration)
Definition qdatetime.h:488
QDateTime addDuration(std::chrono::milliseconds msecs) const
Definition qdatetime.h:368
friend bool operator==(const QDateTime &lhs, const QDateTime &rhs)
Returns true if lhs is the same as rhs; otherwise returns false.
Definition qdatetime.h:526
QDateTime & operator-=(std::chrono::milliseconds duration)
Definition qdatetime.h:509
friend QDateTime operator+(std::chrono::milliseconds duration, const QDateTime &dateTime)
Definition qdatetime.h:493
static qint64 currentMSecsSinceEpoch() noexcept
static QDateTime currentDateTime(const QTimeZone &zone)
friend QDateTime operator-(const QDateTime &dateTime, std::chrono::milliseconds duration)
Definition qdatetime.h:504
friend bool operator<(const QDateTime &lhs, const QDateTime &rhs)
Returns true if lhs is earlier than rhs; otherwise returns false.
Definition qdatetime.h:528
friend std::chrono::milliseconds operator-(const QDateTime &lhs, const QDateTime &rhs)
Definition qdatetime.h:483
void swap(QDateTime &other) noexcept
Definition qdatetime.h:326
\inmodule QtCore \reentrant
Definition qdatetime.h:27
constexpr bool isValid() const
Returns true if this date is valid; otherwise returns false.
Definition qdatetime.h:86
constexpr qint64 toJulianDay() const
Converts the date to a Julian day.
Definition qdatetime.h:161
static constexpr QDate fromJulianDay(qint64 jd_)
Converts the Julian day jd to a QDate.
Definition qdatetime.h:159
constexpr bool isNull() const
Returns true if the date is null; otherwise returns false.
Definition qdatetime.h:85
friend constexpr bool operator!=(QDate lhs, QDate rhs)
Returns true if lhs and rhs represent distinct days; otherwise returns false.
Definition qdatetime.h:176
friend constexpr bool operator>=(QDate lhs, QDate rhs)
Returns true if lhs is later than or equal to rhs; otherwise returns false.
Definition qdatetime.h:180
static QDate currentDate()
Returns the system clock's current date.
constexpr QDate()
Constructs a null date.
Definition qdatetime.h:30
friend constexpr bool operator<=(QDate lhs, QDate rhs)
Returns true if lhs is earlier than or equal to rhs; otherwise returns false.
Definition qdatetime.h:178
friend constexpr bool operator==(QDate lhs, QDate rhs)
Returns true if lhs and rhs represent the same day, otherwise false.
Definition qdatetime.h:175
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:76
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qtimezone.h:25
\inmodule QtCore \reentrant
Definition qdatetime.h:189
friend constexpr bool operator<=(QTime lhs, QTime rhs)
Returns true if lhs is earlier than or equal to rhs; otherwise returns false.
Definition qdatetime.h:241
constexpr bool isNull() const
Returns true if the time is null (i.e., the QTime object was constructed using the default constructo...
Definition qdatetime.h:197
static QTime currentTime()
Returns the current time as reported by the system clock.
friend constexpr bool operator==(QTime lhs, QTime rhs)
Returns true if lhs is equal to rhs; otherwise returns false.
Definition qdatetime.h:238
friend constexpr bool operator!=(QTime lhs, QTime rhs)
Returns true if lhs is different from rhs; otherwise returns false.
Definition qdatetime.h:239
static constexpr QTime fromMSecsSinceStartOfDay(int msecs)
Returns a new QTime instance with the time set to the number of msecs since the start of the day,...
Definition qdatetime.h:217
constexpr int msecsSinceStartOfDay() const
Returns the number of msecs since the start of the day, i.e.
Definition qdatetime.h:218
friend constexpr bool operator>=(QTime lhs, QTime rhs)
Returns true if lhs is later than or equal to rhs; otherwise returns false.
Definition qdatetime.h:243
constexpr QTime()
Constructs a null time object.
Definition qdatetime.h:193
QDate date
[1]
Combined button and popup list for selecting options.
@ UTC
DateFormat
@ TextDate
std::chrono::duration< IntRep, std::ratio< 86400 > > days
Definition q20chrono.h:52
#define QT_POST_CXX17_API_IN_EXPORTED_CLASS
#define Q_DECL_NS_RETURNS_AUTORELEASED
#define Q_DECL_CF_RETURNS_RETAINED
#define Q_IMPLICIT
#define Q_FORWARD_DECLARE_CF_TYPE(type)
#define Q_FORWARD_DECLARE_OBJC_CLASS(classname)
QDateTimePrivate::QDateTimeShortData ShortData
Q_CORE_EXPORT QDataStream & operator>>(QDataStream &, QDate &)
Q_CORE_EXPORT size_t qHash(const QDateTime &key, size_t seed=0)
Q_CORE_EXPORT QDataStream & operator<<(QDataStream &, QDate)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static const char months[]
static qint64 msecsTo(const QDateTime &from, const QDateTime &to)
const GLfloat * m
GLuint64 key
GLfloat GLfloat f
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
bool operator>(const QPoint &a, const QPoint &b)
static bool fromString(const QMetaObject *mo, QString s, Allocate &&allocate)
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1219
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
#define QT_DEPRECATED_VERSION_X_6_9(text)
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:145
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:163
size_t quintptr
Definition qtypes.h:72
int qint32
Definition qtypes.h:44
long long qint64
Definition qtypes.h:55
#define Q_INT64_C(c)
Definition qtypes.h:52
ptrdiff_t qintptr
Definition qtypes.h:71
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QDataStream & operator>>(QDataStream &in, MyClass &myObj)
QDateTime dateTime
[12]
d1 daysTo(d2)
QSharedPointer< T > other(t)
[5]
this swap(other)
char * toString(const MyType &t)
[31]