Eliminate the msecsToTime() overload with out-parameters
Now that I've disposed of the callers that were or might be passing null pointers for the out-parameters, getDateTime() can inline its computation and the two other callers can use msecsTo{Date,Time} until I eliminate the need for that. Change-Id: Ia9169779cf03189fc7fd5271044d1ec90089fa03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
ec1847fa38
commit
a534483518
@ -2717,15 +2717,6 @@ static QTime msecsToTime(qint64 msecs)
|
|||||||
return QTime::fromMSecsSinceStartOfDay(QRoundingDown::qMod(msecs, MSECS_PER_DAY));
|
return QTime::fromMSecsSinceStartOfDay(QRoundingDown::qMod(msecs, MSECS_PER_DAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void msecsToTime(qint64 msecs, QDate *date, QTime *time)
|
|
||||||
{
|
|
||||||
qint64 days = QRoundingDown::qDiv(msecs, MSECS_PER_DAY);
|
|
||||||
if (date)
|
|
||||||
*date = QDate::fromJulianDay(JULIAN_DAY_FOR_EPOCH + days);
|
|
||||||
if (time)
|
|
||||||
*time = QTime::fromMSecsSinceStartOfDay(msecs - days * MSECS_PER_DAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Converts a date/time value into msecs
|
// Converts a date/time value into msecs
|
||||||
static qint64 timeToMSecs(QDate date, QTime time)
|
static qint64 timeToMSecs(QDate date, QTime time)
|
||||||
{
|
{
|
||||||
@ -2952,9 +2943,8 @@ QString QDateTimePrivate::localNameAtMillis(qint64 millis, DaylightStatus dst)
|
|||||||
QString abbreviation;
|
QString abbreviation;
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
if (millisInSystemRange(millis, MSECS_PER_DAY)) {
|
if (millisInSystemRange(millis, MSECS_PER_DAY)) {
|
||||||
QDate dt;
|
QDate dt = msecsToDate(millis);
|
||||||
QTime tm;
|
QTime tm = msecsToTime(millis);
|
||||||
msecsToTime(millis, &dt, &tm);
|
|
||||||
qt_mktime(&dt, &tm, &dst, &abbreviation, &valid);
|
qt_mktime(&dt, &tm, &dst, &abbreviation, &valid);
|
||||||
if (valid)
|
if (valid)
|
||||||
return abbreviation;
|
return abbreviation;
|
||||||
@ -2987,9 +2977,8 @@ QDateTimePrivate::ZoneState QDateTimePrivate::localStateAtMillis(qint64 millis,
|
|||||||
// case it does fall in the range and gets useful information:
|
// case it does fall in the range and gets useful information:
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
if (millisInSystemRange(millis, MSECS_PER_DAY)) {
|
if (millisInSystemRange(millis, MSECS_PER_DAY)) {
|
||||||
QDate dt;
|
QDate dt = msecsToDate(millis);
|
||||||
QTime tm;
|
QTime tm = msecsToTime(millis);
|
||||||
msecsToTime(millis, &dt, &tm);
|
|
||||||
const qint64 utc = qt_mktime(&dt, &tm, &dst, nullptr, &valid);
|
const qint64 utc = qt_mktime(&dt, &tm, &dst, nullptr, &valid);
|
||||||
if (valid && millisInSystemRange(utc)) {
|
if (valid && millisInSystemRange(utc)) {
|
||||||
// mktime() worked and the result falls in its valid range, so use its results
|
// mktime() worked and the result falls in its valid range, so use its results
|
||||||
@ -3341,18 +3330,15 @@ static void setDateTime(QDateTimeData &d, QDate date, QTime time)
|
|||||||
|
|
||||||
static QPair<QDate, QTime> getDateTime(const QDateTimeData &d)
|
static QPair<QDate, QTime> getDateTime(const QDateTimeData &d)
|
||||||
{
|
{
|
||||||
QPair<QDate, QTime> result;
|
|
||||||
qint64 msecs = getMSecs(d);
|
|
||||||
auto status = getStatus(d);
|
auto status = getStatus(d);
|
||||||
msecsToTime(msecs, &result.first, &result.second);
|
const qint64 msecs = getMSecs(d);
|
||||||
|
const qint64 days = QRoundingDown::qDiv(msecs, MSECS_PER_DAY);
|
||||||
if (!status.testFlag(QDateTimePrivate::ValidDate))
|
return { status.testFlag(QDateTimePrivate::ValidDate)
|
||||||
result.first = QDate();
|
? QDate::fromJulianDay(JULIAN_DAY_FOR_EPOCH + days)
|
||||||
|
: QDate(),
|
||||||
if (!status.testFlag(QDateTimePrivate::ValidTime))
|
status.testFlag(QDateTimePrivate::ValidTime)
|
||||||
result.second = QTime();
|
? QTime::fromMSecsSinceStartOfDay(msecs - days * MSECS_PER_DAY)
|
||||||
|
: QTime() };
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user