13#include "private/qcalendarmath_p.h"
14#include "private/qdatetime_p.h"
15#if QT_CONFIG(datetimeparser)
16#include "private/qdatetimeparser_p.h"
19#include "private/qcore_mac_p.h"
21#include "private/qgregoriancalendar_p.h"
22#include "private/qlocale_tools_p.h"
23#include "private/qlocaltime_p.h"
24#include "private/qnumeric_p.h"
25#include "private/qstringconverter_p.h"
26#include "private/qstringiterator_p.h"
27#if QT_CONFIG(timezone)
28#include "private/qtimezoneprivate_p.h"
36#include <private/qtools_p.h>
51static_assert(std::is_trivially_copyable_v<QCalendar::YearMonthDay>);
55 if ((parts.
year < 0 && !cal.isProleptic()) || (parts.
year == 0 && !cal.hasYearZero()))
59 return cal.dateFromParts(parts);
77#if QT_CONFIG(textdate)
78static const char qt_shortMonthNames[][4] = {
79 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
80 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
85 for (
unsigned int i = 0;
i <
sizeof(qt_shortMonthNames) /
sizeof(qt_shortMonthNames[0]); ++
i) {
93#if QT_CONFIG(datestring)
95using ParsedInt = QSimpleParsedNumber<qulonglong>;
123 QVarLengthArray<char> latin1(
text.
size());
130struct ParsedRfcDateTime {
138 const char16_t shortDayNames[] = u
"MonTueWedThuFriSatSun";
139 for (
int i = 0;
i < 7;
i++) {
152 QVarLengthArray<QStringView, 6> words;
156 for (
int i = 0;
i < 6 &&
it != tokens.
end(); ++
i, ++
it)
157 words.emplace_back(*
it);
159 if (words.size() < 3 ||
it != tokens.
end())
161 const QChar colon(u
':');
166 return (
name.size() == 3 &&
name[0].isUpper()
167 &&
name[1].isLower() &&
name[2].isLower());
178 if (maybeDayName.endsWith(u
',')) {
179 dayName = maybeDayName.
chopped(1);
180 words.erase(words.begin());
181 }
else if (!maybeDayName.front().isDigit()) {
182 dayName = maybeDayName;
183 words.erase(words.begin());
186 if (words.size() < 3 || words.size() > 5)
190 int dayIndex, monthIndex;
200 yearIndex = words.
size() > 3 && words.at(2).contains(colon) ? 3 : 2;
205 if (!isShortName(dayName))
207 dayOfWeek = shortDayFromName(dayName);
212 const int day = words.at(dayIndex).toInt(&
ok);
215 const int year = words.at(yearIndex).toInt(&
ok);
219 if (!isShortName(monthName))
221 int month = fromShortMonthName(monthName);
229 words.remove(yearIndex);
234 if (words.size() && words.at(0).contains(colon)) {
236 words.erase(words.begin());
237 if (when.
size() < 5 || when[2] != colon
238 || (when.
size() == 8 ? when[5] != colon : when.
size() > 5)) {
241 const int hour = when.
first(2).toInt(&
ok);
244 const int minute = when.
sliced(3, 2).toInt(&
ok);
247 const auto secs = when.
size() == 8 ? when.
last(2).toInt(&
ok) : 0;
257 words.erase(words.begin());
258 if (words.size() || !(zone.size() == 3 || zone.size() == 5))
263 else if (zone[0] != u
'+')
265 const int hour = zone.sliced(1, 2).toInt(&
ok);
268 const auto minute = zone.size() == 5 ? zone.last(2).toInt(&
ok) : 0;
271 offset = (hour * 60 + minute) * 60;
294#if QT_CONFIG(datestring)
296static int fromOffsetString(
QStringView offsetString,
bool *valid)
noexcept
301 if (size < 2 || size > 6)
308 const QChar signChar = offsetString[0];
309 if (signChar == u
'+')
311 else if (signChar == u
'-')
327 const int hour = hhRef.toInt(&
ok);
328 if (!
ok || hour > 23)
332 const int minute = mmRef.isEmpty() ? 0 : mmRef.toInt(&
ok);
333 if (!
ok || minute < 0 || minute > 59)
337 return sign * ((hour * 60) + minute) * 60;
451 *
this = cal.dateFromParts(
y,
m,
d);
546 const auto parts = cal.partsFromDate(*
this);
598 const auto parts = cal.partsFromDate(*
this);
631 const auto parts = cal.partsFromDate(*
this);
667 return cal.dayOfWeek(*
this);
691 QDate firstDay = cal.dateFromParts(
year(cal), 1, 1);
692 if (firstDay.isValid())
693 return firstDay.
daysTo(*
this) + 1;
706 return jd - *
first + 1;
724 const auto parts = cal.partsFromDate(*
this);
726 return cal.daysInMonth(parts.month, parts.year);
759 return cal.daysInYear(
year(cal));
799 *yearNumber = thursday.year();
802 return (thursday.dayOfYear() + 6) / 7;
805#if QT_DEPRECATED_SINCE(6, 9)
812 qWarning(
"%s: Pass a QTimeZone instead of Qt::TimeZone.", warner);
816 qWarning(
"%s: Ignoring offset (%d seconds) passed with Qt::LocalTime",
822 qWarning(
"%s: Ignoring offset (%d seconds) passed with Qt::UTC",
841 using Bounds = std::numeric_limits<qint64>;
852 return jd > minDay && jd <= maxDay;
854 return jd >= minDay && jd < maxDay;
856 Q_UNREACHABLE_RETURN(
false);
861 Q_ASSERT(!zone.isUtcOrFixedOffset());
870 when = moment(
QTime(12, 0));
873 when = moment(
QTime(23, 59, 59, 999));
881 while (high > low + 1) {
882 const int mid = (high + low) / 2;
898 while (high > low + 1) {
899 const int mid = (high + low) / 2;
900 const int min = mid / 60;
901 const QDateTime probe = moment(
QTime(min / 60, min % 60, mid % 60));
949#if QT_CONFIG(timezone)
951 if (zone.timeSpec() ==
Qt::TimeZone && zone.hasTransitions()) {
952 QTimeZone::OffsetData tran
957 if (
at.isValid() &&
at.date() == *
this)
977#if QT_DEPRECATED_SINCE(6, 9)
1008 QTimeZone zone = asTimeZone(spec, offsetSeconds,
"QDate::startOfDay");
1016 Q_ASSERT(!zone.isUtcOrFixedOffset());
1025 when = moment(
QTime(12, 0));
1028 when = moment(
QTime(0, 0));
1036 while (high > low + 1) {
1037 const int mid = (high + low) / 2;
1053 while (high > low + 1) {
1054 const int mid = (high + low) / 2;
1055 const int min = mid / 60;
1056 const QDateTime probe = moment(
QTime(min / 60, min % 60, mid % 60, 999));
1105#if QT_CONFIG(timezone)
1107 if (zone.timeSpec() ==
Qt::TimeZone && zone.hasTransitions()) {
1108 QTimeZone::OffsetData tran
1112 const QDateTime &
at = tran.atUtc.toTimeZone(zone);
1113 if (
at.isValid() &&
at.date() == *
this)
1132#if QT_DEPRECATED_SINCE(6, 9)
1163 QTimeZone zone = asTimeZone(spec, offsetSeconds,
"QDate::endOfDay");
1169#if QT_CONFIG(datestring)
1176 if (parts.isValid()) {
1190 if (parts.isValid() && parts.year >= 0 && parts.year <= 9999)
1230 return QLocale::c().toString(*
this, u
"dd MMM yyyy");
1233 return toStringTextDate(*
this);
1237 return toStringIsoDate(*
this);
1341 jd = maybe.value_or(nullJd());
1453 auto parts = cal.partsFromDate(*
this);
1455 if (!parts.isValid())
1457 Q_ASSERT(parts.year || cal.hasYearZero());
1459 parts.month += nmonths;
1460 while (parts.month <= 0) {
1461 if (--parts.year || cal.hasYearZero())
1462 parts.month += cal.monthsInYear(parts.year);
1464 int count = cal.monthsInYear(parts.year);
1465 while (parts.month >
count) {
1466 parts.month -=
count;
1467 count = (++parts.year || cal.hasYearZero()) ? cal.monthsInYear(parts.year) : 0;
1487 if (!parts.isValid())
1491 parts.month += nmonths;
1492 while (parts.month <= 0) {
1496 while (parts.month > 12) {
1524 auto parts = cal.partsFromDate(*
this);
1525 if (!parts.isValid())
1528 int old_y = parts.year;
1529 parts.year += nyears;
1532 if (!cal.hasYearZero() && ((old_y > 0) != (parts.year > 0) || !parts.year))
1533 parts.year += nyears > 0 ? +1 : -1;
1548 if (!parts.isValid())
1551 int old_y = parts.year;
1552 parts.year += nyears;
1555 if ((old_y > 0) != (parts.year > 0) || !parts.year)
1556 parts.year += nyears > 0 ? +1 : -1;
1632#if QT_CONFIG(datestring)
1653 if (
string.isEmpty())
1658 return rfcDateImpl(
string).date;
1662 QVarLengthArray<QStringView, 4> parts;
1665 for (
int i = 0;
i < 4 &&
it != tokens.
end(); ++
i, ++
it)
1666 parts.emplace_back(*
it);
1668 if (parts.size() != 4 ||
it != tokens.
end())
1672 int year = parts.at(3).toInt(&
ok);
1673 int day =
ok ? parts.at(2).toInt(&
ok) : 0;
1677 const int month = fromShortMonthName(parts.at(1));
1685 if (
string.
size() >= 10 &&
string[4].isPunct() &&
string[7].isPunct()
1686 && (
string.
size() == 10 || !
string[10].
isDigit())) {
1687 const ParsedInt
year = readInt(
string.
first(4));
1688 const ParsedInt
month = readInt(
string.sliced(5, 2));
1689 const ParsedInt
day = readInt(
string.sliced(8, 2));
1842#if QT_CONFIG(datetimeparser)
1845 if (dt.parseFormat(
format))
1846 dt.fromString(
string, &
date,
nullptr, baseYear);
2110#if QT_CONFIG(datestring)
2135QString QTime::toString(Qt::DateFormat format) const
2142 return QString::asprintf(
"%02d:%02d:%02d.%03d", hour(), minute(), second(), msec());
2326 return theirSeconds - ourSeconds;
2345 t.mds = QRoundingDown::qMod<MSECS_PER_DAY>(ds() + ms);
2367 return t.ds() - ds();
2443#if QT_CONFIG(datestring)
2449 *isMidnight24 =
false;
2455 const qsizetype dot =
string.indexOf(u
'.'), comma =
string.indexOf(u
',');
2460 string =
string.first(
dot);
2461 }
else if (comma != -1) {
2462 tail =
string.
sliced(comma + 1);
2463 string =
string.first(comma);
2468 const ParsedInt frac = readInt(tail);
2470 if (tail.
isEmpty() ?
dot != -1 || comma != -1 : !frac.
ok())
2473 double fraction = frac.ok() ? frac.result * std::pow(0.1, tail.
size()) : 0.0;
2476 if (size < 2 || size > 8)
2479 ParsedInt hour = readInt(
string.
first(2));
2484 if (
string.
size() > 2) {
2485 if (
string[2] == u
':' &&
string.
size() > 4)
2486 minute = readInt(
string.sliced(3, 2));
2491 }
else if (frac.ok()) {
2492 Q_ASSERT(!(fraction < 0.0) && fraction < 1.0);
2495 fraction -= minute.result;
2499 if (
string.
size() > 5) {
2500 if (
string[5] == u
':' &&
string.
size() == 8)
2501 second = readInt(
string.sliced(6, 2));
2504 }
else if (frac.ok()) {
2507 Q_ASSERT(!(fraction < 0.0) && fraction < 1.0);
2510 fraction -= second.result;
2513 Q_ASSERT(!(fraction < 0.0) && fraction < 1.0);
2520 if (isMidnight24 || hour.result < 23 || minute.result < 59 || second.result < 59) {
2538 if (hour.result == 24 && minute.result == 0 && second.result == 0 && msec == 0) {
2541 *isMidnight24 =
true;
2545 return QTime(hour.result, minute.result, second.result, msec);
2563 if (
string.isEmpty())
2568 return rfcDateImpl(
string).time;
2573 return fromIsoTimeString(
string,
format,
nullptr);
2668#if QT_CONFIG(datetimeparser)
2671 if (dt.parseFormat(
format))
2672 dt.fromString(
string,
nullptr, &
time);
2730 return qMulOverflow(days, std::integral_constant<qint64, MSECS_PER_DAY>(), sumMillis)
2739 if (days < 0 && dayms > 0) {
2744 using Bound = std::numeric_limits<qint64>;
2745 return days < 0 ? Bound::min() : Bound::max();
2770 return (bounds.minClip || millis >= bounds.min - slack)
2771 && (bounds.maxClip || millis <= bounds.max + slack);
2792#if defined(Q_OS_WIN) || defined(Q_OS_WASM)
2793 static constexpr int forLeapEarly[] = { 1984, 1996, 1980, 1992, 1976, 1988, 1972 };
2794 static constexpr int regularEarly[] = { 1978, 1973, 1974, 1975, 1970, 1971, 1977 };
2796 static constexpr int forLeapEarly[] = { 1928, 1912, 1924, 1908, 1920, 1904, 1916 };
2797 static constexpr int regularEarly[] = { 1905, 1906, 1907, 1902, 1903, 1909, 1910 };
2799 static constexpr int forLeapLate[] = { 2012, 2024, 2036, 2020, 2032, 2016, 2028 };
2800 static constexpr int regularLate[] = { 2034, 2035, 2030, 2031, 2037, 2027, 2033 };
2804 ? (year < 1970 ? forLeapEarly : forLeapLate)
2805 : (year < 1970 ? regularEarly : regularLate))[dow == 7 ? 0 : dow];
2824#if QT_CONFIG(timezone)
2825 if (
const auto sys = QTimeZone::systemTimeZone(); sys.isValid()) {
2826 result.offset = sys.d->offsetFromUtc(utcMSecs);
2840 qint64 diffMillis, fakeUtc;
2842 ymd.month, ymd.day);
2844 ||
qMulOverflow(jd - *fakeJd, std::integral_constant<qint64, MSECS_PER_DAY>(),
2870 ymd.month, ymd.day);
2929constexpr static QDateTimePrivate::TransitionOptions
2954constexpr static QDateTimePrivate::TransitionOptions
2969 return abbreviation;
2973#if QT_CONFIG(timezone)
2975 const auto sys = QTimeZone::systemTimeZone();
2976 if (sys.isValid()) {
3006#if QT_CONFIG(timezone)
3008 const auto sys = QTimeZone::systemTimeZone();
3010 return zoneStateAtMillis(sys, millis,
resolve);
3021 using Bound = std::numeric_limits<qint64>;
3022 adjusted = millis < fake.shifted ? Bound::min() : Bound::max();
3034#if QT_CONFIG(timezone)
3043 return zone.d->stateAtZoneTime(millis,
resolve);
3048 QDateTimePrivate::TransitionOptions
resolve)
3052#if QT_CONFIG(timezone)
3054 return QDateTimePrivate::zoneStateAtMillis(zone, millis,
resolve);
3066 if constexpr (!QDateTimeData::CanBeSmall)
3071 return sd.msecs == msecs;
3074static constexpr inline
3088static constexpr inline QDateTimePrivate::StatusFlags
3101static constexpr inline
3161 return a->m_offsetFromUtc ==
b->m_offsetFromUtc;
3163 Q_UNREACHABLE_RETURN(
false);
3168 QDateTimePrivate::TransitionOptions
resolve)
3173 int offsetFromUtc = 0;
3195 }
else if (
state.valid) {
3197 offsetFromUtc =
state.offset;
3219 d.data.status = status.toInt();
3221 d->m_status = status;
3222 d->m_offsetFromUtc = offsetFromUtc;
3235 d.data.status = status.toInt();
3237 d->m_status = status;
3264 bool reuse =
d.isShort();
3269 Q_ASSERT(zone.fixedSecondsAheadOfUtc() == 0);
3273 offset = zone.fixedSecondsAheadOfUtc();
3285 d.data.status = status.toInt();
3290#if QT_CONFIG(timezone)
3292 d->m_timeZone = zone;
3308 QDateTimePrivate::StatusFlags newStatus = { };
3326 if (days < 0 && ds > 0) {
3334 newStatus = QDateTimePrivate::StatusFlags{};
3343 d.data.status |= newStatus.toInt();
3353 d->m_status |= newStatus;
3361 const auto dayMilli = QRoundingDown::qDivMod<MSECS_PER_DAY>(msecs);
3374inline QDateTime::Data::Data() noexcept
3383inline QDateTime::Data::Data(
const QTimeZone &zone)
3403inline QDateTime::Data::Data(
const Data &
other) noexcept
3420inline QDateTime::Data::Data(
Data &&
other) noexcept
3426 other.data = dummy.data;
3429inline QDateTime::Data &QDateTime::Data::operator=(
const Data &
other)
noexcept
3436 if (!
other.isShort()) {
3454inline QDateTime::Data::~Data()
3460inline bool QDateTime::Data::isShort()
const
3469 if constexpr (CanBeSmall)
3474inline void QDateTime::Data::detach()
3477 bool wasShort = isShort();
3482 x->m_msecs =
data.msecs;
3490 x->ref.storeRelaxed(1);
3496void QDateTime::Data::invalidate()
3506QTimeZone QDateTime::Data::timeZone()
const
3514#if QT_CONFIG(timezone)
3547 QDateTime::Data
result(zone);
3549 if (zone.isUtcOrFixedOffset())
3945#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED) || QT_POINTER_SIZE == 8
3947 static_assert(
sizeof(
Data) ==
sizeof(
qint64));
3949 static_assert(
sizeof(
ShortData) >=
sizeof(
void*),
"oops, Data::swap() is broken!");
3952#if QT_DEPRECATED_SINCE(6, 9)
4148 return d.timeZone();
4151#if QT_CONFIG(timezone)
4169 return d.timeZone().asBackendZone();
4247#if !QT_CONFIG(timezone)
4281#if !QT_CONFIG(timezone)
4349#if QT_DEPRECATED_SINCE(6, 9)
4390void QDateTime::setOffsetFromUtc(
int offsetSeconds)
4468#if QT_CONFIG(timezone)
4475 Q_UNREACHABLE_RETURN(0);
4530#if QT_CONFIG(timezone)
4539 data.daylightTimeOffset
4555 d.data.status = status.toInt();
4578 if (!
qMulOverflow(secs, std::integral_constant<qint64, MSECS_PER_SEC>(), &msecs))
4584#if QT_CONFIG(datestring)
4615QString QDateTime::toString(Qt::DateFormat format) const
4623 buf =
QLocale::c().toString(*
this, u
"dd MMM yyyy hh:mm:ss ");
4629 buf = toStringTextDate(
p.first);
4631 buf.insert(
buf.lastIndexOf(u
' '),
4634 switch (timeSpec()) {
4637#if QT_CONFIG(timezone)
4639 buf += u
' ' +
d->m_timeZone.displayName(
4657 buf = toStringIsoDate(
p.first);
4768 d.data.msecs =
state.when;
4769 d.data.status = status.toInt();
4772 d->m_status = status;
4775 d->m_offsetFromUtc =
state.offset;
4871 if (
qMulOverflow(
s, std::integral_constant<qint64, MSECS_PER_SEC>(), &msecs))
4896 dt.setMSecsSinceEpoch(msecs);
4906 dt.d.data.msecs =
qintptr(msecs);
4909 dt.d->m_msecs = msecs;
5070#if QT_DEPRECATED_SINCE(6, 9)
5092 return toTimeZone(asTimeZone(spec, 0,
"toTimeSpec"));
5190 return !
other.isValid();
5191 if (!
other.isValid())
5427#if defined(Q_OS_WIN)
5428static inline uint msecsFromDecomposed(
int hour,
int minute,
int sec,
int msec = 0)
5437 return QDate(st.wYear, st.wMonth, st.wDay);
5445 ct.
setHMS(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
5457 (spec ==
Qt::LocalTime ? GetLocalTime : GetSystemTime)(&st);
5458 QDate d(st.wYear, st.wMonth, st.wDay);
5459 QTime t(msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds));
5463 return spec ==
Qt::UTC ? utc : utc.toTimeZone(zone);
5472 return msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds) +
5486#elif defined(Q_OS_UNIX)
5504 struct timespec when;
5505 if (clock_gettime(CLOCK_REALTIME, &when) == 0)
5506 return when.tv_sec *
MSECS_PER_SEC + (when.tv_nsec + 500'000) / 1'000'000;
5507 Q_UNREACHABLE_RETURN(0);
5512 struct timespec when;
5513 if (clock_gettime(CLOCK_REALTIME, &when) == 0)
5515 Q_UNREACHABLE_RETURN(0);
5518#error "What system is this?"
5521#if QT_DEPRECATED_SINCE(6, 9)
5548 asTimeZone(spec, offsetSeconds,
"QDateTime::fromMSecsSinceEpoch"));
5577 asTimeZone(spec, offsetSeconds,
"QDateTime::fromSecsSinceEpoch"));
5599 dt.setMSecsSinceEpoch(msecs);
5630 dt.setSecsSinceEpoch(secs);
5643#if QT_CONFIG(datestring)
5663 if (
string.isEmpty())
5668 const ParsedRfcDateTime rfc = rfcDateImpl(
string);
5670 if (!rfc.date.isValid() || !rfc.time.isValid())
5679 const int size =
string.size();
5693 if (isoString.size() < 2
5698 || isoString.startsWith(u
' '))) {
5701 isoString = isoString.sliced(1);
5710 int signIndex = isoString.size() - 1;
5714 QChar character(isoString[signIndex]);
5715 found = character == u
'+' || character == u
'-';
5716 }
while (!found && --signIndex >= 0);
5720 int offset = fromOffsetString(isoString.sliced(signIndex), &
ok);
5723 isoString = isoString.first(signIndex);
5730 bool isMidnight24 =
false;
5739 QVarLengthArray<QStringView, 6> parts;
5743 for (
int i = 0;
i < 6 &&
it != tokens.
end(); ++
i, ++
it)
5744 parts.emplace_back(*
it);
5748 if (parts.size() < 5 ||
it != tokens.
end())
5755 if (parts.at(3).contains(u
':'))
5757 else if (parts.at(4).contains(u
':'))
5763 int day = parts.at(2).toInt(&
ok);
5764 int year =
ok ? parts.at(yearPart).toInt(&
ok) : 0;
5765 int month = fromShortMonthName(parts.at(1));
5766 if (!
ok || year == 0 || day == 0 || month < 1)
5773 const QTime time = fromIsoTimeString(parts.at(timePart),
format,
nullptr);
5777 if (parts.size() == 5)
5781 if (
tz.startsWith(
"UTC"_L1)
5899#if QT_CONFIG(datetimeparser)
5904 if (dt.parseFormat(
format) && (dt.fromString(
string, &datetime, baseYear)
5967#ifndef QT_NO_DATASTREAM
5978 if (
out.version() < QDataStream::Qt_5_0)
5994 if (
in.version() < QDataStream::Qt_5_0) {
5998 date.jd = (jd != 0 ? jd : QDate::nullJd());
6016 if (
out.version() >= QDataStream::Qt_4_0) {
6036 if (
in.version() >= QDataStream::Qt_4_0) {
6040 time.mds = (ds == 0) ? QTime::NullTime : int(ds);
6054 std::pair<QDate, QTime> dateAndTime;
6057 if (
out.version() >= QDataStream::Qt_5_2) {
6064#if QT_CONFIG(timezone)
6069 }
else if (
out.version() == QDataStream::Qt_5_0) {
6078 }
else if (
out.version() >= QDataStream::Qt_4_0) {
6124 if (
in.version() >= QDataStream::Qt_5_2) {
6127 in >> dt >> tm >> ts;
6147 }
else if (
in.version() == QDataStream::Qt_5_0) {
6150 in >> dt >> tm >> ts;
6155 }
else if (
in.version() >= QDataStream::Qt_4_0) {
6158 in >> dt >> tm >> ts;
6188#if !defined(QT_NO_DEBUG_STREAM) && QT_CONFIG(datestring)
6192 dbg.nospace() <<
"QDate(";
6200 dbg.nospace() <<
"Invalid";
6201 dbg.nospace() <<
')';
6208 dbg.nospace() <<
"QTime(";
6210 dbg.nospace() <<
time.toString(u
"HH:mm:ss.zzz");
6212 dbg.nospace() <<
"Invalid";
6213 dbg.nospace() <<
')';
6220 dbg.nospace() <<
"QDateTime(";
6223 dbg.noquote() <<
date.toString(u
"yyyy-MM-dd HH:mm:ss.zzz t")
6229 dbg.space() <<
date.offsetFromUtc() <<
's';
6232#if QT_CONFIG(timezone)
6233 dbg.space() <<
date.timeZone().id();
6240 dbg.nospace() <<
"Invalid";
6242 return dbg.nospace() <<
')';
T loadRelaxed() const noexcept
The QCalendar class describes calendar systems.
YearMonthDay partsFromDate(QDate date) const
Converts a QDate to a year, month, and day of the month.
\inmodule QtCore\reentrant
QDateTime::ShortData QDateTimeShortData
static QDateTime::Data create(QDate toDate, QTime toTime, const QTimeZone &timeZone, QDateTime::TransitionResolution resolve)
static ZoneState localStateAtMillis(qint64 millis, TransitionOptions resolve)
QDateTime::Data QDateTimeData
static ZoneState expressUtcAsLocal(qint64 utcMSecs)
static QString localNameAtMillis(qint64 millis, DaylightStatus dst)
\inmodule QtCore\reentrant
void setDate(QDate date, TransitionResolution resolve=TransitionResolution::LegacyBehavior)
Sets the date part of this datetime to date.
int offsetFromUtc() const
~QDateTime()
Destroys the datetime.
static QDateTime currentDateTime()
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setMSecsSinceEpoch(qint64 msecs)
qint64 toMSecsSinceEpoch() const
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
qint64 secsTo(const QDateTime &) const
Returns the number of seconds from this datetime to the other datetime.
QDateTime addMSecs(qint64 msecs) const
Returns a QDateTime object containing a datetime msecs milliseconds later than the datetime of this o...
QDateTime addMonths(int months) const
Returns a QDateTime object containing a datetime nmonths months later than the datetime of this objec...
bool isNull() const
Returns true if both the date and the time are null; otherwise returns false.
QDateTime & operator=(const QDateTime &other) noexcept
Copies the other datetime into this and returns this copy.
static QDateTime fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone)
QDateTime toTimeZone(const QTimeZone &toZone) const
qint64 msecsTo(const QDateTime &) const
Returns the number of milliseconds from this datetime to the other datetime.
QDateTime toUTC() const
Returns a copy of this datetime converted to UTC.
void setTimeZone(const QTimeZone &toZone, TransitionResolution resolve=TransitionResolution::LegacyBehavior)
QTime time() const
Returns the time part of the datetime.
QDateTime() noexcept
Constructs a null datetime, nominally using local time.
QDateTime toLocalTime() const
Returns a copy of this datetime converted to local time.
QString timeZoneAbbreviation() const
QDateTime addSecs(qint64 secs) const
Returns a QDateTime object containing a datetime s seconds later than the datetime of this object (or...
static qint64 currentSecsSinceEpoch() noexcept
Qt::TimeSpec timeSpec() const
Returns the time specification of the datetime.
bool isDaylightTime() const
bool isValid() const
Returns true if this datetime represents a definite moment, otherwise false.
static QDateTime currentDateTimeUtc()
QDateTime toOffsetFromUtc(int offsetSeconds) const
qint64 daysTo(const QDateTime &) const
Returns the number of days from this datetime to the other datetime.
static qint64 currentMSecsSinceEpoch() noexcept
qint64 toSecsSinceEpoch() const
friend class QDateTimePrivate
void setTime(QTime time, TransitionResolution resolve=TransitionResolution::LegacyBehavior)
Sets the time part of this datetime to time.
QTimeZone timeRepresentation() const
QDateTime addYears(int years) const
Returns a QDateTime object containing a datetime nyears years later than the datetime of this object ...
QDate date() const
Returns the date part of the datetime.
QDateTime addDays(qint64 days) const
Returns a QDateTime object containing a datetime ndays days later than the datetime of this object (o...
void setSecsSinceEpoch(qint64 secs)
\inmodule QtCore \reentrant
int weekNumber(int *yearNum=nullptr) const
Returns the ISO 8601 week number (1 to 53).
QDateTime endOfDay() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qint64 daysTo(QDate d) const
Returns the number of days from this date to d (which is negative if d is earlier than this date).
constexpr bool isValid() const
Returns true if this date is valid; otherwise returns false.
constexpr qint64 toJulianDay() const
Converts the date to a Julian day.
int month() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static constexpr QDate fromJulianDay(qint64 jd_)
Converts the Julian day jd to a QDate.
int day() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QDate addDays(qint64 days) const
Returns a QDate object containing a date ndays later than the date of this object (or earlier if nday...
QDate addYears(int years) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr bool isNull() const
Returns true if the date is null; otherwise returns false.
int year() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QDate addMonths(int months) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void getDate(int *year, int *month, int *day) const
static QDate currentDate()
Returns the system clock's current date.
int daysInMonth() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QDateTime startOfDay(const QTimeZone &zone) const
int daysInYear() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr QDate()
Constructs a null date.
int dayOfYear() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QDateTime startOfDay() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int dayOfWeek() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool setDate(int year, int month, int day)
static bool isLeapYear(int year)
Returns true if the specified year is a leap year in the Gregorian calendar; otherwise returns false.
static std::optional< qint64 > julianFromParts(int year, int month, int day)
static int yearStartWeekDay(int year)
static int monthLength(int month, int year)
static bool leapTest(int year)
static QCalendar::YearMonthDay partsFromJulian(qint64 jd)
static bool validParts(int year, int month, int day)
static int weekDayOfJulian(qint64 jd)
constexpr const char * data() const noexcept
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
constexpr bool isEmpty() const noexcept
Returns whether this string view is empty - that is, whether {size() == 0}.
constexpr qsizetype size() const noexcept
Returns the size of this string view, in UTF-16 code units (that is, surrogate pairs count as two for...
constexpr QStringView first(qsizetype n) const noexcept
constexpr QStringView chopped(qsizetype n) const noexcept
Returns the substring of length size() - length starting at the beginning of this object.
constexpr QStringView last(qsizetype n) const noexcept
constexpr QChar at(qsizetype n) const noexcept
Returns the character at position n in this string view.
constexpr QChar front() const
qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QStringView sliced(qsizetype pos) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
QChar * data()
Returns a pointer to the data stored in the QString.
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
static constexpr qint64 invalidSeconds()
bool isValid() const
Returns true if this time zone is valid.
static QTimeZone fromSecondsAheadOfUtc(int offset)
constexpr bool isUtcOrFixedOffset() const noexcept
\inmodule QtCore \reentrant
int secsTo(QTime t) const
Returns the number of seconds from this time to t.
constexpr bool isNull() const
Returns true if the time is null (i.e., the QTime object was constructed using the default constructo...
static QTime currentTime()
Returns the current time as reported by the system clock.
QTime addMSecs(int ms) const
Returns a QTime object containing a time ms milliseconds later than the time of this object (or earli...
int hour() const
Returns the hour part (0 to 23) of the time.
int minute() const
Returns the minute part (0 to 59) of the time.
bool isValid() const
Returns true if the time is valid; otherwise returns false.
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,...
int msecsTo(QTime t) const
Returns the number of milliseconds from this time to t.
int msec() const
Returns the millisecond part (0 to 999) of the time.
bool setHMS(int h, int m, int s, int ms=0)
Sets the time to hour h, minute m, seconds s and milliseconds ms.
constexpr int msecsSinceStartOfDay() const
Returns the number of msecs since the start of the day, i.e.
int second() const
Returns the second part (0 to 59) of the time.
constexpr QTime()
Constructs a null time object.
QTime addSecs(int secs) const
Returns a QTime object containing a time s seconds later than the time of this object (or earlier if ...
\variable Qt::strong_ordering::less
static const weak_ordering less
static const weak_ordering greater
static const weak_ordering equivalent
QSet< QString >::iterator it
QString localTimeAbbbreviationAt(qint64 local, QDateTimePrivate::TransitionOptions resolve)
SystemMillisRange computeSystemMillisRange()
QDateTimePrivate::ZoneState utcToLocal(qint64 utcMillis)
QDateTimePrivate::ZoneState mapLocalTime(qint64 local, QDateTimePrivate::TransitionOptions resolve)
Combined button and popup list for selecting options.
constexpr bool isAsciiDigit(char32_t c) noexcept
constexpr qint64 JulianDayMax
constexpr qint64 SECS_PER_HOUR
constexpr qint64 MSECS_PER_MIN
constexpr qint64 SECS_PER_MIN
constexpr qint64 SECS_PER_DAY
constexpr qint64 JulianDayMin
constexpr qint64 MSECS_PER_DAY
constexpr qint64 JULIAN_DAY_FOR_EPOCH
constexpr qint64 MINS_PER_HOUR
constexpr qint64 MSECS_PER_SEC
constexpr qint64 MSECS_PER_HOUR
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
static QTime msecsToTime(qint64 msecs)
static auto millisToWithinRange(qint64 millis)
static QDateTime toLatest(QDate day, const QTimeZone &zone)
static constexpr QDateTimePrivate::StatusFlags mergeDaylightStatus(QDateTimePrivate::StatusFlags sf, QDateTimePrivate::DaylightStatus status)
static qint64 timeToMSecs(QDate date, QTime time)
static std::pair< QDate, QTime > getDateTime(const QDateTimeData &d)
static constexpr QDateTimePrivate::DaylightStatus extractDaylightStatus(QDateTimePrivate::StatusFlags status)
size_t qHash(const QDateTime &key, size_t seed)
static Qt::TimeSpec getSpec(const QDateTimeData &d)
QDateTimePrivate::QDateTimeShortData ShortData
static void reviseTimeZone(QDateTimeData &d, const QTimeZone &zone, QDateTime::TransitionResolution resolve)
static QDateTimePrivate::StatusFlags getStatus(const QDateTimeData &d)
static qint64 getMSecs(const QDateTimeData &d)
static void massageAdjustedDateTime(QDateTimeData &d, QDate date, QTime time, bool forward)
static bool inDateTimeRange(qint64 jd, DaySide side)
QDateTimePrivate::QDateTimeData QDateTimeData
static bool specCanBeSmall(Qt::TimeSpec spec)
static int systemTimeYearMatching(int year)
static constexpr QDateTimePrivate::StatusFlags mergeSpec(QDateTimePrivate::StatusFlags status, Qt::TimeSpec spec)
static QDate msecsToDate(qint64 msecs)
static QString toOffsetString(Qt::DateFormat format, int offset)
static bool daysAndMillisOverflow(qint64 days, qint64 millisInDay, qint64 *sumMillis)
static QDate fixedDate(QCalendar::YearMonthDay parts, QCalendar cal)
static constexpr QDateTimePrivate::TransitionOptions toTransitionOptions(QDateTime::TransitionResolution res)
static void refreshSimpleDateTime(QDateTimeData &d)
static void setDateTime(QDateTimeData &d, QDate date, QTime time)
static void refreshZonedDateTime(QDateTimeData &d, const QTimeZone &zone, QDateTimePrivate::TransitionOptions resolve)
static bool msecsCanBeSmall(qint64 msecs)
static constexpr Qt::TimeSpec extractSpec(QDateTimePrivate::StatusFlags status)
static bool usesSameOffset(const QDateTimeData &a, const QDateTimeData &b)
static void checkValidDateTime(QDateTimeData &d, QDateTime::TransitionResolution resolve)
Qt::weak_ordering compareThreeWay(const QDateTime &lhs, const QDateTime &rhs)
static QDateTime toEarliest(QDate day, const QTimeZone &zone)
static QDateTimePrivate::ZoneState stateAtMillis(const QTimeZone &zone, qint64 millis, QDateTimePrivate::TransitionOptions resolve)
static bool millisInSystemRange(qint64 millis, qint64 slack=0)
static qint64 msecsToJulianDay(qint64 msecs)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
constexpr const T & qMin(const T &a, const T &b)
constexpr T qAbs(const T &t)
std::enable_if_t< std::is_unsigned_v< T >, bool > qAddOverflow(T v1, T v2, T *r)
std::enable_if_t< std::is_unsigned_v< T >, bool > qSubOverflow(T v1, T v2, T *r)
std::enable_if_t< std::is_unsigned_v< T >||std::is_signed_v< T >, bool > qMulOverflow(T v1, T v2, T *r)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
static qreal dot(const QPointF &a, const QPointF &b)
static bool fromString(const QMetaObject *mo, QString s, Allocate &&allocate)
static const QQmlJSScope * resolve(const QQmlJSScope *current, const QStringList &names)
static QT_BEGIN_NAMESPACE bool isDigit(ushort ch)
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
static ISC_DATE toDate(QDate t)
static ISC_TIME toTime(QTime t)
QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
QT_BEGIN_NAMESPACE typedef signed char qint8
static double LocalTime(double t, double localTZA)
static int toInt(const QChar &qc, int R)
QTextStream out(stdout)
[7]
\inmodule QtCore \reentrant
static char * convertFromUnicode(char *out, QStringView in, QStringConverter::State *state) noexcept